diff --git a/.cproject b/.cproject index 0c0add5..edb5d25 100644 --- a/.cproject +++ b/.cproject @@ -5,7 +5,6 @@ - @@ -16,60 +15,59 @@ - - - - - - - + + + + + - - - - - - - - + + + + - - - + @@ -86,9 +84,6 @@ - - - @@ -103,11 +98,8 @@ - - - - - - + + + diff --git a/.project b/.project index 7bd8870..e87f5c8 100644 --- a/.project +++ b/.project @@ -3,6 +3,8 @@ UbixOS + UbixOS Kernel + UbixOS Libc diff --git a/DEBUG b/DEBUG new file mode 100644 index 0000000..a6d239a --- /dev/null +++ b/DEBUG @@ -0,0 +1,3 @@ +#DEBUG_EXEC - Exec Debug +#DEBUG_VFS - VFS DEBUG +#DEBUG_SYSCTL - SYSCTL DEBUG diff --git a/DEBUG_INFO b/DEBUG_INFO deleted file mode 100644 index a6d239a..0000000 --- a/DEBUG_INFO +++ /dev/null @@ -1,3 +0,0 @@ -#DEBUG_EXEC - Exec Debug -#DEBUG_VFS - VFS DEBUG -#DEBUG_SYSCTL - SYSCTL DEBUG diff --git a/Dump/Ubix-CLOUDNINE.flp b/Dump/Ubix-CLOUDNINE.flp deleted file mode 100644 index d18d75f..0000000 --- a/Dump/Ubix-CLOUDNINE.flp +++ /dev/null Binary files differ diff --git a/Dump/UbixOS-080504.flp b/Dump/UbixOS-080504.flp deleted file mode 100644 index 2462273..0000000 --- a/Dump/UbixOS-080504.flp +++ /dev/null Binary files differ diff --git a/Dump/hybos/Makefile b/Dump/hybos/Makefile deleted file mode 100644 index d90ac30..0000000 --- a/Dump/hybos/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -MAKEFILE=Makefile - -all: - make -f $(MAKEFILE) -C src - -install: - make -f $(MAKEFILE) -C src install - -clean: - make -f $(MAKEFILE) -C lib clean - make -f $(MAKEFILE) -C src clean diff --git a/Dump/hybos/README.txt b/Dump/hybos/README.txt deleted file mode 100644 index 6f0e2f2..0000000 --- a/Dump/hybos/README.txt +++ /dev/null @@ -1,210 +0,0 @@ -OSD demo code - Interim release (January, 2003) - -I am working a new set of kernels, but it's slow going, so here -are the old kernels with some bug fixes and improvements. - -Location of these files: http://www.execpc.com/~geezer/osd/code - -The GRUB bootloader is GPL, all other files are PUBLIC DOMAIN -(no copyright). You may do whatever you want with them. - -================================================================ -QUICK START -================================================================ -1. Make sure you have all the software tools you need. You need NASM: - http://nasm.sourceforge.net - - You need the GNU C compiler (GCC), including binutils, GNU Make, - and sed. Users of DOS and Win9x should get GCC for DOS (DJGPP): - http://www.delorie.com/djgpp - - Find a mirror site near you and download the following - packages (NNN is version number): - compiler v2gnu/gccNNNNb.zip - binutils v2gnu/bnuNNNNb.zip - libraries v2/djdevNNN.zip - Make v2gnu/makNNNNb.zip - sed v2gnu/sedNNb.zip - CWSDPMI v2misc/csdpmiN.zip - - Users of WinNT/Win2000/WinXP should get GCC for Win32 (MinGW): - http://mingw.sourceforge.net - - Users of Linux can use the GNU tools that come with Linux. If - they're not already installed, check the CD-ROMs or FTP site - from where you got Linux. - - DOS and Windows users also need John Fine's Partial Copy (PARTCOPY): - http://www.execpc.com/~geezer/johnfine/#zero - -2. Create a formatted floppy disk with the GRUB bootloader - installed on it. The procedure to do this is described below. - -3. Got your tools? Got your GRUB floppy? Then you're ready to - build and install the demo kernels. - - If you're using DJGPP, type make -f dj.mak install - - If you're using MinGW, type make -f ming.mak install - - If you're using Linux, type make -f linux.mak install - -Hopefully, everything will work properly. If it does, you'll be -left with a bootable GRUB floppy with 7 demo kernels on it -(OSD 3 - OSD 9). - -================================================================ -MAKING A BOOTABLE FLOPPY DISK WITH THE GRUB BOOTLOADER ON IT -================================================================ -GRUB is a GPLed bootloader. - -Home page: http://www.gnu.org/software/grub -Binaries: ftp://alpha.gnu.org/gnu/grub/grub-0.90-i386-pc.tar.gz -Source code: ftp://alpha.gnu.org/gnu/grub/grub-0.90.tar.gz -HOW-TOs: http://www.washingdishes.freeuk.com/grubtut.html - http://www.execpc.com/~geezer/osd/boot/grub-how.txt - -1. You will need - - Two 1.44 meg floppy disks, one of them formatted with a - filesystem that GRUB recognizes (e.g. FAT12 or ext2). - The other floppy (the "unformatted" floppy) may contain - a filesystem, but it will be destroyed. - - The GRUB binaries: files "stage1" and "stage2". These are - in the OSD distribution, in the directory "boot/grub". - - A "menu.lst" configuration file for GRUB. Again, this - is provided with OSD in the "boot/grub" directory. - -2. On the formatted floppy disk, create the subdirectory - "/boot/grub/", and copy the files "stage1", "stage2", and - "menu.lst" into this subdirectory. - -3. Concatenate the binary files "stage1" and "stage2" into a - single binary file named "boot": - (DOS/Windows): copy /b stage1 + stage2 boot - (Linux): cat stage1 stage2 >boot - -4. Write the file "boot" directly to the unformatted floppy. - This is a sector-level write that does not use (and will - destroy) any filesystem present on the disk: - (DOS/Windows): partcopy boot 0 168000 -f0 - (Linux): cat boot >/dev/fd0 - - PARTCOPY will display an error message because "boot" is - much shorter than 0x168000 bytes, but this is OK. - -5. Boot your PC from the unformatted floppy disk. - -6. After GRUB has started, eject the unformatted floppy and - insert the formatted floppy, containing the "stage1", - "stage2", and "menu.lst" files, all in the "/boot/grub/" - subdirectory. Type: - setup (fd0) - -7. The formatted floppy is now bootable. Do not move, modify, - or delete the file "/boot/grub/stage2" on this floppy. - -================================================================ -BUGS/GOTCHAS/"IT DOESN'T WORK!" -================================================================ -- DJGPP crashes under Windows XP - The DJGPP team is working on a way to fix this. If you have - any flavor of WindowsNT (including WindowsXP) use MinGW - instead of DJGPP. - -- Will CygWin work instead of MinGW? - Probably, but I haven't tested it. - -- 'make -f ming.mak clean' doesn't delete .o files in /lib/ - I know, but I can't figure out how to fix it. Make sure - these files get deleted if you switch between MinGW and - DJGPP. The linkers can't distinguish between DJGPP COFF - .o files and Win32 PE COFF .o files, but they ARE different, - and your kernels will crash if you mix the two COFF types. - -- BFD: Dwarf Error: Abbrev offset (1075154) greater than or - equal to .debug_abbrev size (3198). - This is a bug in new versions of DJGPP. It's ugly, but you - can ignore it. - -- Do not use MinGW GCC 2.x with NASM - MinGW based on GCC 2.95.2 stores the BSS size in the wrong - field of the section header. Because of this bug, this - version of MinGW will not interoperate with other toolchains, - including NASM, Microsoft compilers, and Borland compilers. - -- Screen fills with errors when compiling under Linux - There are two possible causes for this: - 1. Linux GCC chokes on DOS-style newlines in the source code. - Run all source code files and makefiles through 'fromdos' - to convert the DOS newlines (CR-LF) to UNIX newlines (LF). - 2. There is no newline at the very end of the file. - -- ld: krnl.x: Not enough room for program headers, try linking with -N - This error occurs if you do not use AT() in the linker script - when making an ELF kernel. - -- Exception 10 (bad TSS) - If the NT bit in the EFLAGS register is set, IRET will attempt - a TSS-based task-switch, instead of a normal IRET. Code was - added to osd9/kstart.asm to prevent this. (GRUB 0.90 leaves - the NT bit set when it jumps to the kernel.) - -- Errors from GRUB: - 'Error: Loading below 1M not supported' - 'Error 28: Selected item won't fit into memory' - These errors are usually caused by improperly-linked ELF - kernels. If your kernel is ELF, try this: - objdump --private-headers -h krnl.x - The vaddr and paddr fields for each program header (segment) - must be at or above 1 meg (00100000h) but smaller than your - RAM size. If you have readelf, you can also do this: - readelf --segments krnl.x - If you find a segment with bad values of VirtAddr or - PhysAddr, look at the section-to-segment mapping to see - which section is causing the problem. - -================================================================ -DEMO CODE OVERVIEW -================================================================ -osd3 mixing C and asm, C calling convention, underscores - (xxx - current code does not demonstrate these very well) - -osd4 putch() and kprintf() - -osd5 C library code moved to separate directory - -osd6 software interrupts, exception handlers in asm and C - -osd7 hardware interrupts, reprogramming the 8259 interrupt - controller chips, simple keyboard driver - -osd8 multitasking preliminaries: multiple (virtual) consoles - backed with video memory, ANSI/VT escapes for moving - the cursor and changing text color. Improved keyboard - driver; can press Ctrl+Alt+Del to reboot. - -osd9 cooperative multitasking with setjmp() and longjump() - (static tasks; linked into the kernel at compile-time) - -================================================================ -WHAT CHANGED? -================================================================ -- Updated GRUB to version 0.90 -- Wrote MinGW makefiles, and fixed code to work with MinGW - based on GCC 3.x (and generate error message for GCC 2.x) -- Fixed definition of MAKEFILE in lib/linux.mak -- BIG changes to linker script - - Unified ELF/DJGPP COFF/Win32 PE COFF linker scripts into one - - Added AT() statements so ELF kernels link properly, and - work properly - - Now handling .rodata section properly, so ELF kernels work - properly (including multiple .rodata sections with GCC 3.x) -- Rewrote setjmp() and longjmp() because they were buggy (though, - strangely enough, the bug did not manifest itself) -- Added code to osd9/kstart.asm to zero NT bit in EFLAGS, - preventing exception 10 -- Now enabling interrupts for each task in function init_tasks() - of osd9/sched.c. In previous code, interrupts were disabled - for all tasks except the idle task, making the blinking - character in the upper left corner of the screen appear to - blink much more slowly than 18 Hz. diff --git a/Dump/hybos/__experimental/README.txt b/Dump/hybos/__experimental/README.txt deleted file mode 100644 index fba9e05..0000000 --- a/Dump/hybos/__experimental/README.txt +++ /dev/null @@ -1,87 +0,0 @@ -Sector-level disk I/O code for various OSes - -This code is public domain (no copyright). -You can do whatever you want with it. - -Chris Giese http://www.execpc.com/~geezer - -================================================================ -BUILD -================================================================ -After a successful build, the executable is named 'diskio.exe' - -DOS - Turbo C++ 1.0 or Turbo C++ 3.0: - make - -DOS - Watcom C: - wmake /f watcom16.mak - -32-bit DOS - DJGPP: - make -f djgpp.mak - -32-bit DOS - Watcom C with CauseWay DOS extender: - wmake /f watcom32.mak - -NOTE: 32-bit code built with Watcom C does not yet work. - -Windows NT - MinGW or CygWin: - make -f win-nt.mak - -NOTE: Windows NT version is not tested. - -Linux - GCC: - xxx - to do - -If you have Windows9x, build and run this code as a DOS program, -not a Win32 program. - -================================================================ -API -================================================================ -/* disk_t, open_disk(), read_sector(), write_sector() */ -#include "diskio.h" - -int main(void) { - unsigned long lba_sector_num; - unsigned char buf[512]; - unsigned drive; - disk_t disk; - -/* drive values for floppies: - 0 for A:, 1 for B:, etc. -drive values for hard drives: - 0x80 for first hard drive, 0x81 for second hard drive, etc. */ - drive = 0; -/* read hard drive partition table or floppy boot sector */ - lba_sector_num = 0; - if(open_disk(&disk, drive) == 0) - if(read_sector(&disk, lba_sector_num, buf) == 0) - /* success */; - return 0; } - -================================================================ -TO DO -================================================================ -Test if code writes to disk properly - -Test Windows NT version -- See if the following work with Windows NT: - - 1.44 meg FAT12 floppy (my guess: YES) - - 1.68 meg FAT12 floppy (my guess: YES) - - 1.44 meg non-FAT (e.g. ext2) floppy (my guess: YES) - - 1.68 meg non-FAT floppy (my guess: NO) -- Is there a Windows NT ioctl() to get floppy disk geometry? - Does it work for non-FAT floppy disks? (How do I make NT read - a 1.68 meg non-FAT floppy?) - -Make it work with Linux - -Make it work with 32-bit Watcom C - -Maybe add a disk cache - -Maybe support disks with sector size other than 512 bytes -(e.g. 2048-byte CD-ROM sectors)? - -Any way to access CD-ROM with INT 13h functions? -WITHOUT booting from the CD-ROM? diff --git a/Dump/hybos/__experimental/demo.c b/Dump/hybos/__experimental/demo.c deleted file mode 100644 index 4a20581..0000000 --- a/Dump/hybos/__experimental/demo.c +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for various OSes -This code is public domain (no copyright). -You can do whatever you want with it. -*****************************************************************************/ -#include /* printf(), putchar() */ -#include "diskio.h" -/***************************************************************************** -*****************************************************************************/ -#define BPERL 16 /* byte/line for dump */ - -static void dump(unsigned char *data, unsigned count) -{ - unsigned char byte1, byte2; - - while(count != 0) - { - for(byte1 = 0; byte1 < BPERL; byte1++) - { - if(count == 0) - break; - printf("%02X ", data[byte1]); - count--; - } - printf("\t"); - for(byte2 = 0; byte2 < byte1; byte2++) - { - if(data[byte2] < ' ') - putchar('.'); - else - putchar(data[byte2]); - } - printf("\n"); - data += BPERL; - } -} -/***************************************************************************** -*****************************************************************************/ -int main(void) -{ - unsigned char buf[512], *ptab_rec; - unsigned i = 0; - disk_t disk; - - printf("Looking for FAT (DOS) disk or partition...\n"); -/* check if floppy in A: drive */ - if(open_disk(&disk, 0) == 0) - { -/* read bootsector, check if FAT */ - if(read_sector(&disk, 0, buf) == 0) - { - if(is_fat_bootsector(buf)) - goto OK; - } - } -/* scan hard drives for FAT partition */ - for(i = 0x80; i < 0x82; i++) - { - if(open_disk(&disk, i) != 0) - continue; -/* read MBR */ - if(read_sector(&disk, 0, buf) != 0) - continue; -/* find FAT partition */ - for(i = 0; i < 4; i++) - { - ptab_rec = buf + 446 + 16 * i; -/* make sure it's FAT */ - if(ptab_rec[4] == 0x01 || /* FAT 12 */ - ptab_rec[4] == 0x04 || /* FAT 16 <32meg */ - ptab_rec[4] == 0x06 || /* FAT 16 >=32meg */ - ptab_rec[4] == 0x0E) /* LBA type 0x06 */ - { -/* xxx - note if FAT16 or FAT12 */ - disk.partition_start = LE32(ptab_rec + 8); - goto OK; - } - } - } - printf("No FAT partitions found on any disk\n"); - return 1; -OK: - if(disk.drive_num >= 0x80) - printf("Partition #%u on ", i); - printf("INT 13h disk number 0x%02X:\n", disk.drive_num); - if(read_sector(&disk, 0, buf) != 0) - printf("Error reading bootsector\n"); - else - { - printf("Hex dump of bootsector:\n"); - dump(buf, 64); - } - return 0; -} diff --git a/Dump/hybos/__experimental/diskio.h b/Dump/hybos/__experimental/diskio.h deleted file mode 100644 index 71ff36c..0000000 --- a/Dump/hybos/__experimental/diskio.h +++ /dev/null @@ -1,59 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for various OSes -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS (API): -DEBUG(), BPS, LE16(), LE32(), disk_t, -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int write_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int is_fat_bootsector(unsigned char *buf); -int open_disk(disk_t *disk, unsigned drive_num); -*****************************************************************************/ -#ifndef __DISKIO_H -#define __DISKIO_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#if 0 -#define DEBUG(X) X -#else -#define DEBUG(X) /* nothing */ -#endif - -#define BPS 512 /* bytes/sector */ - -/* these assume little endian CPU like x86 */ -#define LE16(X) *(uint16_t *)(X) -#define LE32(X) *(uint32_t *)(X) - -/* STDINT.H -these assume sizeof(short)==2 and sizeof(long)==4 */ -typedef unsigned short uint16_t; -typedef unsigned long uint32_t; - -typedef struct -{ - unsigned char drive_num; -/* CHS disk geometry (heads and sectors are used only if use_lba==0) */ - unsigned use_lba : 1; - unsigned char heads; - unsigned char sectors; -/* LBA sector address of partition start (hard disk only) */ - unsigned long partition_start; -} disk_t; - -/* these are in DISKIO.C */ -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int write_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int is_fat_bootsector(unsigned char *buf); -int open_disk(disk_t *disk, unsigned drive_num); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/__experimental/djgpp.c b/Dump/hybos/__experimental/djgpp.c deleted file mode 100644 index ee35e57..0000000 --- a/Dump/hybos/__experimental/djgpp.c +++ /dev/null @@ -1,131 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for DOS, using DJGPP. -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS: -int lba_biosdisk(int cmd, int drive, unsigned long lba, - int nsects, void *buf); -int get_hd_geometry(disk_t *disk); -*****************************************************************************/ -#include /* dosmemget(), dosmemput() */ -#include /* memset() */ -#include /* printf() */ -#include /* _DISK_... */ -#include /* __dpmi_regs, __dpmi_int() */ -#include /* _go32_info_block, __tb */ -#include "diskio.h" -#include "dos.h" /* peekb() */ -/***************************************************************************** -*****************************************************************************/ -int lba_biosdisk(int cmd, int drive, unsigned long lba, int nsects, void *buf) -{ - struct - { - unsigned char pkt_len __attribute__((packed)); - unsigned char res0 __attribute__((packed)); - unsigned char nsects __attribute__((packed)); - unsigned char res1 __attribute__((packed)); - unsigned short buf_off __attribute__((packed)); - unsigned short buf_seg __attribute__((packed)); - unsigned long lba31_0 __attribute__((packed)); - unsigned long lba63_32 __attribute__((packed)); - } lba_cmd_pkt; - unsigned tries, err = 0; - __dpmi_regs regs; - - if(cmd != _DISK_READ && cmd != _DISK_WRITE) - return 0x100; -/* make sure the DJGPP transfer buffer (in conventional memory) -is big enough */ - if(BPS * nsects + sizeof(lba_cmd_pkt) > - _go32_info_block.size_of_transfer_buffer) - return 0x100; -/* make sure drive and BIOS support LBA */ - regs.x.bx = 0x55AA; - regs.h.dl = drive; - regs.h.ah = 0x41; - __dpmi_int(0x13, ®s); - if(regs.x.flags & 0x0001) /* carry bit (CY) is set */ - return 0x100; -/* fill out the INT 13h AH=4xh command packet */ - memset(&lba_cmd_pkt, 0, sizeof(lba_cmd_pkt)); - lba_cmd_pkt.pkt_len = sizeof(lba_cmd_pkt); - lba_cmd_pkt.nsects = nsects; -/* use start of transfer buffer for data transferred by BIOS disk I/O... */ - lba_cmd_pkt.buf_off = 0; - lba_cmd_pkt.buf_seg = __tb >> 4; - lba_cmd_pkt.lba31_0 = lba; -/* ...use end of transfer buffer for the command packet itself */ - dosmemput(&lba_cmd_pkt, sizeof(lba_cmd_pkt), - __tb + BPS * nsects); -/* fill out registers for INT 13h AH=4xh */ - regs.x.ds = (__tb + BPS * nsects) >> 4; - regs.x.si = (__tb + BPS * nsects) & 0x0F; - regs.h.dl = drive; -/* if writing, store the data */ - if(cmd == _DISK_WRITE) - dosmemput(buf, BPS * nsects, __tb); -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - regs.h.ah = (cmd == _DISK_READ) ? 0x42 : 0x43; - __dpmi_int(0x13, ®s); - err = regs.h.ah; - if((regs.x.flags & 0x0001) == 0) - { -/* if reading, load the data */ - if(cmd == _DISK_READ) - dosmemget(__tb, BPS * nsects, buf); - return 0; - } -/* reset disk */ - regs.h.ah = _DISK_RESET; - __dpmi_int(0x13, ®s); - } - DEBUG(printf("lba_biosdisk(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int get_hd_geometry(disk_t *disk) -{ - __dpmi_regs regs; - -/* make sure hard drive exists */ - if(disk->drive_num - 0x80 >= peekb(0x40, 0x75)) - { - printf("get_hd_geometry(): hd 0x%02X does not exist\n", - disk->drive_num); - return -1; - } -/* use LBA if drive and BIOS support it */ - regs.h.ah = 0x41; - regs.x.bx = 0x55AA; - regs.h.dl = disk->drive_num; - __dpmi_int(0x13, ®s); - if((regs.x.flags & 0x0001) == 0 && regs.x.bx == 0xAA55) - { - disk->use_lba = 1; - DEBUG(printf("get_hd_geometry(): using LBA for hd 0x%02X\n", - disk->drive_num);) - return 0; - } -/* get geometry from BIOS */ - regs.h.ah = 0x08; - regs.h.dl = disk->drive_num; - __dpmi_int(0x13, ®s); - if(regs.x.flags & 0x0001) - { - printf("get_hd_geometry(): error getting geometry " - "for hard drive 0x%02X\n", disk->drive_num); - return -1; - } - disk->heads = regs.h.dh + 1; - disk->sectors = regs.h.cl & 0x3F; - DEBUG(printf("get_hd_geometry() for hd 0x%02X: " - "CHS=?:%u:%u (from INT 13h AH=08h)\n", - disk->drive_num, - disk->heads, disk->sectors);) - return 0; -} diff --git a/Dump/hybos/__experimental/djgpp.mak b/Dump/hybos/__experimental/djgpp.mak deleted file mode 100644 index a8e153f..0000000 --- a/Dump/hybos/__experimental/djgpp.mak +++ /dev/null @@ -1,28 +0,0 @@ -# Makefile for 32-bit DOS - DJGPP - -# defines -# MAKEDEP =makefile -CC =gcc -g -O2 -Wall -W -LD =gcc -g -OBJS =demo.o dos.o djgpp.o - -# targets -all: diskio.exe - -clean: - deltree /y *.exe *.obj *.o *.err - -# implicit rules -.c.o: - $(CC) -c -o$@ $< - -# dependencies -demo.o: demo.c $(MAKEDEP) diskio.h - -dos.o: dos.c $(MAKEDEP) diskio.h dos.h - -djgpp.o: djgpp.c $(MAKEDEP) diskio.h dos.h - -# explicit rules -diskio.exe: $(OBJS) $(MAKEDEP) - $(LD) -o$@ $(OBJS) diff --git a/Dump/hybos/__experimental/dos.c b/Dump/hybos/__experimental/dos.c deleted file mode 100644 index 71f1446..0000000 --- a/Dump/hybos/__experimental/dos.c +++ /dev/null @@ -1,256 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for DOS. -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS: -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int write_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int is_fat_bootsector(unsigned char *buf); -int open_disk(disk_t *disk, unsigned drive_num); -*****************************************************************************/ -#include /* printf() */ -/*#include */ /* _DISK_..., diskinfo_t, _bios_disk() */ -#include "diskio.h" -#include "dos.h" /* peekw() */ - -/* IMPORTS -from _16BIT.C, DJGPP, or ??? */ -int lba_biosdisk(int cmd, int drive, unsigned long lba, int nsects, void *buf); -int get_hd_geometry(disk_t *disk); - -/* xxx - I'm not sure of the Turbo C version where these were -introduced. They are present in Turbo C++ 3.0 (__TURBOC__ == 0x401) -but not in Turbo C++ 1.0 (__TURBOC__ == 0x296) */ -#if defined(__TURBOC__) -#if __TURBOC__<0x300 - -struct diskinfo_t -{ - unsigned drive, head, track, sector, nsectors; - void far *buffer; -}; - -unsigned _bios_disk(unsigned cmd, struct diskinfo_t *info) -{ - struct SREGS sregs; - union REGS regs; - -/* biosdisk() returns the 8-bit error code left in register AH by -the call to INT 13h. It does NOT return a combined, 16-bit error -code + number of sectors transferred, as described in the online help. - - return biosdisk(cmd, info->drive, info->head, info->track, - info->sector, info->nsectors, info->buffer); -*/ - regs.h.ah = cmd; - regs.h.al = info->nsectors; - regs.x.bx = FP_OFF(info->buffer); - regs.h.ch = info->track; - regs.h.cl = (info->track / 256) * 64 + (info->sector & 0x3F); - regs.h.dh = info->head; - regs.h.dl = info->drive; - sregs.es = FP_SEG(info->buffer); - int86x(0x13, ®s, ®s, &sregs); - return regs.x.ax; -} -#endif -#endif -/***************************************************************************** -*****************************************************************************/ -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf) -{ - struct diskinfo_t cmd; - unsigned tries, err; - - lba += disk->partition_start; - cmd.drive = disk->drive_num; -/* use LBA if available */ - if(disk->use_lba) - { - return lba_biosdisk(_DISK_READ, - disk->drive_num, lba, 1, buf); - } -/* use CHS _bios_disk() */ - cmd.sector = (unsigned)(lba % disk->sectors + 1); - cmd.head = (unsigned)((lba / disk->sectors) % disk->heads); - cmd.track = (unsigned)((lba / disk->sectors) / disk->heads); - cmd.nsectors = 1; - cmd.buffer = buf; -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - err = _bios_disk(_DISK_READ, &cmd); - err >>= 8; -/* 0x11=="CRC/ECC corrected data error" */ - if(err == 0 || err == 0x11) - return 0; -/* reset disk */ - _bios_disk(_DISK_RESET, &cmd); - } - DEBUG(printf("read_sector(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int write_sector(disk_t *disk, unsigned long lba, unsigned char *buf) -{ - struct diskinfo_t cmd; - unsigned tries, err; - - lba += disk->partition_start; - cmd.drive = disk->drive_num; -/* use LBA if available */ - if(disk->use_lba) - { - return lba_biosdisk(_DISK_WRITE, - disk->drive_num, lba, 1, buf); - } -/* use CHS _bios_disk() */ - cmd.sector = (unsigned)(lba % disk->sectors + 1); - cmd.head = (unsigned)((lba / disk->sectors) % disk->heads); - cmd.track = (unsigned)((lba / disk->sectors) / disk->heads); - cmd.nsectors = 1; - cmd.buffer = buf; -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - err = _bios_disk(_DISK_WRITE, &cmd); - err >>= 8; -/* 0x11=="CRC/ECC corrected data error" */ - if(err == 0 || err == 0x11) - return 0; -/* reset disk */ - _bios_disk(_DISK_RESET, &cmd); - } - DEBUG(printf("write_sector(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int is_fat_bootsector(unsigned char *buf) -{ - int temp, ok = 1; - - DEBUG(printf("check_if_fat_bootsector:\n");) -/* must start with 16-bit JMP or 8-bit JMP plus NOP */ - if(buf[0] == 0xE9) - /* OK */; - else if(buf[0] == 0xEB && buf[2] == 0x90) - /* OK */; - else - { - DEBUG(printf("\tMissing JMP/NOP\n");) - ok = 0; - } - temp = buf[13]; - if(temp == 0 || ((temp - 1) & temp) != 0) - { - DEBUG(printf("\tSectors per cluster (%u) " - "is not a power of 2\n", temp);) - ok = 0; - } - temp = buf[16]; - temp = LE16(buf + 24); - if(temp == 0 || temp > 63) - { - DEBUG(printf("\tInvalid number of sectors (%u)\n", temp);) - ok = 0; - } - temp = LE16(buf + 26); - if(temp == 0 || temp > 255) - { - DEBUG(printf("\tInvalid number of heads (%u)\n", temp);) - ok = 0; - } - return ok; -} -/***************************************************************************** -*****************************************************************************/ -static void probe_floppy_geometry(disk_t *disk) -{ - unsigned sectors, heads; - unsigned char buf[BPS]; - -/* scan upwards for sector number where read fails */ - disk->sectors = 64 + 1; - for(sectors = 1; sectors <= 64; sectors++) - { - if(read_sector(disk, sectors - 1, buf) != 0) - break; - } - disk->sectors = sectors - 1; -#if 1 -disk->heads = 2; -#else -/* scan upwards for head number where read fails -xxx - this probing for number of heads doesn't work */ - disk->heads = 16 + 1; - for(heads = 1; heads < 16; heads++) - { - if(read_sector(disk, heads * disk->sectors, buf) != 0) - break; - } - disk->heads = heads; -#endif -/* reset drive by reading sector 0 */ - (void)read_sector(disk, 0, buf); - DEBUG(printf("probe_floppy_geometry() for fd 0x%02X: " - "CHS=?:%u:%u\n", disk->drive_num, - disk->heads, disk->sectors);) -} -/***************************************************************************** -*****************************************************************************/ -int open_disk(disk_t *disk, unsigned drive_num) -{ - unsigned char buf[BPS]; - unsigned num_fds; - int err; - - disk->drive_num = drive_num; - disk->partition_start = 0; /* assume floppy */ - disk->use_lba = 0; /* assume CHS */ -/* hard disk */ - if(disk->drive_num >= 0x80) - return get_hd_geometry(disk); -/* make sure floppy drive exists */ - num_fds = peekw(0x40, 0x10); - if(num_fds & 0x0001) - num_fds = ((num_fds / 64) & 3) + 1; - else - num_fds = 0; - if(disk->drive_num >= num_fds) - { - printf("open_disk(): fd 0x%02X does not exist\n", - disk->drive_num); - return -1; - } -/* temporary values to make read_sector(0) work */ - disk->heads = disk->sectors = 1; - err = read_sector(disk, 0, buf); - if(err != 0) - return err; -/* if it's a FAT (DOS) disk, we get can reliable geometry info -from the BIOS parameter block (BPB) in the bootsector */ - if(is_fat_bootsector(buf)) - { - disk->heads = LE16(buf + 26); - disk->sectors = LE16(buf + 24); - DEBUG(printf("open_disk() for fd 0x%02X: " - "CHS=?:%u:%u (from BPB)\n", - disk->drive_num, - disk->heads, disk->sectors);) - return 0; - } -#if 0 -/* ...otherwise, do slow probe */ - probe_floppy_geometry(disk); -#else -/* ...or just assume some values */ - disk->heads = 2; - disk->sectors = 18; - DEBUG(printf("open_disk() for fd 0x%02X: " - "assuming CHS=?:2:18\n", disk->drive_num);) -#endif - return 0; -} diff --git a/Dump/hybos/__experimental/dos.c~ b/Dump/hybos/__experimental/dos.c~ deleted file mode 100644 index 8b0703a..0000000 --- a/Dump/hybos/__experimental/dos.c~ +++ /dev/null @@ -1,256 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for DOS. -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS: -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int write_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int is_fat_bootsector(unsigned char *buf); -int open_disk(disk_t *disk, unsigned drive_num); -*****************************************************************************/ -#include /* printf() */ -#include /* _DISK_..., diskinfo_t, _bios_disk() */ -#include "diskio.h" -#include "dos.h" /* peekw() */ - -/* IMPORTS -from _16BIT.C, DJGPP, or ??? */ -int lba_biosdisk(int cmd, int drive, unsigned long lba, int nsects, void *buf); -int get_hd_geometry(disk_t *disk); - -/* xxx - I'm not sure of the Turbo C version where these were -introduced. They are present in Turbo C++ 3.0 (__TURBOC__ == 0x401) -but not in Turbo C++ 1.0 (__TURBOC__ == 0x296) */ -#if defined(__TURBOC__) -#if __TURBOC__<0x300 - -struct diskinfo_t -{ - unsigned drive, head, track, sector, nsectors; - void far *buffer; -}; - -unsigned _bios_disk(unsigned cmd, struct diskinfo_t *info) -{ - struct SREGS sregs; - union REGS regs; - -/* biosdisk() returns the 8-bit error code left in register AH by -the call to INT 13h. It does NOT return a combined, 16-bit error -code + number of sectors transferred, as described in the online help. - - return biosdisk(cmd, info->drive, info->head, info->track, - info->sector, info->nsectors, info->buffer); -*/ - regs.h.ah = cmd; - regs.h.al = info->nsectors; - regs.x.bx = FP_OFF(info->buffer); - regs.h.ch = info->track; - regs.h.cl = (info->track / 256) * 64 + (info->sector & 0x3F); - regs.h.dh = info->head; - regs.h.dl = info->drive; - sregs.es = FP_SEG(info->buffer); - int86x(0x13, ®s, ®s, &sregs); - return regs.x.ax; -} -#endif -#endif -/***************************************************************************** -*****************************************************************************/ -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf) -{ - struct diskinfo_t cmd; - unsigned tries, err; - - lba += disk->partition_start; - cmd.drive = disk->drive_num; -/* use LBA if available */ - if(disk->use_lba) - { - return lba_biosdisk(_DISK_READ, - disk->drive_num, lba, 1, buf); - } -/* use CHS _bios_disk() */ - cmd.sector = (unsigned)(lba % disk->sectors + 1); - cmd.head = (unsigned)((lba / disk->sectors) % disk->heads); - cmd.track = (unsigned)((lba / disk->sectors) / disk->heads); - cmd.nsectors = 1; - cmd.buffer = buf; -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - err = _bios_disk(_DISK_READ, &cmd); - err >>= 8; -/* 0x11=="CRC/ECC corrected data error" */ - if(err == 0 || err == 0x11) - return 0; -/* reset disk */ - _bios_disk(_DISK_RESET, &cmd); - } - DEBUG(printf("read_sector(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int write_sector(disk_t *disk, unsigned long lba, unsigned char *buf) -{ - struct diskinfo_t cmd; - unsigned tries, err; - - lba += disk->partition_start; - cmd.drive = disk->drive_num; -/* use LBA if available */ - if(disk->use_lba) - { - return lba_biosdisk(_DISK_WRITE, - disk->drive_num, lba, 1, buf); - } -/* use CHS _bios_disk() */ - cmd.sector = (unsigned)(lba % disk->sectors + 1); - cmd.head = (unsigned)((lba / disk->sectors) % disk->heads); - cmd.track = (unsigned)((lba / disk->sectors) / disk->heads); - cmd.nsectors = 1; - cmd.buffer = buf; -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - err = _bios_disk(_DISK_WRITE, &cmd); - err >>= 8; -/* 0x11=="CRC/ECC corrected data error" */ - if(err == 0 || err == 0x11) - return 0; -/* reset disk */ - _bios_disk(_DISK_RESET, &cmd); - } - DEBUG(printf("write_sector(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int is_fat_bootsector(unsigned char *buf) -{ - int temp, ok = 1; - - DEBUG(printf("check_if_fat_bootsector:\n");) -/* must start with 16-bit JMP or 8-bit JMP plus NOP */ - if(buf[0] == 0xE9) - /* OK */; - else if(buf[0] == 0xEB && buf[2] == 0x90) - /* OK */; - else - { - DEBUG(printf("\tMissing JMP/NOP\n");) - ok = 0; - } - temp = buf[13]; - if(temp == 0 || ((temp - 1) & temp) != 0) - { - DEBUG(printf("\tSectors per cluster (%u) " - "is not a power of 2\n", temp);) - ok = 0; - } - temp = buf[16]; - temp = LE16(buf + 24); - if(temp == 0 || temp > 63) - { - DEBUG(printf("\tInvalid number of sectors (%u)\n", temp);) - ok = 0; - } - temp = LE16(buf + 26); - if(temp == 0 || temp > 255) - { - DEBUG(printf("\tInvalid number of heads (%u)\n", temp);) - ok = 0; - } - return ok; -} -/***************************************************************************** -*****************************************************************************/ -static void probe_floppy_geometry(disk_t *disk) -{ - unsigned sectors, heads; - unsigned char buf[BPS]; - -/* scan upwards for sector number where read fails */ - disk->sectors = 64 + 1; - for(sectors = 1; sectors <= 64; sectors++) - { - if(read_sector(disk, sectors - 1, buf) != 0) - break; - } - disk->sectors = sectors - 1; -#if 1 -disk->heads = 2; -#else -/* scan upwards for head number where read fails -xxx - this probing for number of heads doesn't work */ - disk->heads = 16 + 1; - for(heads = 1; heads < 16; heads++) - { - if(read_sector(disk, heads * disk->sectors, buf) != 0) - break; - } - disk->heads = heads; -#endif -/* reset drive by reading sector 0 */ - (void)read_sector(disk, 0, buf); - DEBUG(printf("probe_floppy_geometry() for fd 0x%02X: " - "CHS=?:%u:%u\n", disk->drive_num, - disk->heads, disk->sectors);) -} -/***************************************************************************** -*****************************************************************************/ -int open_disk(disk_t *disk, unsigned drive_num) -{ - unsigned char buf[BPS]; - unsigned num_fds; - int err; - - disk->drive_num = drive_num; - disk->partition_start = 0; /* assume floppy */ - disk->use_lba = 0; /* assume CHS */ -/* hard disk */ - if(disk->drive_num >= 0x80) - return get_hd_geometry(disk); -/* make sure floppy drive exists */ - num_fds = peekw(0x40, 0x10); - if(num_fds & 0x0001) - num_fds = ((num_fds / 64) & 3) + 1; - else - num_fds = 0; - if(disk->drive_num >= num_fds) - { - printf("open_disk(): fd 0x%02X does not exist\n", - disk->drive_num); - return -1; - } -/* temporary values to make read_sector(0) work */ - disk->heads = disk->sectors = 1; - err = read_sector(disk, 0, buf); - if(err != 0) - return err; -/* if it's a FAT (DOS) disk, we get can reliable geometry info -from the BIOS parameter block (BPB) in the bootsector */ - if(is_fat_bootsector(buf)) - { - disk->heads = LE16(buf + 26); - disk->sectors = LE16(buf + 24); - DEBUG(printf("open_disk() for fd 0x%02X: " - "CHS=?:%u:%u (from BPB)\n", - disk->drive_num, - disk->heads, disk->sectors);) - return 0; - } -#if 0 -/* ...otherwise, do slow probe */ - probe_floppy_geometry(disk); -#else -/* ...or just assume some values */ - disk->heads = 2; - disk->sectors = 18; - DEBUG(printf("open_disk() for fd 0x%02X: " - "assuming CHS=?:2:18\n", disk->drive_num);) -#endif - return 0; -} diff --git a/Dump/hybos/__experimental/dos.h b/Dump/hybos/__experimental/dos.h deleted file mode 100644 index d604379..0000000 --- a/Dump/hybos/__experimental/dos.h +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for DOS. -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS: -peekb(), peekw() -*****************************************************************************/ -#ifndef __DISKIO_DOS_H -#define __DISKIO_DOS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/********************************* TURBO C **********************************/ -#if defined(__TURBOC__) -#include /* peekb(), peek() */ - -#define peekw(S,O) peek(S,O) - -/* xxx - I'm not sure of the Turbo C version where these were -introduced. They are present in Turbo C++ 3.0 (__TURBOC__ == 0x401) -but not in Turbo C++ 1.0 (__TURBOC__ == 0x296) */ -#if __TURBOC__<0x300 -#define _DISK_RESET 0 /* controller hard reset */ -#define _DISK_STATUS 1 /* status of last operation */ -#define _DISK_READ 2 /* read sectors */ -#define _DISK_WRITE 3 /* write sectors */ -#define _DISK_VERIFY 4 /* verify sectors */ -#define _DISK_FORMAT 5 /* format track */ -#endif - -/********************************* DJGPP ************************************/ -#elif defined(__DJGPP__) -#include /* _farpeek[b|w]() */ -#include /* _dos_ds */ - -#define peekb(S,O) _farpeekb(_dos_ds, 16uL * (S) + (O)) -#define peekw(S,O) _farpeekw(_dos_ds, 16uL * (S) + (O)) - -/******************************** WATCOM C **********************************/ -#elif defined(__WATCOMC__) - -#if defined(__386__) -/* CauseWay DOS extender only */ -#define peekb(S,O) *(unsigned char *)(16uL * (S) + (O)) -#define peekw(S,O) *(unsigned short *)(16uL * (S) + (O)) -#else -#include /* MK_FP() */ -#define peekb(S,O) *(unsigned char far *)MK_FP(S,O) -#define peekw(S,O) *(unsigned short far *)MK_FP(S,O) -#endif - -/****************************************************************************/ -#else -#error Not Turbo C, not DJGPP, not Watcom C. Sorry. -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/__experimental/dos16.c b/Dump/hybos/__experimental/dos16.c deleted file mode 100644 index d849321..0000000 --- a/Dump/hybos/__experimental/dos16.c +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for DOS, using 16-bit compiler. -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS: -int lba_biosdisk(int cmd, int drive, unsigned long lba, - int nsects, void *buf); -int get_hd_geometry(disk_t *disk); -*****************************************************************************/ -#include /* memset() */ -#include /* printf() */ -#include /* _DISK_... */ -/* union REGS, struct SREGS, int86(), int86x() */ -#include /* FP_SEG(), FP_OFF() */ -#include "diskio.h" -#include "dos.h" /* peekb() */ -/***************************************************************************** -*****************************************************************************/ -int lba_biosdisk(int cmd, int drive, unsigned long lba, int nsects, void *buf) -{ - struct - { - unsigned char pkt_len; - unsigned char res0; - unsigned char nsects; - unsigned char res1; - unsigned short buf_off; - unsigned short buf_seg; - unsigned long lba31_0; - unsigned long lba63_32; - } lba_cmd_pkt; - unsigned tries, err = 0; - struct SREGS sregs; - union REGS regs; - - if(cmd != _DISK_READ && cmd != _DISK_WRITE) - return 0x100; -/* make sure drive and BIOS support LBA */ - regs.x.bx = 0x55AA; - regs.h.dl = drive; - regs.h.ah = 0x41; - int86x(0x13, ®s, ®s, &sregs); - if(regs.x.cflag) - return 0x100; -/* fill out the INT 13h AH=4xh command packet */ - memset(&lba_cmd_pkt, 0, sizeof(lba_cmd_pkt)); - lba_cmd_pkt.pkt_len = sizeof(lba_cmd_pkt); - lba_cmd_pkt.nsects = nsects; - lba_cmd_pkt.buf_off = FP_OFF(buf); - lba_cmd_pkt.buf_seg = FP_SEG(buf); - lba_cmd_pkt.lba31_0 = lba; -/* fill out registers for INT 13h AH=4xh */ - sregs.ds = FP_SEG(&lba_cmd_pkt); - regs.x.si = FP_OFF(&lba_cmd_pkt); - regs.h.dl = drive; -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - regs.h.ah = (cmd == _DISK_READ) ? 0x42 : 0x43; - int86x(0x13, ®s, ®s, &sregs); - err = regs.h.ah; - if(!regs.x.cflag) - return 0; -/* reset disk */ - regs.h.ah = _DISK_RESET; - int86x(0x13, ®s, ®s, &sregs); - } - DEBUG(printf("lba_biosdisk(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int get_hd_geometry(disk_t *disk) -{ - union REGS regs; - -/* make sure hard drive exists */ - if(disk->drive_num - 0x80 >= peekb(0x40, 0x75)) - { - printf("get_hd_geometry(): hd 0x%02X does not exist\n", - disk->drive_num); - return -1; - } -/* use LBA if drive and BIOS support it */ - regs.h.ah = 0x41; - regs.x.bx = 0x55AA; - regs.h.dl = disk->drive_num; - int86(0x13, ®s, ®s); - if(!regs.x.cflag && regs.x.bx == 0xAA55) - { - disk->use_lba = 1; - DEBUG(printf("get_hd_geometry(): using LBA for hd 0x%02X\n", - disk->drive_num);) - return 0; - } -/* get geometry from BIOS */ - regs.h.ah = 0x08; - regs.h.dl = disk->drive_num; - int86(0x13, ®s, ®s); - if(regs.x.cflag) - { - printf("get_hd_geometry(): error getting geometry " - "for hard drive 0x%02X\n", disk->drive_num); - return -1; - } - disk->heads = regs.h.dh + 1; - disk->sectors = regs.h.cl & 0x3F; - DEBUG(printf("get_hd_geometry() for hd 0x%02X: " - "CHS=?:%u:%u (from INT 13h AH=08h)\n", - disk->drive_num, - disk->heads, disk->sectors);) - return 0; -} diff --git a/Dump/hybos/__experimental/makefile b/Dump/hybos/__experimental/makefile deleted file mode 100644 index 97c6819..0000000 --- a/Dump/hybos/__experimental/makefile +++ /dev/null @@ -1,32 +0,0 @@ -# Makefile for Turbo C++ 1.0 -# For old Turbo MAKE 3.0, this file MUST be named 'makefile' - -# defines -# MAKEDEP =makefile -MODEL =s -CC =tcc -v -m$(MODEL) -w -O2 -d -Z -vi -1 -LIBDIR =c:\tc\lib -LD =tlink /v /x -OBJS =demo.obj dos.obj dos16.obj - -# targets -all: diskio.exe - -clean: - deltree /y *.exe *.obj *.o *.err - -# implicit rules -.c.obj: - $(CC) -c -o$*.obj $< - -# dependencies -demo.o: demo.c $(MAKEDEP) diskio.h - -dos.o: dos.c $(MAKEDEP) diskio.h dos.h - -dos16.o: dos16.c $(MAKEDEP) diskio.h dos.h - -# explicit rules -diskio.exe: $(OBJS) $(MAKEDEP) - $(LD) $(LIBDIR)\c0$(MODEL).obj $(OBJS),$.,,$(LIBDIR)\c$(MODEL).lib - diff --git a/Dump/hybos/__experimental/watcom16.mak b/Dump/hybos/__experimental/watcom16.mak deleted file mode 100644 index 0c61cc3..0000000 --- a/Dump/hybos/__experimental/watcom16.mak +++ /dev/null @@ -1,28 +0,0 @@ -# Makefile for DOS - Watcom C - -# defines -# MAKEDEP =watcom16.mak -CC =wcc -3 -s -d2 -hw -ox -w=9 -zc -ms -OBJS =demo.obj dos.obj dos16.obj - -# targets -all: diskio.exe - -clean: - deltree /y *.exe *.obj *.o *.err - -# implicit rules -.c.obj: - $(CC) -fo=$@ $[. - -# dependencies -demo.o: demo.c $(MAKEDEP) diskio.h - -dos.o: dos.c $(MAKEDEP) diskio.h dos.h - -dos16.o: dos16.c $(MAKEDEP) diskio.h dos.h - -# explicit rules -diskio.exe: $(OBJS) $(MAKEDEP) - wlink D W A SYSTEM dos NAME $@ FILE demo.obj FILE dos.obj FILE dos16.obj - diff --git a/Dump/hybos/__experimental/watcom32.c b/Dump/hybos/__experimental/watcom32.c deleted file mode 100644 index 978b34e..0000000 --- a/Dump/hybos/__experimental/watcom32.c +++ /dev/null @@ -1,117 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for DOS, using 32-bit Watcom C -with CauseWay DOS extender. -This code is public domain (no copyright). -You can do whatever you want with it. - -xxx - This code doesn't work - -EXPORTS: -int lba_biosdisk(int cmd, int drive, unsigned long lba, - int nsects, void *buf); -int get_hd_geometry(disk_t *disk); -*****************************************************************************/ -#include /* memset() */ -#include /* printf() */ -#include /* _DISK_... */ -/* union REGS, struct SREGS, int386(), int386x() */ -#include /* FP_SEG(), FP_OFF() */ -#include "diskio.h" -#include "dos.h" /* peekb() */ -/***************************************************************************** -*****************************************************************************/ -int lba_biosdisk(int cmd, int drive, unsigned long lba, int nsects, void *buf) -{ - struct - { - unsigned char pkt_len; - unsigned char res0; - unsigned char nsects; - unsigned char res1; - unsigned short buf_off; - unsigned short buf_seg; - unsigned long lba31_0; - unsigned long lba63_32; - } lba_cmd_pkt; - unsigned tries, err = 0; - struct SREGS sregs; - union REGS regs; - - if(cmd != _DISK_READ && cmd != _DISK_WRITE) - return 0x100; -/* make sure drive and BIOS support LBA */ - regs.w.bx = 0x55AA; - regs.h.dl = drive; - regs.h.ah = 0x41; - int386x(0x13, ®s, ®s, &sregs); - if(regs.w.cflag) - return 0x100; -/* fill out the INT 13h AH=4xh command packet */ - memset(&lba_cmd_pkt, 0, sizeof(lba_cmd_pkt)); - lba_cmd_pkt.pkt_len = sizeof(lba_cmd_pkt); - lba_cmd_pkt.nsects = nsects; - lba_cmd_pkt.buf_off = FP_OFF(buf); - lba_cmd_pkt.buf_seg = FP_SEG(buf); - lba_cmd_pkt.lba31_0 = lba; -/* fill out registers for INT 13h AH=4xh */ - sregs.ds = FP_SEG(&lba_cmd_pkt); - regs.w.si = FP_OFF(&lba_cmd_pkt); - regs.h.dl = drive; -/* make 3 attempts */ - for(tries = 3; tries != 0; tries--) - { - regs.h.ah = (cmd == _DISK_READ) ? 0x42 : 0x43; - int386x(0x13, ®s, ®s, &sregs); - err = regs.h.ah; - if(!regs.w.cflag) - return 0; -/* reset disk */ - regs.h.ah = _DISK_RESET; - int386x(0x13, ®s, ®s, &sregs); - } - DEBUG(printf("lba_biosdisk(): error 0x%02X\n", err);) - return err; -} -/***************************************************************************** -*****************************************************************************/ -int get_hd_geometry(disk_t *disk) -{ - union REGS regs; - -/* make sure hard drive exists */ - if(disk->drive_num - 0x80 >= peekb(0x40, 0x75)) - { - printf("get_hd_geometry(): hd 0x%02X does not exist\n", - disk->drive_num); - return -1; - } -/* use LBA if drive and BIOS support it */ - regs.h.ah = 0x41; - regs.w.bx = 0x55AA; - regs.h.dl = disk->drive_num; - int386(0x13, ®s, ®s); - if(!regs.w.cflag && regs.w.bx == 0xAA55) - { - disk->use_lba = 1; - DEBUG(printf("get_hd_geometry(): using LBA for hd 0x%02X\n", - disk->drive_num);) - return 0; - } -/* get geometry from BIOS */ - regs.h.ah = 0x08; - regs.h.dl = disk->drive_num; - int386(0x13, ®s, ®s); - if(!regs.w.cflag) - { - printf("get_hd_geometry(): error getting geometry " - "for hard drive 0x%02X\n", disk->drive_num); - return -1; - } - disk->heads = regs.h.dh + 1; - disk->sectors = regs.h.cl & 0x3F; - DEBUG(printf("get_hd_geometry() for hd 0x%02X: " - "CHS=?:%u:%u (from INT 13h AH=08h)\n", - disk->drive_num, - disk->heads, disk->sectors);) - return 0; -} diff --git a/Dump/hybos/__experimental/watcom32.mak b/Dump/hybos/__experimental/watcom32.mak deleted file mode 100644 index f5164c6..0000000 --- a/Dump/hybos/__experimental/watcom32.mak +++ /dev/null @@ -1,30 +0,0 @@ -# Makefile for 32-bit DOS - Watcom C -# (using CauseWay DOS extender) -# xxx - the resulting DISKIO.EXE doesn't work (!) - -# defines -# MAKEDEP =watcom32.mak -CC =wcc386 -3 -s -d2 -hw -ox -w=9 -zc -mf -OBJS =demo.obj dos.obj watcom32.obj - -# targets -all: diskio.exe - -clean: - deltree /y *.exe *.obj *.o *.err - -# implicit rules -.c.obj: - $(CC) -fo=$@ $[. - -# dependencies -demo.o: demo.c $(MAKEDEP) diskio.h - -dos.o: dos.c $(MAKEDEP) diskio.h dos.h - -watcom32.o: watcom32.c $(MAKEDEP) diskio.h dos.h - -# explicit rules -diskio.exe: $(OBJS) $(MAKEDEP) - wlink D W A SYSTEM causeway NAME $@ FILE demo.obj FILE dos.obj FILE watcom32.obj - diff --git a/Dump/hybos/__experimental/win-nt.c b/Dump/hybos/__experimental/win-nt.c deleted file mode 100644 index 6d97a0c..0000000 --- a/Dump/hybos/__experimental/win-nt.c +++ /dev/null @@ -1,125 +0,0 @@ -/***************************************************************************** -Sector-level disk I/O code for Windows NT. -This code is public domain (no copyright). -You can do whatever you want with it. - -EXPORTS: -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf); -int open_disk(disk_t *disk, unsigned drive_num); -int is_fat_bootsector(unsigned char *buf); - -Tim Robinson helped with this code. -(Bugs are due to Giese :) -*****************************************************************************/ -#include -/* FILE, fopen(), setvbuf(), fseek(), fread(), fclose(), printf(), sprintf() */ -#include -#include "diskio.h" -/***************************************************************************** -*****************************************************************************/ -static FILE *do_open(unsigned drive_num) -{ - char dev_name[64]; - FILE *f; - -/* form internal drive name */ - if(drive_num < 0x80) - sprintf(dev_name, "\\\\.\\%c:", drive_num + 'A'); - else - sprintf(dev_name, "\\\\.\\PhysicalDrive%u", - drive_num - 0x80); -/* open the drive */ - f = fopen(dev_name, "r+b"); - if(f == NULL) - printf("do_open(): drive 0x%02X (%s) does not exist\n", - drive_num, dev_name); - return f; -} -/***************************************************************************** -*****************************************************************************/ -int read_sector(disk_t *disk, unsigned long lba, unsigned char *buf) -{ - unsigned err; - FILE *f; - - lba += disk->partition_start; - f = do_open(disk->drive_num); - if(f == NULL) - return -1; -/* seek, read, close */ - setvbuf(f, NULL, _IOFBF, BPS); - fseek(f, lba * BPS, SEEK_SET); - err = fread(buf, 1, BPS, f); - fclose(f); - return (err == BPS) ? 0 : -1; -} -/***************************************************************************** -*****************************************************************************/ -int open_disk(disk_t *disk, unsigned drive_num) -{ - OSVERSIONINFO win_version; - unsigned char buf[BPS]; - unsigned err = 0; - FILE *f; - -/* check for NT */ - win_version.dwOSVersionInfoSize = sizeof(win_version); - GetVersionEx(&win_version); - if(win_version.dwPlatformId != VER_PLATFORM_WIN32_NT) - { - printf("Sorry, Windows NT required\n" - "Windows 9x users should use the " - "DOS version of this program\n\n"); - return -1; - } - disk->drive_num = drive_num; - disk->partition_start = 0; /* assume floppy */ - disk->use_lba = 0; /* assume CHS */ -/* open the drive, to make sure it exists */ - f = do_open(disk->drive_num); - if(f == NULL) - return -1; - fclose(f); -/* no CHS geometry - NT uses LBA for everything */ - return 0; -} -/***************************************************************************** -is_fat_bootsector() is not used in this file, but still used in DEMO.C -*****************************************************************************/ -int is_fat_bootsector(unsigned char *buf) -{ - int temp, ok = 1; - - DEBUG(printf("check_if_fat_bootsector:\n");) -/* must start with 16-bit JMP or 8-bit JMP plus NOP */ - if(buf[0] == 0xE9) - /* OK */; - else if(buf[0] == 0xEB && buf[2] == 0x90) - /* OK */; - else - { - DEBUG(printf("\tMissing JMP/NOP\n");) - ok = 0; - } - temp = buf[13]; - if(temp == 0 || ((temp - 1) & temp) != 0) - { - DEBUG(printf("\tSectors per cluster (%u) " - "is not a power of 2\n", temp);) - ok = 0; - } - temp = buf[16]; - temp = LE16(buf + 24); - if(temp == 0 || temp > 63) - { - DEBUG(printf("\tInvalid number of sectors (%u)\n", temp);) - ok = 0; - } - temp = LE16(buf + 26); - if(temp == 0 || temp > 255) - { - DEBUG(printf("\tInvalid number of heads (%u)\n", temp);) - ok = 0; - } - return ok; -} diff --git a/Dump/hybos/__experimental/win-nt.mak b/Dump/hybos/__experimental/win-nt.mak deleted file mode 100644 index c43eb97..0000000 --- a/Dump/hybos/__experimental/win-nt.mak +++ /dev/null @@ -1,26 +0,0 @@ -# Makefile for Windows NT - MinGW/CygWin - -# defines -# MAKEDEP =makefile -CC =gcc -g -O2 -Wall -W -LD =gcc -g -OBJS =demo.o win-nt.o - -# targets -all: diskio.exe - -clean: - deltree /y *.exe *.obj *.o *.err - -# implicit rules -.c.o: - $(CC) -c -o$@ $< - -# dependencies -demo.o: demo.c $(MAKEDEP) diskio.h - -win-nt.o: win-nt.c $(MAKEDEP) diskio.h - -# explicit rules -diskio.exe: $(OBJS) $(MAKEDEP) - $(LD) -o$@ $(OBJS) diff --git a/Dump/hybos/boot/grub/mbchk.c b/Dump/hybos/boot/grub/mbchk.c deleted file mode 100644 index fcb2485..0000000 --- a/Dump/hybos/boot/grub/mbchk.c +++ /dev/null @@ -1,166 +0,0 @@ -/***************************************************************************** -This was lifted from the GRUB source code. -GRUB is available under the GNU general public license from - http://www.gnu.org/software/grub - ftp://alpha.gnu.org/gnu/grub -*****************************************************************************/ -#include "mltiboot.h" -#include - -static int quiet; -/***************************************************************************** -*****************************************************************************/ -static int -check_multiboot (const char *filename, FILE *fp) -{ - multiboot_header_t *mbh = 0; - int i; - char buf[8192]; - - if (fread (buf, 1, 8192, fp) < 0) - { - fprintf (stderr, "%s: Read error.\n", filename); - return 0; - } - - for (i = 0; i < 8192 - sizeof (multiboot_header_t); i++) - { - unsigned long magic = *((unsigned long *) (buf + i)); - - if (magic == MULTIBOOT_HEADER_MAGIC) - { - mbh = (multiboot_header_t *) (buf + i); - break; - } - } - - if (! mbh) - { - fprintf (stderr, "%s: No Multiboot header.\n", filename); - return 0; - } - - if (! quiet) - printf ("%s: The Multiboot header is found at the offset %d.\n", - filename, i); - - /* Check for the checksum. */ - if (mbh->magic + mbh->flags + mbh->checksum != 0) - { - fprintf (stderr, - "%s: Bad checksum (0x%lx).\n", - filename, mbh->checksum); - return 0; - } - - /* Reserved flags must be zero. */ - if (mbh->flags & ~0x00010003) - { - fprintf (stderr, - "%s: Non-zero is found in reserved flags (0x%lx).\n", - filename, mbh->flags); - return 0; - } - - if (! quiet) - { - printf ("%s: Page alignment is turned %s.\n", - filename, (mbh->flags & 0x1)? "on" : "off"); - printf ("%s: Memory information is turned %s.\n", - filename, (mbh->flags & 0x2)? "on" : "off"); - printf ("%s: Address fields is turned %s.\n", - filename, (mbh->flags & 0x10000)? "on" : "off"); - } - - /* Check for the address fields. */ - if (mbh->flags & 0x10000) - { - -printf("header_addr = 0x%lX\n", mbh->header_addr); -printf("load_addr = 0x%lX\n", mbh->load_addr); -printf("load_end_addr = 0x%lX\n", mbh->load_end_addr); -printf("bss_end_addr = 0x%lX\n", mbh->bss_end_addr); -printf("entry_addr = 0x%lX\n", mbh->entry_addr); - - if (mbh->header_addr < mbh->load_addr) - { - fprintf (stderr, - "%s: header_addr is less than " - "load_addr (0x%lx > 0x%lx).\n", - filename, mbh->header_addr, mbh->load_addr); - return 0; - } - - if (mbh->load_addr >= mbh->load_end_addr) - { - fprintf (stderr, - "%s: load_addr is not less than load_end_addr" - " (0x%lx >= 0x%lx).\n", - filename, mbh->load_addr, mbh->load_end_addr); - return 0; - } - - if (mbh->load_end_addr > mbh->bss_end_addr) - { - fprintf (stderr, - "%s: load_end_addr is greater than bss_end_addr" - " (0x%lx > 0x%lx).\n", - filename, mbh->load_end_addr, mbh->bss_end_addr); - return 0; - } - - if (mbh->load_addr > mbh->entry_addr) - { - fprintf (stderr, - "%s: load_addr is greater than entry_addr" - " (0x%lx > 0x%lx).\n", - filename, mbh->load_addr, mbh->entry_addr); - return 0; - } - - if (mbh->load_end_addr <= mbh->entry_addr) - { - fprintf (stderr, - "%s: load_end_addr is not less than entry_addr" - " (0x%lx <= 0x%lx).\n", - filename, mbh->load_end_addr, mbh->entry_addr); - return 0; - } - - /* This is a GRUB-specific limitation. */ - if (mbh->load_addr < 0x100000) - { - fprintf (stderr, - "%s: Cannot be loaded at less than 1MB by GRUB" - " (0x%lx).\n", - filename, mbh->load_addr); - return 0; - } - } - - if (! quiet) - printf ("%s: All checks passed.\n", filename); - - return 1; -} -/***************************************************************************** -*****************************************************************************/ -int main(unsigned arg_c, char *arg_v[]) -{ - FILE *file; - - if(arg_c < 2) - { - printf("Checks if file is Multiboot compatible\n"); - return 1; - } - file = fopen(arg_v[1], "rb"); - if(file == NULL) - { - printf("Can't open file '%s'\n", arg_v[1]); - return 2; - } - check_multiboot(arg_v[1], file); - fclose(file); - return 0; -} diff --git a/Dump/hybos/boot/grub/menu.lst b/Dump/hybos/boot/grub/menu.lst deleted file mode 100644 index 3f86aa1..0000000 --- a/Dump/hybos/boot/grub/menu.lst +++ /dev/null @@ -1,39 +0,0 @@ -# boot the first entry by default -# default 0 -# if there's a problem booting the default entry, boot the second entry -# fallback 1 -# boot default after 30 sec -# timeout 30 - -title OSD 3 - root (fd0) - kernel /osd3.x - -title OSD 4 - root (fd0) - kernel /osd4.x - -title OSD 5 - root (fd0) - kernel /osd5.x - -title OSD 6 - root (fd0) - kernel /osd6.x - -title OSD 7 - root (fd0) - kernel /osd7.x - -title OSD 8 - root (fd0) - kernel /osd8.x - -title OSD 9 - root (fd0) - kernel /osd9.x - -title Boot from C: drive - root (hd0,1) - makeactive - chainloader +1 diff --git a/Dump/hybos/boot/grub/mltiboot.h b/Dump/hybos/boot/grub/mltiboot.h deleted file mode 100644 index 6c2efdb..0000000 --- a/Dump/hybos/boot/grub/mltiboot.h +++ /dev/null @@ -1,115 +0,0 @@ -/* multiboot.h - the header for Multiboot */ -/* Copyright (C) 1999 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Macros. */ - -/* The magic number for the Multiboot header. */ -#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 - -/* The flags for the Multiboot header. */ -#define MULTIBOOT_HEADER_FLAGS 0x00010003 - -/* The magic number passed by a Multiboot-compliant boot loader. */ -#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 - -/* The size of our stack (16KB). */ -#define STACK_SIZE 0x4000 - -/* C symbol format. HAVE_ASM_USCORE is defined by configure. */ -#ifdef HAVE_ASM_USCORE -# define EXT_C(sym) _ ## sym -#else -# define EXT_C(sym) sym -#endif - -#ifndef ASM -/* Do not include here in boot.S. */ - -/* Types. */ - -/* The Multiboot header. */ -typedef struct multiboot_header -{ - unsigned long magic; - unsigned long flags; - unsigned long checksum; - unsigned long header_addr; - unsigned long load_addr; - unsigned long load_end_addr; - unsigned long bss_end_addr; - unsigned long entry_addr; -} multiboot_header_t; - -/* The symbol table for a.out. */ -typedef struct aout_symbol_table -{ - unsigned long tabsize; - unsigned long strsize; - unsigned long addr; - unsigned long reserved; -} aout_symbol_table_t; - -/* The section header table for ELF. */ -typedef struct elf_section_header_table -{ - unsigned long num; - unsigned long size; - unsigned long addr; - unsigned long shndx; -} elf_section_header_table_t; - -/* The Multiboot information. */ -typedef struct multiboot_info -{ - unsigned long flags; - unsigned long mem_lower; - unsigned long mem_upper; - unsigned long boot_device; - unsigned long cmdline; - unsigned long mods_count; - unsigned long mods_addr; - union - { - aout_symbol_table_t aout_sym; - elf_section_header_table_t elf_sec; - } u; - unsigned long mmap_length; - unsigned long mmap_addr; -} multiboot_info_t; - -/* The module structure. */ -typedef struct module -{ - unsigned long mod_start; - unsigned long mod_end; - unsigned long string; - unsigned long reserved; -} module_t; - -/* The memory map. Be careful that the offset 0 is base_addr_low - but no size. */ -typedef struct memory_map -{ - unsigned long size; - unsigned long base_addr_low; - unsigned long base_addr_high; - unsigned long length_low; - unsigned long length_high; - unsigned long type; -} memory_map_t; - -#endif /* ! ASM */ diff --git a/Dump/hybos/boot/grub/stage1 b/Dump/hybos/boot/grub/stage1 deleted file mode 100644 index 1cd1292..0000000 --- a/Dump/hybos/boot/grub/stage1 +++ /dev/null Binary files differ diff --git a/Dump/hybos/boot/grub/stage2 b/Dump/hybos/boot/grub/stage2 deleted file mode 100644 index 25094fe..0000000 --- a/Dump/hybos/boot/grub/stage2 +++ /dev/null Binary files differ diff --git a/Dump/hybos/boot/kernel.bin b/Dump/hybos/boot/kernel.bin deleted file mode 100644 index 3ff90a0..0000000 --- a/Dump/hybos/boot/kernel.bin +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/._malloc.h.swp b/Dump/hybos/include/._malloc.h.swp deleted file mode 100644 index 3a93866..0000000 --- a/Dump/hybos/include/._malloc.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/.ctype.h.swp b/Dump/hybos/include/.ctype.h.swp deleted file mode 100644 index 3191f8d..0000000 --- a/Dump/hybos/include/.ctype.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/.fat.h.swp b/Dump/hybos/include/.fat.h.swp deleted file mode 100644 index ab6de14..0000000 --- a/Dump/hybos/include/.fat.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/.keyboard.h.swp b/Dump/hybos/include/.keyboard.h.swp deleted file mode 100644 index b1505f1..0000000 --- a/Dump/hybos/include/.keyboard.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/.stdarg.h.swp b/Dump/hybos/include/.stdarg.h.swp deleted file mode 100644 index 3c895d7..0000000 --- a/Dump/hybos/include/.stdarg.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/.x86.h.swp b/Dump/hybos/include/.x86.h.swp deleted file mode 100644 index 4a4a828..0000000 --- a/Dump/hybos/include/.x86.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/include/__nocompile_fcntl.h b/Dump/hybos/include/__nocompile_fcntl.h deleted file mode 100644 index 48de3c3..0000000 --- a/Dump/hybos/include/__nocompile_fcntl.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * fcntl.h - * - * access constants for _open. Note that this file is not complete - * and should not be used (yet) - */ - -#ifndef __STRICT_ANSI__ -#ifndef _FCNTL_H - -#define _FCNTL_H - -/** - * File access modes - */ -#define _O_RDONLY 0 /* read only */ -#define _O_WRONLY 1 /* write only */ -#define _O_RDWR 2 /* read and write */ - -/** - * Mask for access mode bits in the _open flags - */ -#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR) -#define _O_APPEND 0x0008 /* append output to end of file */ -#define _O_RANDOM 0x0010 -#define _O_SEQUENTIAL 0x0020 -#define _O_TEMPORARY 0x0040 /* make the file dissappear after closing */ -#define _O_NOINHERIT 0x0080 -#define _O_CREAT 0x0100 /* create file if it doesn't exist */ -#define _O_TRUNC 0x0200 /* truncate file to zero bytes if it exists */ -#define _O_EXCL 0x0400 /* open only if the file does not exist */ - -#define _O_SHORT_LIVED 0x1000 - -#define _O_TEXT 0x4000 /* crlf in file == lf in memory (\r\n == \n) */ -#define _O_BINARY 0x8000 /* input and output is not translated */ -#define _O_RAW _O_BINARY /* compatability */ - -/** - * XXX - * The following special mode(s) are only available to the - * kernel. Modules (even kernel-level modules) and other - * binaries will never be allowed to use these special modes. - * - * Modules which are compiled into the kernel may use these - * special modes (mainly at boot). - */ -#define _O_DEV 0x9000 /* XXX: special device links (files) */ -#define _O_SWAP 0x9100 /* swap */ - -#ifndef _NO_OLDNAMES - -/** - * POSIX/Non-ANSI names for increased portability - */ -#define O_RDONLY _O_RDONLY -#define O_WRONLY _O_WRONLY -#define O_RDWR _O_RDWR -#define O_ACCMODE _O_ACCMODE -#define O_APPEND _O_APPEND -#define O_CREAT _O_CREAT -#define O_TRUNC _O_TRUNC -#define O_EXCL _O_EXCL -#define O_TEXT _O_TEXT -#define O_BINARY _O_BINARY -#define O_TEMPORARY _O_TEMPORARY -#define O_NOINHERIT _O_NOINHERIT -#define O_SEQUENTIAL _O_SEQUENTIAL -#define O_RANDOM _O_RANDOM - -#define O_DEV _O_DEV -#define O_SWAP _O_SWAP - -#endif /* ! _NO_OLDNAMES */ - -#endif /* ! _FCNTL_H */ - -#endif /* ! __STRICT_ANSI__ */ - diff --git a/Dump/hybos/include/__nocompile_signal.h b/Dump/hybos/include/__nocompile_signal.h deleted file mode 100644 index 5aef646..0000000 --- a/Dump/hybos/include/__nocompile_signal.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * fcntl.h - * - * access constants for _open. Note that this file is not complete - * and should not be used (yet) - */ - -#ifndef _SIGNAL_H -#define _SIGNAL_H - -/** - * The actual signal values. Using other values with signal - * produces a SIG_ERR return value. - * - * NOTE: SIGINT is produced when the user presses Ctrl-C - * SIGILL has not been tested - * SIGFPE - * SIGSEGV - * SIGTERM comes from what kind of termination request exactly? - * SIGBREAK is produced by pressing Ctrl-Break - * SIGABRT is produced by calling abort - */ -#define SIGINT 2 /* Interactive attention */ -#define SIGILL 4 /* Illegal instruction */ -#define SIGFPE 8 /* Floating point error */ -#define SIGSEGV 11 /* Segmentation violation */ -#define SIGTERM 15 /* Termination request */ -#define SIGBREAK 21 /* Ctrl-Break */ -#define SIGABRT 22 /* Abnormal termination (abort) */ - -#define NSIG 23 /* maximum signal number + 1 */ - -#ifndef RC_INVOKED -#ifndef _SIG_ATOMIC_T_DEFINED -typedef int sig_atomic_t; -#define _SIG_ATOMIC_T_DEFINED -#endif /* ! _SIG_ATOMIC_T_DEFINED */ - -/** - * The prototypes (below) are the easy part. The hard part is figuring - * out what signals are available and what numbers they are assigned - * along with appropriate values of SIG_DFL and SIG_IGN. - */ - -/** - * A pointer to a signal handler function. A signal handler takes a - * single int, which is the signal it handles. - */ -typedef void (*__p_sig_fn_t)(int); - -/** - * These are special values of signal handler pointers which are - * used to send a signal to the default handler (SIG_DFL), ignore - * the signal (SIG_IGN), or indicate an error return (SIG_ERR). - */ -#define SIG_DFL ((__p_sig_fn_t) 0) -#define SIG_IGN ((__p_sig_fn_t) 1) -#define SIG_ERR ((__p_sig_fn_t) -1) - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Call signal to set the signal handler for signal sig to the - * function pointed to by handler. Returns a pointer to the - * previous handler, or SIG_ERR if an error occurs. Initially - * unhandled signals defined above will return SIG_DFL. - */ -_CRTIMP __p_sig_fn_t __cdecl signal(int, __p_sig_fn_t); - -/** - * Raise the signal indicated by sig. Returns non-zero on success. - */ -_CRTIMP int __cdecl raise (int); - -#ifdef __cplusplus -} -#endif - -#endif /* ! RC_INVOKED */ -#endif /* ! _SIGNAL_H */ - diff --git a/Dump/hybos/include/_malloc.h b/Dump/hybos/include/_malloc.h deleted file mode 100644 index b8c68da..0000000 --- a/Dump/hybos/include/_malloc.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __TL__MALLOC_H -#define __TL__MALLOC_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* 500K */ -#define HEAP_SIZE 500000uL - -#include <_size_t.h> -/*#include <_null.h>*/ - -#define MALLOC_MAGIC 0x6D92 /* must be < 0x8000 */ - -typedef struct _malloc /* Turbo C DJGPP */ -{ - size_t size; /* 2 bytes 4 bytes */ - struct _malloc *next; /* 2 bytes 4 bytes */ - unsigned magic : 15; /* 2 bytes total 4 bytes total */ - unsigned used : 1; -} malloc_t; /* total 6 bytes 12 bytes */ - -extern malloc_t *_heap_bot, *_heap_top; - -static void dump_heap(void); -static void *kbrk(int *delta); -void *kmalloc(size_t size); -void kfree(void *blk); -void *krealloc(void *blk, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/_null.h_ b/Dump/hybos/include/_null.h_ deleted file mode 100644 index 6207940..0000000 --- a/Dump/hybos/include/_null.h_ +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __TL__NULL_H -#define __TL__NULL_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef _NULL -#define _NULL -#define NULL 0 -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/_printf.h b/Dump/hybos/include/_printf.h deleted file mode 100644 index c967f10..0000000 --- a/Dump/hybos/include/_printf.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __TL__PRINTF_H -#define __TL__PRINTF_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <_va_list.h> - -typedef int (*fnptr_t)(unsigned c, void **helper); - -int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/_size_t.h b/Dump/hybos/include/_size_t.h deleted file mode 100644 index bebd416..0000000 --- a/Dump/hybos/include/_size_t.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __TL__SIZE_T_H -#define __TL__SIZE_T_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned size_t; -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/_va_list.h b/Dump/hybos/include/_va_list.h deleted file mode 100644 index fe5b164..0000000 --- a/Dump/hybos/include/_va_list.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __TL__VA_LIST_H -#define __TL__VA_LIST_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef unsigned char *va_list; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/asm.inc b/Dump/hybos/include/asm.inc deleted file mode 100644 index 3ba45fc..0000000 --- a/Dump/hybos/include/asm.inc +++ /dev/null @@ -1,30 +0,0 @@ -%ifndef __TL_ASM_INC -%define __TL_ASM_INC 1 - -; macros to handle leading underscores added by DOS/Windows compilers -%macro IMP 1 -%ifdef UNDERBARS - EXTERN _%1 - %define %1 _%1 -%else - EXTERN %1 -%endif -%endmacro - -%macro EXP 1 - GLOBAL $_%1 - $_%1: - GLOBAL $%1 - $%1: -%endmacro - -DS_MAGIC equ 3544DA2Ah - -MULTIBOOT_PAGE_ALIGN equ 1<<0 -MULTIBOOT_MEMORY_INFO equ 1<<1 -MULTIBOOT_AOUT_KLUDGE equ 1<<16 -MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 -MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE -MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) - -%endif diff --git a/Dump/hybos/include/char.h b/Dump/hybos/include/char.h deleted file mode 100644 index 9ae9311..0000000 --- a/Dump/hybos/include/char.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _CHAR_H -#define _CHAR_H - -#include - -long atoi(const char *nptr); -bool isalnum(const char c); -bool isalpha(const char c); -bool isascii(const unsigned char c); -bool iscsym(const char c); -bool iscsymf(const char c); -bool isctrl(const char c); -bool isdigit(const char c); -bool isgraph(const unsigned char c); -bool islowwer(const char c); -bool isprint(const char c); -bool ispunct(const char c); -bool isspace(const char c); -bool isupper(const char c); -bool isxdigit(const char c); -int tolower(int c); -int toupper(int c); - -#endif /* !defined(_CHAR_H) */ diff --git a/Dump/hybos/include/conio.h b/Dump/hybos/include/conio.h deleted file mode 100644 index abc6575..0000000 --- a/Dump/hybos/include/conio.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __TL_CONIO_H -#define __TL_CONIO_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* "bucky bits" -0x0100 is reserved for non-ASCII keys, so start with 0x200 */ -#define KBD_META_ALT 0x0200 /* Alt is pressed */ -#define KBD_META_CTRL 0x0400 /* Ctrl is pressed */ -#define KBD_META_SHIFT 0x0800 /* Shift is pressed */ -#define KBD_META_ANY (KBD_META_ALT | KBD_META_CTRL | KBD_META_SHIFT) -#define KBD_META_CAPS 0x1000 /* CapsLock is on */ -#define KBD_META_NUM 0x2000 /* NumLock is on */ -#define KBD_META_SCRL 0x4000 /* ScrollLock is on */ - -/* "ASCII" values for non-ASCII keys. All of these are user-defined. - -Hrrm. Unicode defines code pages for pseudographics (e.g. box-drawing -characters). I wonder it defines anything for keys like these? - -function keys: */ -#define KEY_F1 0x80 -#define KEY_F2 (KEY_F1 + 1) -#define KEY_F3 (KEY_F2 + 1) -#define KEY_F4 (KEY_F3 + 1) -#define KEY_F5 (KEY_F4 + 1) -#define KEY_F6 (KEY_F5 + 1) -#define KEY_F7 (KEY_F6 + 1) -#define KEY_F8 (KEY_F7 + 1) -#define KEY_F9 (KEY_F8 + 1) -#define KEY_F10 (KEY_F9 + 1) -#define KEY_F11 (KEY_F10 + 1) -#define KEY_F12 (KEY_F11 + 1) -/* cursor keys */ -#define KEY_INS 0x90 -#define KEY_DEL (KEY_INS + 1) -#define KEY_HOME (KEY_DEL + 1) -#define KEY_END (KEY_HOME + 1) -#define KEY_PGUP (KEY_END + 1) -#define KEY_PGDN (KEY_PGUP + 1) -#define KEY_LFT (KEY_PGDN + 1) -#define KEY_UP (KEY_LFT + 1) -#define KEY_DN (KEY_UP + 1) -#define KEY_RT (KEY_DN + 1) -/* print screen/sys rq and pause/break */ -#define KEY_PRNT (KEY_RT + 1) -#define KEY_PAUSE (KEY_PRNT + 1) -/* these return a value but they could also act as additional bucky keys */ -#define KEY_LWIN (KEY_PAUSE + 1) -#define KEY_RWIN (KEY_LWIN + 1) -#define KEY_MENU (KEY_RWIN + 1) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/ctype.h b/Dump/hybos/include/ctype.h deleted file mode 100644 index ac9d411..0000000 --- a/Dump/hybos/include/ctype.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __TL_CTYPE_H -#define __TL_CTYPE_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern char _ctype[]; - -typedef enum {false = 0, true = !0} bool; - -#define CT_UP 0x01 /* upper case */ -#define CT_LOW 0x02 /* lower case */ -#define CT_DIG 0x04 /* digit */ -#define CT_CTL 0x08 /* control */ -#define CT_PUN 0x10 /* punctuation */ -#define CT_WHT 0x20 /* white space (space/cr/lf/tab) */ -#define CT_HEX 0x40 /* hex digit */ -#define CT_SP 0x80 /* hard space (0x20) */ - -/* without the cast to unsigned, DJGPP complains (using -Wall) */ -#define isalnum(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG)) -#define isalpha(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW)) -#define iscntrl(c) ((_ctype + 1)[(unsigned)(c)] & (CT_CTL)) -#define isdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG)) -#define isgraph(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG)) -#define islower(c) ((_ctype + 1)[(unsigned)(c)] & (CT_LOW)) -#define isprint(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP)) -#define ispunct(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN)) -#define isspace(c) ((_ctype + 1)[(unsigned)(c)] & (CT_WHT)) -#define isupper(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP)) -#define isxdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX)) -#define isascii(c) ((unsigned)(c) <= 0x7F) -#define toascii(c) ((unsigned)(c) & 0x7F) - -#define tolower(c) (isupper(c) ? c + 'a' - 'A' : c) -#define toupper(c) (islower(c) ? c + 'A' - 'a' : c) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/e2fs.h b/Dump/hybos/include/e2fs.h deleted file mode 100644 index edf72f3..0000000 --- a/Dump/hybos/include/e2fs.h +++ /dev/null @@ -1,290 +0,0 @@ -/* e2fs.h */ -#ifndef E2FS_H -#define E2FS_H - -/* - * This code is a complete rewrite of the read-only part of E2FS - * library, done to reduce code size and memory requirements, and - * also increase speed in my particular conditions. - * - * So I need to include this for the common structure description: - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/include/linux/minix_fs.h - * - * Copyright (C) 1991, 1992 Linus Torvalds - * - * And I also have to point to the complete e2fsprogs suite - * at: http://sourceforge.net/projects/e2fsprogs/ - * or: http://e2fsprogs.sourceforge.net - * by Theodore Ts'o (http://thunk.org/tytso/) (tytso@mit.edu). - * - * This rewrite is based on the structure found in e2fsprogs-1.26. - * - * Note that some parts of e2fsprogs may be available under LGPL, - * my added work is only available under the GPL - not LGPL. - */ - -/* Gujin is a bootloader, it loads a Linux kernel from cold boot or DOS. - * Copyright (C) 1999-2003 Etienne Lorrain, fingerprint (2D3AF3EA): - * 2471 DF64 9DEE 41D4 C8DB 9667 E448 FF8C 2D3A F3EA - * E-Mail: etienne.lorrain@masroudeau.com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -typedef unsigned char __u8; -typedef short __s16; -typedef unsigned short __u16; -typedef int __s32; -typedef unsigned int __u32; - -/* - * Where the master copy of the superblock is located, and how big - * superblocks are supposed to be. We define SUPERBLOCK_SIZE because - * the size of the superblock structure is not necessarily trustworthy - * (some versions have the padding set up so that the superblock is - * 1032 bytes long). - */ -#define SUPERBLOCK_OFFSET 1024 -#define SUPERBLOCK_SIZE 1024 -#define EXT2_MIN_BLOCK_SIZE 1024 -#define EXT2_MAX_BLOCK_SIZE 4096 - -/* - * Special inodes numbers - */ -#define EXT2_BAD_INO 1 /* Bad blocks inode */ -#define EXT2_ROOT_INO 2 /* Root inode */ -#define EXT2_ACL_IDX_INO 3 /* ACL inode */ -#define EXT2_ACL_DATA_INO 4 /* ACL inode */ -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ -#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ -#define EXT2_JOURNAL_INO 8 /* Journal inode */ - -/* - * First non-reserved inode for old ext2 filesystems - */ -#define EXT2_GOOD_OLD_FIRST_INO 11 - -/* - * The second extended file system magic number - */ -#define EXT2_SUPER_MAGIC 0xEF53 - -/* - * Revision levels - */ -#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ -#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ - -#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV -#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV - -#define EXT2_GOOD_OLD_INODE_SIZE 128 - -#define EXT2_NAME_LEN 255 - -/* - * Structure of the super block - */ -typedef struct { - __u32 s_inodes_count; /* Inodes count */ - __u32 s_blocks_count; /* Blocks count */ - __u32 s_r_blocks_count; /* Reserved blocks count */ - __u32 s_free_blocks_count; /* Free blocks count */ - __u32 s_free_inodes_count; /* Free inodes count */ - __u32 s_first_data_block; /* First Data Block */ - __u32 s_log_block_size; /* Block size */ - __s32 s_log_frag_size; /* Fragment size */ - __u32 s_blocks_per_group; /* # Blocks per group */ - __u32 s_frags_per_group; /* # Fragments per group */ - __u32 s_inodes_per_group; /* # Inodes per group */ - __u32 s_mtime; /* Mount time */ - __u32 s_wtime; /* Write time */ - __u16 s_mnt_count; /* Mount count */ - __s16 s_max_mnt_count; /* Maximal mount count */ - __u16 s_magic; /* Magic signature */ - __u16 s_state; /* File system state */ - __u16 s_errors; /* Behaviour when detecting errors */ - __u16 s_minor_rev_level; /* minor revision level */ - __u32 s_lastcheck; /* time of last check */ - __u32 s_checkinterval; /* max. time between checks */ - __u32 s_creator_os; /* OS */ - __u32 s_rev_level; /* Revision level */ - __u16 s_def_resuid; /* Default uid for reserved blocks */ - __u16 s_def_resgid; /* Default gid for reserved blocks */ - /* - * These fields are for EXT2_DYNAMIC_REV superblocks only. - * - * Note: the difference between the compatible feature set and - * the incompatible feature set is that if there is a bit set - * in the incompatible feature set that the kernel doesn't - * know about, it should refuse to mount the filesystem. - * - * e2fsck's requirements are more strict; if it doesn't know - * about a feature in either the compatible or incompatible - * feature set, it must abort and not try to meddle with - * things it doesn't understand... - */ - __u32 s_first_ino; /* First non-reserved inode */ - __u16 s_inode_size; /* size of inode structure */ - __u16 s_block_group_nr; /* block group # of this superblock */ - struct feature_compat_str { - unsigned dir_prealloc : 1; - unsigned imagic_inode : 1; - unsigned has_journal : 1; - unsigned ext_attr : 1; - unsigned resize_inode : 1; - unsigned dir_index : 1; - unsigned reserved : 26; - } __attribute__ ((packed)) s_feature_compat; /* compatible feature set */ - struct feature_incompat_str { - unsigned compression : 1; - unsigned filetype : 1; - unsigned recover : 1; - unsigned journal_dev : 1; - unsigned reserved : 28; - } __attribute__ ((packed)) s_feature_incompat; /* incompatible feature set */ - struct feature_ro_compat_str { - unsigned sparse_super : 1; - unsigned large_file : 1; - unsigned btree_dir : 1; - unsigned reserved : 27; - } __attribute__ ((packed)) s_feature_ro_compat; /* readonly-compatible feature set */ - __u8 s_uuid[16]; /* 128-bit uuid for volume */ - char s_volume_name[16]; /* volume name */ - char s_last_mounted[64]; /* directory where last mounted */ - __u32 s_algorithm_usage_bitmap; /* For compression */ - /* - * Performance hints. Directory preallocation should only - * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. - */ - __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ - __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ - __u16 s_padding1; - /* - * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. - */ - __u8 s_journal_uuid[16]; /* uuid of journal superblock */ - __u32 s_journal_inum; /* inode number of journal file */ - __u32 s_journal_dev; /* device number of journal file */ - __u32 s_last_orphan; /* start of list of inodes to delete */ - - __u32 s_reserved[197]; /* Padding to the end of the block */ - } E2FS_super_block; - -/* - * Structure of an inode on the disk - */ -typedef struct { - struct i_mode_str { -#if 0 - struct { - unsigned short execute : 1; - unsigned short write : 1; - unsigned short read : 1; - } __attribute__ ((packed)) other, group, user; -#else - unsigned short execute_other : 1; - unsigned short write_other : 1; - unsigned short read_other : 1; - unsigned short execute_group : 1; - unsigned short write_group : 1; - unsigned short read_group : 1; - unsigned short execute_user : 1; - unsigned short write_user : 1; - unsigned short read_user : 1; -#endif - unsigned short vtx : 1; - unsigned short gid : 1; - unsigned short uid : 1; - enum { - fmt_fifo = 1, - fmt_chr = 2, - fmt_dir = 4, - fmt_blk = 6, - fmt_reg = 8, - fmt_lnk = 10, - fmt_sock = 12 - } fmt : 4; - } __attribute__ ((packed)) i_mode; /* File mode */ - __u16 i_uid; /* Low 16 bits of Owner Uid */ - __u32 i_size; /* Size in bytes */ - __u32 i_atime; /* Access time */ - __u32 i_ctime; /* Creation time */ - __u32 i_mtime; /* Modification time */ - __u32 i_dtime; /* Deletion Time */ - __u16 i_gid; /* Low 16 bits of Group Id */ - __u16 i_links_count; /* Links count */ - __u32 i_blocks; /* Blocks count */ - __u32 i_flags; /* File flags */ - /* OS dependent 1: */ - __u32 i_translator; /* Only HURD, else reserved */ - /* end OS dependent 1 */ - __u32 i_direct_block[12]; - __u32 i_simple_indirect_block; - __u32 i_double_indirect_block; - __u32 i_triple_indirect_block; - __u32 i_generation; /* File version (for NFS) */ - __u32 i_file_acl; /* File ACL */ - __u32 i_size_high; /* was i_dir_acl, i.e. Directory ACL */ - __u32 i_faddr; /* Fragment address */ - /* OS dependent 2: */ - __u8 i_frag; /* Fragment number */ - __u8 i_fsize; /* Fragment size */ - __u16 i_mode_high; /* Only HURD, else padding */ - /* Following is reserved for masix: */ - __u16 i_uid_high; - __u16 i_gid_high; - __u32 i_author; /* Only HURD, else reserved */ - /* end OS dependent 2 */ - } __attribute__ ((packed)) E2FS_inode; - -typedef struct { - __u32 bg_block_bitmap; /* Blocks bitmap block */ - __u32 bg_inode_bitmap; /* Inodes bitmap block */ - __u32 bg_inode_table; /* Inodes table block */ - __u16 bg_free_blocks_count; /* Free blocks count */ - __u16 bg_free_inodes_count; /* Free inodes count */ - __u16 bg_used_dirs_count; /* Directories count */ - __u16 bg_pad; - __u32 bg_reserved[3]; - } E2FS_group_desc; - -typedef struct { - __u32 inode; /* Inode number */ - __u16 rec_len; /* Directory entry length */ - __u8 name_len; /* Name length */ - enum E2FS_file_type { - e2fs_ft_unknown = 0, - e2fs_ft_reg_file = 1, - e2fs_ft_dir = 2, - e2fs_ft_chrdev = 3, - e2fs_ft_blkdev = 4, - e2fs_ft_fifo = 5, - e2fs_ft_sock = 6, - e2fs_ft_symlink = 7 - } file_type : 8; - char name[EXT2_NAME_LEN]; /* File name (variable array) */ - } E2FS_dir_entry; - -#endif /* E2FS_H */ - diff --git a/Dump/hybos/include/esh/esh.h b/Dump/hybos/include/esh/esh.h deleted file mode 100644 index 298da0c..0000000 --- a/Dump/hybos/include/esh/esh.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * esh.h - */ - -#ifndef _ESH_H -#define _ESH_H - -#define MAX_LEN 512 /* maximum length of a command */ -#define MAX_PARAMS 20 /* maximum ammount of parameters a command may have */ -#define COMMAND_COUNT 6 /* number of commands supported */ - -typedef struct ESHELL_COMMANDS -{ - int minparams; /* number of required parameters */ - int maxparams; /* number of maximum parameters supported */ - char command[MAX_LEN]; /* command entry */ - char params[MAX_PARAMS][MAX_LEN]; /* parameters for command [index]["entry"] */ - char description[MAX_LEN]; -} ESHCOMMANDS; - -typedef struct ESHELL_CURR_COMMAND -{ - int count; - char param[MAX_PARAMS][MAX_LEN]; - char value[MAX_PARAMS][MAX_LEN]; -} ESHCURRCOMMAND; - -void keyDown(unsigned key); -void keyUp(unsigned key); -void processCommand(char *line, int count); - -#endif /* _ESH_H */ - diff --git a/Dump/hybos/include/esh/esh.h~ b/Dump/hybos/include/esh/esh.h~ deleted file mode 100644 index 134afeb..0000000 --- a/Dump/hybos/include/esh/esh.h~ +++ /dev/null @@ -1,32 +0,0 @@ -/** - * esh.h - */ - -#ifndef _ESH_H -#define _ESH_H - -#define MAX_LEN 512 /* maximum length of a command */ -#define MAX_PARAMS 20 /* maximum ammount of parameters a command may have */ -#define COMMAND_COUNT 6 /* number of commands supported */ - -typedef struct ESHELL_COMMANDS -{ - int minparams; /* number of required parameters */ - int maxparams; /* number of maximum parameters supported */ - char command[MAX_LEN]; /* command entry */ - char params[MAX_PARAMS][MAX_LEN]; /* parameters for command [index]["entry"] */ -} ESHCOMMANDS; - -typedef struct ESHELL_CURR_COMMAND -{ - int count; - char param[MAX_PARAMS][MAX_LEN]; - char value[MAX_PARAMS][MAX_LEN]; -} ESHCURRCOMMAND; - -void keyDown(unsigned key); -void keyUp(unsigned key); -void processCommand(char *line, int count); - -#endif /* _ESH_H */ - diff --git a/Dump/hybos/include/fat.h b/Dump/hybos/include/fat.h deleted file mode 100644 index af93578..0000000 --- a/Dump/hybos/include/fat.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _FAT_H -#define _FAT_H - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned long uint32_t; - -/** - * FAT12 and FAT16 bootsector - */ -typedef struct __FAT_BOOTSECTOR /* MUST be packed */ -{ - uint8_t jump[3]; /* 16-bit JMP to boot code, or 8-bit JMP + NOP */ - uint8_t oem_id[8]; /* e.g., 'MSWIN4.0' */ - uint16_t bytes_per_sector; /* typically 512 */ - uint8_t sectors_per_cluster; - uint16_t num_boot_sectors; /* typically 1 */ - uint8_t num_fats; /* typically 2 */ - uint16_t num_root_dir_ents; - uint16_t total_sectors; /* 16-bit; 0 if num sectors > 65535 */ - uint8_t media_ID_byte; /* typically 0F0h */ - uint16_t sectors_per_fat; - uint16_t sectors_per_track; - uint16_t heads; - uint32_t hidden_sectors; /* LBA partition start */ - uint32_t total_sectors_large; /* 32-bit; 0 if num sectors < 65536 */ - uint8_t boot_code[474]; - uint8_t magic[2]; /* 55h, 0AAh */ -} FAT_BOOTSECTOR; /* 512 bytes total */ - -/** - * FAT directory entries - * - * As far as I know, this should be valid for FAT12/16/32 - * Entries are 32 bytes long - */ -typedef struct __FAT_DIRSTRUCT /* MUST be packed */ -{ - uint8_t name[8]; /* all caps, pad right with spaces */ - uint8_t ext[3]; /* all caps, pad right with spaces */ - uint8_t attrib; /* attribute byte */ - uint8_t reserved; /* 0 */ - uint8_t ctime_ms; /* file creation time, 10ms units */ - uint16_t ctime; /* file creation time, in DOS format */ - uint16_t cdate; /* file creation date, in DOS format */ - uint16_t adate; /* DOS date of last file access */ - uint16_t st_clust_msw; /* high 16 bits of starting cluster (FAT32) */ - uint16_t mtime; /* DOS time of last file modification */ - uint16_t mdate; /* DOS date of last file modification */ - uint16_t st_clust; /* starting cluster */ - uint32_t file_size; /* in bytes */ -} FAT_DIRSTRUCT; /* 32 bytes total */ - -/** - * DOS time and date structs - */ -typedef struct __DOS_TIME /* MUST be packed */ -{ - unsigned two_secs : 5; /* low 5 bits: 2-second increments */ - unsigned minutes : 6; /* middle 6 bits: minutes */ - unsigned hours : 5; /* high 5 bits: hours (0-23) */ -} DOS_TIME; /* 2 bytes total */ - -typedef struct __DOS_DATE /* MUST be packed */ -{ - unsigned date : 5; /* low 5 bits: date (1-31) */ - unsigned month : 4; /* middle 4 bits: month (1-12) */ - unsigned year : 7; /* high 7 bits: year - 1980 */ -} DOS_DATE; /* 2 bytes total */ - -/** - * DOS File attributes - */ -typedef struct __DOS_ATTRIB /* MUST be packed */ -{ - int read_only : 1; /* b0 */ - int hidden : 1; - int system : 1; - int volume_label : 1; - int directory : 1; - int reserved : 2; /* b6, b7 */ -} DOS_ATTRIB; /* 1 byte total */ - -#endif /* ! _FAT_H */ diff --git a/Dump/hybos/include/keyboard.h b/Dump/hybos/include/keyboard.h deleted file mode 100644 index 403422c..0000000 --- a/Dump/hybos/include/keyboard.h +++ /dev/null @@ -1,415 +0,0 @@ -#ifndef _KEYBOARD_H -#define _KEYBOARD_H - -/** - * For now we will default to __KB_IBM_PC_XT - */ -#define __KB_IBM_PC_XT - - -/** - * Just in case we were defined someplace else - */ -#ifdef __KB_IBM_PC_XT -#undef __KB_IBM_PC_AT -#undef __KB_IBM_PS2 -#elif defined(__KB_IBM_PC_AT) -#undef __KB_IBM_PC_XT -#undef __KB_IBM_PS2 -#else -#undef __KB_IBM_PC_AT -#undef __KB_IBM_PC_XT -#define __KB_IBM_PC_XT -#endif - - -#ifdef __KB_IBM_PC_XT -/** - * Set 1 Scancodes - * - * IBM PC XT - * - * __KB_IBM_PC_XT must be defined to use these - */ -#define KEY_ESC 0x01 -#define KEY_F1 0x3B -#define KEY_F2 0x3C -#define KEY_F3 0x3D -#define KEY_F4 0x3E -#define KEY_F5 0x3F -#define KEY_F6 0x40 -#define KEY_F7 0x41 -#define KEY_F8 0x42 -#define KEY_F9 0x43 -#define KEY_F10 0x44 -#define KEY_F11 0x57 -#define KEY_F12 0x58 -#define KEY_TILDA 0x29 -#define KEY_1 0x02 -#define KEY_2 0x03 -#define KEY_3 0x04 -#define KEY_4 0x05 -#define KEY_5 0x06 -#define KEY_6 0x07 -#define KEY_7 0x08 -#define KEY_8 0x09 -#define KEY_9 0x0A -#define KEY_0 0x0B -#define KEY_MINUS 0x0C -#define KEY_PLUS 0x0D -#define KEY_BKSLASH 0x2B -#define KEY_BKSPACE 0x0E -#define KEY_TAB 0x0F -#define KEY_Q 0x10 -#define KEY_W 0x11 -#define KEY_E 0x12 -#define KEY_R 0x13 -#define KEY_T 0x14 -#define KEY_Y 0x15 -#define KEY_U 0x16 -#define KEY_I 0x17 -#define KEY_O 0x18 -#define KEY_P 0x19 -#define KEY_LBRACKET 0x1A -#define KEY_RBRACKET 0x1B -#define KEY_ENTER 0x1C -#define KEY_CAPS 0x3A -#define KEY_A 0x1E -#define KEY_S 0x1F -#define KEY_D 0x20 -#define KEY_F 0x21 -#define KEY_G 0x22 -#define KEY_H 0x23 -#define KEY_J 0x24 -#define KEY_K 0x25 -#define KEY_L 0x26 -#define KEY_SEMICOLON 0x27 -#define KEY_QUOTE 0x28 -#define KEY_LSHIFT 0x2A -#define KEY_Z 0x2C -#define KEY_X 0x2D -#define KEY_C 0x2E -#define KEY_V 0x2F -#define KEY_B 0x30 -#define KEY_N 0x31 -#define KEY_M 0x32 -#define KEY_COMMA 0x33 -#define KEY_PERIOD 0x34 -#define KEY_SLASH 0x35 -#define KEY_RSHIFT 0x36 -#define KEY_LCTRL 0x1D -#define KEY_LWIN 0x5B -#define KEY_LALT 0x38 -#define KEY_SPACE 0x39 -#define KEY_RALT 0x38 -#define KEY_RWIN 0x5C -#define KEY_MENU 0x5D -#define KEY_RCTRL 0x1D -#define KEY_SCRLCK 0x46 /* scroll lock */ - -/** - * Keypad - */ -#define KEYP_NUMLCK 0x45 -#define KEYP_SLASH 0x35 -#define KEYP_ASTERISK 0x37 -#define KEYP_MINUS 0x4A -#define KEYP_7 0x47 -#define KEYP_8 0x48 -#define KEYP_9 0x49 -#define KEYP_PLUS 0x4E -#define KEYP_4 0x4B -#define KEYP_5 0x4C -#define KEYP_6 0x4D -#define KEYP_1 0x4F -#define KEYP_2 0x50 -#define KEYP_3 0x51 -#define KEYP_ENTER 0x1C -#define KEYP_0 0x52 -#define KEYP_PERIOD 0x53 - -/** - * Insert, Home, Page Up cluster - */ -#define KEY_INSERT 0x52 -#define KEY_HOME 0x47 -#define KEY_PGUP 0x49 -#define KEY_DEL 0x53 -#define KEY_END 0x4F -#define KEY_PGDOWN 0x51 - -/** - * Arrow key cluster - */ -#define KEY_UP 0x48 -#define KEY_LEFT 0x4B -#define KEY_DOWN 0x50 -#define KEY_RIGHT 0x4D - -/** - * FIXME: Experimental - */ -//#define KEY_PRTSCR 0xE02AE037 /* print screen */ -//#define KEY_PAUSE 0xE11D45E19DC5 /* pause/break */ - -#endif /* defined(__KB_IBM_PC_XT) */ - -#ifdef __KB_IBM_PC_AT -/** - * Set 2 Scancodes - * - * IBM PC AT - * - * __KB_IBM_PC_AT must be defined to use these - */ -#define KEY_ESC 0x76 -#define KEY_F1 0x05 -#define KEY_F2 0x06 -#define KEY_F3 0x04 -#define KEY_F4 0x0C -#define KEY_F5 0x03 -#define KEY_F6 0x0B -#define KEY_F7 0x83 -#define KEY_F8 0x0A -#define KEY_F9 0x01 -#define KEY_F10 0x09 -#define KEY_F11 0x78 -#define KEY_F12 0x07 -#define KEY_TILDA 0x0E -#define KEY_1 0x16 -#define KEY_2 0x1E -#define KEY_3 0x26 -#define KEY_4 0x25 -#define KEY_5 0x2E -#define KEY_6 0x36 -#define KEY_7 0x3D -#define KEY_8 0x3E -#define KEY_9 0x46 -#define KEY_0 0x45 -#define KEY_MINUS 0x4E -#define KEY_PLUS 0x55 -#define KEY_BKSLASH 0x5D -#define KEY_BKSPACE 0x66 -#define KEY_TAB 0x0D -#define KEY_Q 0x15 -#define KEY_W 0x1D -#define KEY_E 0x24 -#define KEY_R 0x2D -#define KEY_T 0x2C -#define KEY_Y 0x35 -#define KEY_U 0x3C -#define KEY_I 0x43 -#define KEY_O 0x44 -#define KEY_P 0x4D -#define KEY_LBRACKET 0x54 -#define KEY_RBRACKET 0x5B -#define KEY_ENTER 0x5A -#define KEY_CAPS 0x58 -#define KEY_A 0x1C -#define KEY_S 0x1B -#define KEY_D 0x23 -#define KEY_F 0x2B -#define KEY_G 0x34 -#define KEY_H 0x33 -#define KEY_J 0x3B -#define KEY_K 0x42 -#define KEY_L 0x4B -#define KEY_SEMICOLON 0x4C -#define KEY_QUOTE 0x52 -#define KEY_LSHIFT 0x12 -#define KEY_Z 0x1A -#define KEY_X 0x22 -#define KEY_C 0x21 -#define KEY_V 0x2A -#define KEY_B 0x32 -#define KEY_N 0x31 -#define KEY_M 0x3A -#define KEY_COMMA 0x41 -#define KEY_PERIOD 0x49 -#define KEY_SLASH 0x4A -#define KEY_RSHIFT 0x59 -#define KEY_LCTRL 0x14 -#define KEY_LWIN 0xE01F -#define KEY_LALT 0x11 -#define KEY_SPACE 0x29 -#define KEY_RALT 0xE011 -#define KEY_RWIN 0xE027 -#define KEY_MENU 0xE02F -#define KEY_RCTRL 0xE014 -#define KEY_SCRLCK 0x7E /* scroll lock */ - -/** - * Keypad - */ -#define KEYP_NUMLCK 0x77 -#define KEYP_SLASH 0xE04A -#define KEYP_ASTERISK 0x7C -#define KEYP_MINUS 0x7B -#define KEYP_7 0x6C -#define KEYP_8 0x75 -#define KEYP_9 0x7D -#define KEYP_PLUS 0x79 -#define KEYP_4 0x6B -#define KEYP_5 0x73 -#define KEYP_6 0x74 -#define KEYP_1 0x69 -#define KEYP_2 0x72 -#define KEYP_3 0x7A -#define KEYP_ENTER 0xE05A -#define KEYP_0 0x70 -#define KEYP_PERIOD 0x71 - -/** - * Insert, Home, Page Up cluster - */ -#define KEY_INSERT 0xE070 -#define KEY_HOME 0xE06C -#define KEY_PGUP 0xE07D -#define KEY_DEL 0xE071 -#define KEY_END 0xE069 -#define KEY_PGDOWN 0xE07A - -/** - * Arrow key cluster - */ -#define KEY_UP 0xE075 -#define KEY_LEFT 0xE06B -#define KEY_DOWN 0xE072 -#define KEY_RIGHT 0xE074 - -/** - * FIXME: Experimental - */ -#define KEY_PRTSCR 0xE012E07C /* print screen */ -#define KEY_PAUSE 0xE11477E1F014F077 /* pause/break */ - -#endif /* defined(__KB_IBM_PC_AT) */ - -#ifdef __KB_IBM_PS2 -/** - * Set 1 Scancodes - * - * IBM PC XT - * - * __KB_IBM_PS2 must be defined to use these - */ -#define KEY_ESC 0x08 -#define KEY_F1 0x07 -#define KEY_F2 0x0F -#define KEY_F3 0x17 -#define KEY_F4 0x1F -#define KEY_F5 0x27 -#define KEY_F6 0x2F -#define KEY_F7 0x37 -#define KEY_F8 0x3F -#define KEY_F9 0x47 -#define KEY_F10 0x4F -#define KEY_F11 0x56 -#define KEY_F12 0x5E -#define KEY_TILDA 0x0E -#define KEY_1 0x16 -#define KEY_2 0x1E -#define KEY_3 0x26 -#define KEY_4 0x25 -#define KEY_5 0x2E -#define KEY_6 0x36 -#define KEY_7 0x3D -#define KEY_8 0x3E -#define KEY_9 0x46 -#define KEY_0 0x45 -#define KEY_MINUS 0x4E -#define KEY_PLUS 0x55 -#define KEY_BKSLASH 0x5C -#define KEY_BKSPACE 0x66 -#define KEY_TAB 0x0D -#define KEY_Q 0x15 -#define KEY_W 0x1D -#define KEY_E 0x24 -#define KEY_R 0x2D -#define KEY_T 0x2C -#define KEY_Y 0x35 -#define KEY_U 0x3C -#define KEY_I 0x43 -#define KEY_O 0x44 -#define KEY_P 0x4D -#define KEY_LBRACKET 0x54 -#define KEY_RBRACKET 0x5B -#define KEY_ENTER 0x5A -#define KEY_CAPS 0x14 -#define KEY_A 0x1C -#define KEY_S 0x1B -#define KEY_D 0x23 -#define KEY_F 0x2B -#define KEY_G 0x34 -#define KEY_H 0x33 -#define KEY_J 0x3B -#define KEY_K 0x42 -#define KEY_L 0x4B -#define KEY_SEMICOLON 0x4C -#define KEY_QUOTE 0x52 -#define KEY_LSHIFT 0x12 -#define KEY_Z 0x1A -#define KEY_X 0x22 -#define KEY_C 0x21 -#define KEY_V 0x2A -#define KEY_B 0x32 -#define KEY_N 0x31 -#define KEY_M 0x3A -#define KEY_COMMA 0x41 -#define KEY_PERIOD 0x49 -#define KEY_SLASH 0x4A -#define KEY_RSHIFT 0x59 -#define KEY_LCTRL 0x11 -#define KEY_LWIN 0x8B -#define KEY_LALT 0x19 -#define KEY_SPACE 0x29 -#define KEY_RALT 0x39 -#define KEY_RWIN 0x8C -#define KEY_MENU 0x8D -#define KEY_RCTRL 0x58 -#define KEY_SCRLCK 0x5F /* scroll lock */ -#define KEY_PRTSCR 0x57 /* print screen */ -#define KEY_PAUSE 0x62 /* pause/break */ - -/** - * Keypad - */ -#define KEYP_NUMLCK 0x76 -#define KEYP_SLASH 0x77 -#define KEYP_ASTERISK 0x7E -#define KEYP_MINUS 0x84 -#define KEYP_7 0x6C -#define KEYP_8 0x75 -#define KEYP_9 0x7D -#define KEYP_PLUS 0x7C -#define KEYP_4 0x6B -#define KEYP_5 0x73 -#define KEYP_6 0x74 -#define KEYP_1 0x69 -#define KEYP_2 0x72 -#define KEYP_3 0x7A -#define KEYP_ENTER 0x79 -#define KEYP_0 0x70 -#define KEYP_PERIOD 0x71 - -/** - * Insert, Home, Page Up cluster - */ -#define KEY_INSERT 0x67 -#define KEY_HOME 0x6E -#define KEY_PGUP 0x6F -#define KEY_DEL 0x64 -#define KEY_END 0x65 -#define KEY_PGDOWN 0x6D - -/** - * Arrow key cluster - */ -#define KEY_UP 0x63 -#define KEY_LEFT 0x61 -#define KEY_DOWN 0x60 -#define KEY_RIGHT 0x6A - -#endif /* defined(__KB_IBM_PS2) */ - -#endif /* ! _KEYBOARD_H */ diff --git a/Dump/hybos/include/keymap.h b/Dump/hybos/include/keymap.h deleted file mode 100644 index ae39ba0..0000000 --- a/Dump/hybos/include/keymap.h +++ /dev/null @@ -1,142 +0,0 @@ -/* keymap.h - defines for keymapping Author: Marcus Hampel - */ -#ifndef _SYS__KEYMAP_H -#define _SYS__KEYMAP_H - -#define C(c) ((c) & 0x1F) /* Map to control code */ -#define A(c) ((c) | 0x80) /* Set eight bit (ALT) */ -#define CA(c) A(C(c)) /* Control-Alt */ -#define L(c) ((c) | HASCAPS) /* Add "Caps Lock has effect" attribute */ - -#define EXT 0x0100 /* Normal function keys */ -#define CTRL 0x0200 /* Control key */ -#define SHIFT 0x0400 /* Shift key */ -#define ALT 0x0800 /* Alternate key */ -#define EXTKEY 0x1000 /* extended keycode */ -#define HASCAPS 0x8000 /* Caps Lock has effect */ - -/* Numeric keypad */ -#define HOME (0x01 + EXT) -#define END (0x02 + EXT) -#define UP (0x03 + EXT) -#define DOWN (0x04 + EXT) -#define LEFT (0x05 + EXT) -#define RIGHT (0x06 + EXT) -#define PGUP (0x07 + EXT) -#define PGDN (0x08 + EXT) -#define MID (0x09 + EXT) -#define NMIN (0x0A + EXT) -#define PLUS (0x0B + EXT) -#define INSRT (0x0C + EXT) - -/* Alt + Numeric keypad */ -#define AHOME (0x01 + ALT) -#define AEND (0x02 + ALT) -#define AUP (0x03 + ALT) -#define ADOWN (0x04 + ALT) -#define ALEFT (0x05 + ALT) -#define ARIGHT (0x06 + ALT) -#define APGUP (0x07 + ALT) -#define APGDN (0x08 + ALT) -#define AMID (0x09 + ALT) -#define ANMIN (0x0A + ALT) -#define APLUS (0x0B + ALT) -#define AINSRT (0x0C + ALT) - -/* Ctrl + Numeric keypad */ -#define CHOME (0x01 + CTRL) -#define CEND (0x02 + CTRL) -#define CUP (0x03 + CTRL) -#define CDOWN (0x04 + CTRL) -#define CLEFT (0x05 + CTRL) -#define CRIGHT (0x06 + CTRL) -#define CPGUP (0x07 + CTRL) -#define CPGDN (0x08 + CTRL) -#define CMID (0x09 + CTRL) -#define CNMIN (0x0A + CTRL) -#define CPLUS (0x0B + CTRL) -#define CINSRT (0x0C + CTRL) - -/* Lock keys */ -#define CALOCK (0x0D + EXT) /* caps lock */ -#define NLOCK (0x0E + EXT) /* number lock */ -#define SLOCK (0x0F + EXT) /* scroll lock */ - -/* Function keys */ -#define F1 (0x10 + EXT) -#define F2 (0x11 + EXT) -#define F3 (0x12 + EXT) -#define F4 (0x13 + EXT) -#define F5 (0x14 + EXT) -#define F6 (0x15 + EXT) -#define F7 (0x16 + EXT) -#define F8 (0x17 + EXT) -#define F9 (0x18 + EXT) -#define F10 (0x19 + EXT) -#define F11 (0x1A + EXT) -#define F12 (0x1B + EXT) - -/* Alt+Fn */ -#define AF1 (0x10 + ALT) -#define AF2 (0x11 + ALT) -#define AF3 (0x12 + ALT) -#define AF4 (0x13 + ALT) -#define AF5 (0x14 + ALT) -#define AF6 (0x15 + ALT) -#define AF7 (0x16 + ALT) -#define AF8 (0x17 + ALT) -#define AF9 (0x18 + ALT) -#define AF10 (0x19 + ALT) -#define AF11 (0x1A + ALT) -#define AF12 (0x1B + ALT) - -/* Ctrl+Fn */ -#define CF1 (0x10 + CTRL) -#define CF2 (0x11 + CTRL) -#define CF3 (0x12 + CTRL) -#define CF4 (0x13 + CTRL) -#define CF5 (0x14 + CTRL) -#define CF6 (0x15 + CTRL) -#define CF7 (0x16 + CTRL) -#define CF8 (0x17 + CTRL) -#define CF9 (0x18 + CTRL) -#define CF10 (0x19 + CTRL) -#define CF11 (0x1A + CTRL) -#define CF12 (0x1B + CTRL) - -/* Shift+Fn */ -#define SF1 (0x10 + SHIFT) -#define SF2 (0x11 + SHIFT) -#define SF3 (0x12 + SHIFT) -#define SF4 (0x13 + SHIFT) -#define SF5 (0x14 + SHIFT) -#define SF6 (0x15 + SHIFT) -#define SF7 (0x16 + SHIFT) -#define SF8 (0x17 + SHIFT) -#define SF9 (0x18 + SHIFT) -#define SF10 (0x19 + SHIFT) -#define SF11 (0x1A + SHIFT) -#define SF12 (0x1B + SHIFT) - -/* Alt+Shift+Fn */ -#define ASF1 (0x10 + ALT + SHIFT) -#define ASF2 (0x11 + ALT + SHIFT) -#define ASF3 (0x12 + ALT + SHIFT) -#define ASF4 (0x13 + ALT + SHIFT) -#define ASF5 (0x14 + ALT + SHIFT) -#define ASF6 (0x15 + ALT + SHIFT) -#define ASF7 (0x16 + ALT + SHIFT) -#define ASF8 (0x17 + ALT + SHIFT) -#define ASF9 (0x18 + ALT + SHIFT) -#define ASF10 (0x19 + ALT + SHIFT) -#define ASF11 (0x1A + ALT + SHIFT) -#define ASF12 (0x1B + ALT + SHIFT) - -#define MAP_COLS 6 /* Number of columns in keymap */ -#define NR_SCAN_CODES 0x80 /* Number of scan codes (rows in keymap) */ - -typedef unsigned short keymap_t[NR_SCAN_CODES * MAP_COLS]; - -#define KEY_MAGIC "KMAZ" /* Magic number of keymap file */ - -#endif /* _SYS__KEYMAP_H */ diff --git a/Dump/hybos/include/mmzone.h b/Dump/hybos/include/mmzone.h deleted file mode 100644 index e69de29..0000000 --- a/Dump/hybos/include/mmzone.h +++ /dev/null diff --git a/Dump/hybos/include/setjmp.h b/Dump/hybos/include/setjmp.h deleted file mode 100644 index b9dda41..0000000 --- a/Dump/hybos/include/setjmp.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __TL_SETJMP_H -#define __TL_SETJMP_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef struct -{ -/* setjmp() and longjmp() rely on the order of these registers, -so do not re-arrange them */ - unsigned edi, esi, ebp, esp, ebx, edx, ecx, eax; - unsigned eip, eflags; -} jmp_buf[1]; - -int setjmp(jmp_buf b); -void longjmp(jmp_buf b, int ret_val); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/include/signal.h b/Dump/hybos/include/signal.h deleted file mode 100644 index 6344bb5..0000000 --- a/Dump/hybos/include/signal.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * signal.h - */ - -#ifndef _SIGNAL_H -#define _SIGNAL_H - -typedef int sig_atomic_t; - -#define SIGHUP 1 /* hangup */ -#define SIGINT 2 /* interrupt (DEL) */ -#define SIGQUIT 3 /* quit (ASCII FS) */ -#define SIGILL 4 /* illegal instruction */ -#define SIGTRAP 5 /* trace trap (not reset when caught) */ -#define SIGABRT 6 /* IOT instruction */ -#define SIGBUS 7 -#define SIGEMT 7 -#define SIGFPE 8 /* floating point exception */ -#define SIGKILL 9 /* kill (cannot be caught or ignored) */ -#define SIGUSR1 10 /* user defined signal 1 */ -#define SIGSEGV 11 /* segmentation violation */ -#define SIGUSR2 12 /* user defined signal 2 */ -#define SIGPIPE 13 /* write on a pipe with no one to read it */ -#define SIGALRM 14 /* alarm clock */ -#define SIGTERM 15 /* software termination signal from kill */ - -/** - * For POSIX compliance - */ -#define SIGCHLD 17 /* child process terminated or stopped */ -#define SIGCONT 18 /* continue if stopped */ -#define SIGSTOP 19 /* stop signal */ -#define SIGTSTP 20 /* interactive stop signal */ -#define SIGTTIN 21 /* background process requesting read */ -#define SIGTTOU 22 /* background process requesting write */ - -#if 0 -#define SIG_ERR ((__sighandler_t) -1) /* error return */ -#define SIG_DFL ((__sighandler_t) 0) /* default signal handling */ -#define SIG_IGN ((__sighandler_t) 1) /* ignore signal */ -#endif /* 0 */ - -#define _NSIG 23 - -#if 0 -int raise(int sig); -__sighandler_t signal(int sig, __sighandler_t func); -int kill(pid_t pid, int sig); -#endif /* 0 */ - -#endif /* _SIGNAL_H */ - diff --git a/Dump/hybos/include/signal.h~ b/Dump/hybos/include/signal.h~ deleted file mode 100644 index 56e3ab5..0000000 --- a/Dump/hybos/include/signal.h~ +++ /dev/null @@ -1,50 +0,0 @@ -/** - * signal.h - */ - -#ifndef _SIGNAL_H -#define _SIGNAL_H - -typedef int sig_atomic_t; - -#define SIGHUP 1 /* hangup */ -#define SIGINT 2 /* interrupt (DEL) */ -#define SIGQUIT 3 /* quit (ASCII FS) */ -#define SIGILL 4 /* illegal instruction */ -#define SIGTRAP 5 /* trace trap (not reset when caught) */ -#define SIGABRT 6 /* IOT instruction */ -#define SIGBUS 7 -#define SIGEMT 7 -#define SIGFPE 8 /* floating point exception */ -#define SIGKILL 9 /* kill (cannot be caught or ignored) */ -#define SIGUSR1 10 /* user defined signal 1 */ -#define SIGSEGV 11 /* segmentation violation */ -#define SIGUSR2 12 /* user defined signal 2 */ -#define SIGPIPE 13 /* write on a pipe with no one to read it */ -#define SIGALRM 14 /* alarm clock */ -#define SIGTERM 15 /* software termination signal from kill */ - -/** - * For POSIX compliance - */ -#define SIGCHLD 17 /* child process terminated or stopped */ -#define SIGCONT 18 /* continue if stopped */ -#define SIGSTOP 19 /* stop signal */ -#define SIGTSTP 20 /* interactive stop signal */ -#define SIGTTIN 21 /* background process requesting read */ -#define SIGTTOU 22 /* background process requesting write */ - -#if 0 -#define SIG_ERR ((__sighandler_t) -1) /* error return */ -#define SIG_DFL ((__sighandler_t) 0) /* default signal handling */ -#define SIG_IGN ((__sighandler_t) 1) /* ignore signal */ -#endif /* 0 */ - -#define _NSIG 23 - -int raise(int sig); -__sighandler_t signal(int sig, __sighandler_t func); -int kill(pid_t pid, int sig); - -#endif /* _SIGNAL_H */ - diff --git a/Dump/hybos/include/stdarg.h b/Dump/hybos/include/stdarg.h deleted file mode 100644 index ea527d4..0000000 --- a/Dump/hybos/include/stdarg.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __TL_STDARG_H -#define __TL_STDARG_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <_va_list.h> - -/* width of stack == width of int */ -#define STACKITEM int - -/* round up width of objects pushed on stack. The expression before the -& ensures that we get 0 for objects of size 0. */ -#define VA_SIZE(TYPE) \ - ((sizeof(TYPE) + sizeof(STACKITEM) - 1) \ - & ~(sizeof(STACKITEM) - 1)) - -/* &(LASTARG) points to the LEFTMOST argument of the function call -(before the ...) */ -#define va_start(AP, LASTARG) \ - (AP=((va_list)&(LASTARG) + VA_SIZE(LASTARG))) - -#define va_end(AP) /* nothing */ - -#define va_arg(AP, TYPE) \ - (AP += VA_SIZE(TYPE), *((TYPE *)(AP - VA_SIZE(TYPE)))) - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/Dump/hybos/include/stdbool.h b/Dump/hybos/include/stdbool.h deleted file mode 100644 index e3f2b22..0000000 --- a/Dump/hybos/include/stdbool.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _STDBOOL_H -#define _STDBOOL_H - -typedef enum {false = 0, true = !0} bool; - -#endif /* !defined(_STDBOOL_H) */ diff --git a/Dump/hybos/include/stddef.h b/Dump/hybos/include/stddef.h deleted file mode 100644 index f1a5135..0000000 --- a/Dump/hybos/include/stddef.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _STDDEF_H -#define _STDDEF_H - -#define NULL ((void *)0) - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -#endif /* _STDDEF_H */ diff --git a/Dump/hybos/include/stdint.h b/Dump/hybos/include/stdint.h deleted file mode 100644 index 744183f..0000000 --- a/Dump/hybos/include/stdint.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef _STDINT_H -#define _STDINT_H - -/* 7.18.1.1 Exact-width integer types */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned uint32_t; -typedef long long int64_t; -typedef unsigned long long uint64_t; - -/* 7.18.1.2 Minimum-width integer types */ -typedef signed char int_least8_t; -typedef unsigned char uint_least8_t; -typedef short int_least16_t; -typedef unsigned short uint_least16_t; -typedef int int_least32_t; -typedef unsigned uint_least32_t; -typedef long long int_least64_t; -typedef unsigned long long uint_least64_t; - -/* 7.18.1.3 Fastest minimum-width integer types - * Not actually guaranteed to be fastest for all purposes - * Here we use the exact-width types for 8 and 16-bit ints. - */ -typedef char int_fast8_t; -typedef unsigned char uint_fast8_t; -typedef short int_fast16_t; -typedef unsigned short uint_fast16_t; -typedef int int_fast32_t; -typedef unsigned int uint_fast32_t; -typedef long long int_fast64_t; -typedef unsigned long long uint_fast64_t; - -/* 7.18.1.4 Integer types capable of holding object pointers */ -typedef int intptr_t; -typedef unsigned uintptr_t; - -/* 7.18.1.5 Greatest-width integer types */ -typedef long long intmax_t; -typedef unsigned long long uintmax_t; - -/* 7.18.2 Limits of specified-width integer types */ -#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS) - -/* 7.18.2.1 Limits of exact-width integer types */ -#define INT8_MIN (-128) -#define INT16_MIN (-32768) -#define INT32_MIN (-2147483647 - 1) -#define INT64_MIN (-9223372036854775807LL - 1) - -#define INT8_MAX 127 -#define INT16_MAX 32767 -#define INT32_MAX 2147483647 -#define INT64_MAX 9223372036854775807LL - -#define UINT8_MAX 0xff /* 255U */ -#define UINT16_MAX 0xffff /* 65535U */ -#define UINT32_MAX 0xffffffff /* 4294967295U */ -#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */ - -/* 7.18.2.2 Limits of minimum-width integer types */ -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST64_MIN INT64_MIN - -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MAX INT64_MAX - -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -/* 7.18.2.3 Limits of fastest minimum-width integer types */ -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN - -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MAX INT64_MAX - -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -/* 7.18.2.4 Limits of integer types capable of holding - object pointers */ -#define INTPTR_MIN INT32_MIN -#define INTPTR_MAX INT32_MAX -#define UINTPTR_MAX UINT32_MAX - -/* 7.18.2.5 Limits of greatest-width integer types */ -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -/* 7.18.3 Limits of other integer types */ -#define PTRDIFF_MIN INT32_MIN -#define PTRDIFF_MAX INT32_MAX - -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX - -#define SIZE_MAX UINT32_MAX - -#ifndef WCHAR_MIN /* also in wchar.h */ -#define WCHAR_MIN 0 -#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */ -#endif - -/* - * wint_t is unsigned short for compatibility with MS runtime - */ -#define WINT_MIN 0 -#define WINT_MAX ((wint_t)-1) /* UINT16_MAX */ - -#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ - - -/* 7.18.4 Macros for integer constants */ -#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS) - -/* 7.18.4.1 Macros for minimum-width integer constants - - Accoding to Douglas Gwyn : - "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC - 9899:1999 as initially published, the expansion was required - to be an integer constant of precisely matching type, which - is impossible to accomplish for the shorter types on most - platforms, because C99 provides no standard way to designate - an integer constant with width less than that of type int. - TC1 changed this to require just an integer constant - *expression* with *promoted* type." - - The trick used here is from Clive D W Feather. -*/ - -#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) -#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) -#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) -/* The 'trick' doesn't work in C89 for long long because, without - suffix, (val) will be evaluated as int, not intmax_t */ -#define INT64_C(val) val##LL - -#define UINT8_C(val) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(val)) -#define UINT16_C(val) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(val)) -#define UINT32_C(val) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(val)) -#define UINT64_C(val) val##ULL - -/* 7.18.4.2 Macros for greatest-width integer constants */ -#define INTMAX_C(val) val##LL -#define UINTMAX_C(val) val##ULL - -#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ - -#endif /* !defined(_STDINT_H) */ diff --git a/Dump/hybos/include/stdio.h b/Dump/hybos/include/stdio.h deleted file mode 100644 index 12bbb89..0000000 --- a/Dump/hybos/include/stdio.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * stdio.h - * - * Input/output functions - */ - -#ifndef _STDIO_H -#define _STDIO_H - -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 - -#ifndef _NULL -#define NULL ((void *)0) -#endif -#define EOF (-1) - -#define FOPEN_MAX 20 -#define FILENAME_MAX 14 -#define TMP_MAX 999 - -typedef long int fpos_t; - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -/*int remove(const char *_filename);*/ -/*int rename(const char *_old, const char *_new);*/ -/*FILE *tmpfile(void);*/ -/*char *tmpnam(char *_s);*/ -/*int fclose(FILE *_stream);*/ -/*int fflush(FILE *_stream);*/ -/*FILE *fopen(const char *_filename, const char *_mode);*/ -/*FILE *freopen(const char *_filename, const char *_mode, FILE *_stream);*/ -/*void setbuf(FILE *_stream, char *_buf);*/ -/*int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size);*/ -/*int fprintf(FILE *_stream, const char *_format, ...);*/ -/*int printf(const char *fmt, ...);*/ -void printf(const char *format, ...); -int sprintf(char *s, const char *format, ...); -/*int vfprintf(FILE *_stream, const char *_format, char *_arg);*/ -/*int vprintf(const char *_format, char *_arg);*/ -int vsprintf(char *s, const char *format, ...); -/*int fscanf(FILE *_stream, const char *_format, ...);*/ -/*int scanf(const char *_format, ...);*/ -/*int sscanf(const char *_s, const char *_format, ...);*/ -/*#define vfscanf _doscan*/ -/*int vfscanf(FILE *_stream, const char *_format, char *_arg);*/ -/*int vscanf(const char *_format, char *_arg);*/ -/*int vsscanf(const char *_s, const char *_format, char *_arg);*/ -/*int fgetc(FILE *_stream);*/ -/*char *fgets(char *_s, int _n, FILE *_stream);*/ -/*int fputc(int _c, FILE *_stream);*/ -/*int fputs(const char *_s, FILE *_stream);*/ -/*int getc(FILE *_stream);*/ -/*int getchar(void);*/ -/*char *gets(char *_s);*/ -/*int putc(int _c, FILE *_stream);*/ -/*int putchar(int _c);*/ -/*int puts(const char *_s);*/ -/*int ungetc(int _c, FILE *_stream);*/ -/*size_t fread(void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);*/ -/*size_t fwrite(const void *_ptr, size_t _size, size_t _nmemb, FILE *_stream);*/ -/*int fgetpos(FILE *_stream, fpos_t *_pos);*/ -/*int fseek(FILE *_stream, long _offset, int _whence);*/ -/*int fsetpos(FILE *_stream, fpos_t *_pos);*/ -/*long ftell(FILE *_stream);*/ -/*void rewind(FILE *_stream);*/ -/*void clearerr(FILE *_stream);*/ -/*int feof(FILE *_stream);*/ -/*int ferror(FILE *_stream);*/ -/*void perror(const char *_s);*/ -/*int __fillbuf(FILE *_stream);*/ -/*int __flushbuf(int _c, FILE *_stream);*/ - -#endif /* _STDIO_H */ diff --git a/Dump/hybos/include/stdlib.h b/Dump/hybos/include/stdlib.h deleted file mode 100644 index 477873e..0000000 --- a/Dump/hybos/include/stdlib.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * stdlib.h - * - * Defines certain common macros, types, and functions - */ - -#ifndef _STDLIB_H -#define _STDLIB_H - -#ifndef _NULL -#define NULL ((void *)0) -#endif - -#define EXIT_FAILURE 1 /* standard error returned from exit() */ -#define EXIT_SUCCESS 0 /* successfull return from exit() */ -#define RAND_MAX 32767 /* largest value generated by rand() */ -#define MB_CUR_MAX 1 /* maximum value of multibyte character */ - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -#ifndef _WCHAR_T -#define _WCHAR_T -typedef char wchar_t; -#endif - -/*void abort(void);*/ -int abs(int number); -/*int atexit(void (*_func)(void));*/ -/*double atof(const char *_nptr);*/ -int atoi(const char *nptr); -/*long atol(const char *_nptr);*/ -/*void *calloc(size_t _nmemb, size_t _size);*/ -/*div_t div(int _numer, int _denom);*/ -/*void exit(int _status);*/ -void free(void *blk); -/*char *getenv(const char *_name);*/ -/*long labs(long _j);*/ -/*ldiv_t ldiv(long _numer, long _denom);*/ -void *malloc(size_t _size); -/*int mblen(const char *_s, size_t _n);*/ -/*size_t mbstowcs(wchar_t *_pwcs, const char *_s, size_t _n);*/ -/*int mbtowc(wchar_t *_pwc, const char *_s, size_t _n);*/ -void *realloc(void *blk, size_t size); -/*double strtod(const char *_nptr, char **_endptr);*/ -/*long strtol(const char *_nptr, char **_endptr, int _base);*/ -/*int system(const char *_string);*/ -/*size_t wcstombs(char *_s, const wchar_t *_pwcs, size_t _n);*/ -/*int wctomb(char *_s, wchar_t _wchar);*/ -/*void *bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, int (*compar) (const void *, const void *));*/ -/*void qsort(void *_base, size_t _nmemb, size_t _size, int (*compar) (const void *, const void *));*/ -int rand(void); -void srand(unsigned int seed); -/*unsigned long int strtoul(const char *_nptr, char **_endptr, int _base);*/ - -#endif /* _STDLIB_H */ diff --git a/Dump/hybos/include/string.h b/Dump/hybos/include/string.h deleted file mode 100644 index 8fa2767..0000000 --- a/Dump/hybos/include/string.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __TL_STRING_H -#define __TL_STRING_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*#include <_size_t.h>*/ -/*#include <_null.h>*/ -#include - -void *memcpy(void *dst_ptr, const void *src_ptr, size_t count); -void *memsetw(void *dst, int val, size_t count); -size_t strlen(const char *str); -int strcmp(const char * src, const char * dst); -int strncmp(const char * first, const char * last, size_t count); -char *strcpy(char *s, const char *t); -char *strncpy(char * dest, const char * source, size_t count); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/Dump/hybos/include/sys/dir.h b/Dump/hybos/include/sys/dir.h deleted file mode 100644 index 114d2bf..0000000 --- a/Dump/hybos/include/sys/dir.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _DIR_H -#define _DIR_H - -/** - * Size of directory block - */ -#define DIRBLKSIZE 512 - -#ifndef DIRSIZ -#define DIRSIZ 14 -#endif - -typedef struct __DIR__DIRECT_ -{ - unsigned int d_ino; /* defined as __kernel_ino_t in posix_types.h */ - char d_name[DIRSIZ]; -} direct; - -#endif /* _DIR_H */ diff --git a/Dump/hybos/include/time.h b/Dump/hybos/include/time.h deleted file mode 100644 index 96b5c37..0000000 --- a/Dump/hybos/include/time.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * time.h - */ - -#ifndef _TIME_H -#define _TIME_H - -#define CLOCKS_PER_SEC 60 /* 60 Hz */ - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -#ifndef _TIME_T -#define _TIME_T -typedef long time_t; /* time in seconds since January 1, 1970 0000 GMT */ -#endif - -#ifndef _CLOCK_T -#define _CLOCK_T -typedef long clock_t; /* time in ticks since process started */ -#endif - -typedef struct __TIME_H_TIME -{ - int tm_sec; /* seconds after the minute [0, 59] */ - int tm_min; /* minutes after the hour [0, 59] */ - int tm_hour; /* hours since midnight [0, 23] */ - int tm_mday; /* day of the month [1, 31] */ - int tm_mon; /* months since January [0, 11] */ - int tm_year; /* years since 1900 */ - int tm_wday; /* days since Sunday [0, 6] */ - int tm_yday; /* days since January 1 [0, 365] */ - int tm_isdst; /* Daylight Saving Time flag */ -} dm, TIME; - -clock_t clock(void); -double difftime(time_t time1, time_t time0); -time_t mktime(struct tm *pTime); -time_t time(time_t *pTime); -char *asctime(const struct tm *pTime); -char *ctime(const time_t *pTimer); -struct tm *gmtime(const time_t *pTimer); -size_t strftime(char *s, size_t max, const char *format, const struct tm *pTime); - -#endif /* _TIME_H */ - diff --git a/Dump/hybos/include/x86.h b/Dump/hybos/include/x86.h deleted file mode 100644 index bb68769..0000000 --- a/Dump/hybos/include/x86.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __TL_X86_H -#define __TL_X86_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * 16 bit MSB: segment, 16 bit LSB: offset - */ -//typedef unsigned farptr; - -unsigned inportb(unsigned short port); -void outportb(unsigned port, unsigned val); -unsigned inportw(unsigned short port); -void outportw(unsigned port, unsigned val); -unsigned disable(void); -void enable(void); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/Dump/hybos/lib/Makefile b/Dump/hybos/lib/Makefile deleted file mode 100644 index 0b91a38..0000000 --- a/Dump/hybos/lib/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#MAKEFILE=ming.mak -MAKEFILE =Makefile - -OBJS =objects/*.o - -all: - make -f $(MAKEFILE) -C char - make -f $(MAKEFILE) -C config - make -f $(MAKEFILE) -C convert - make -f $(MAKEFILE) -C ctype - make -f $(MAKEFILE) -C math - make -f $(MAKEFILE) -C mem - make -f $(MAKEFILE) -C setjmp - make -f $(MAKEFILE) -C stdio - make -f $(MAKEFILE) -C string - make -f $(MAKEFILE) -C util - make -f $(MAKEFILE) -C x86 - ar rcs libc.a $(OBJS) - -clean: - make -f $(MAKEFILE) -C char clean - make -f $(MAKEFILE) -C config clean - make -f $(MAKEFILE) -C convert clean - make -f $(MAKEFILE) -C ctype clean - make -f $(MAKEFILE) -C math clean - make -f $(MAKEFILE) -C mem clean - make -f $(MAKEFILE) -C setjmp clean - make -f $(MAKEFILE) -C stdio clean - make -f $(MAKEFILE) -C string clean - make -f $(MAKEFILE) -C util clean - make -f $(MAKEFILE) -C x86 clean - del libc.a - diff --git a/Dump/hybos/lib/char/Makefile b/Dump/hybos/lib/char/Makefile deleted file mode 100644 index 654c46f..0000000 --- a/Dump/hybos/lib/char/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -CHAR =isalnum.o \ - isalpha.o \ - isascii.o \ - iscsym.o \ - iscsymf.o \ - isctrl.o \ - isdigit.o \ - isgraph.o \ - islower.o \ - isprint.o \ - ispunct.o \ - isspace.o \ - isupper.o \ - isxdigit.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(CHAR) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\isalnum.o - del ..\$(OBJ_DIR)\isalpha.o - del ..\$(OBJ_DIR)\isascii.o - del ..\$(OBJ_DIR)\iscsym.o - del ..\$(OBJ_DIR)\iscsymf.o - del ..\$(OBJ_DIR)\isctrl.o - del ..\$(OBJ_DIR)\isdigit.o - del ..\$(OBJ_DIR)\isgraph.o - del ..\$(OBJ_DIR)\islower.o - del ..\$(OBJ_DIR)\isprint.o - del ..\$(OBJ_DIR)\ispunct.o - del ..\$(OBJ_DIR)\isspace.o - del ..\$(OBJ_DIR)\isupper.o - del ..\$(OBJ_DIR)\isxdigit.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -isalnum.o: isalnum.c $(MAKEDEP) -isalpha.o: isalpha.c $(MAKEDEP) -isascii.o: isascii.c $(MAKEDEP) -iscsym.o: iscsym.c $(MAKEDEP) -iscsymf.o: iscsymf.c $(MAKEDEP) -isctrl.o: isctrl.c $(MAKEDEP) -isdigit.o: isdigit.c $(MAKEDEP) -isgraph.o: isgraph.c $(MAKEDEP) -islower.o: islower.c $(MAKEDEP) -isprint.o: isprint.c $(MAKEDEP) -ispunct.o: ispunct.c $(MAKEDEP) -isspace.o: isspace.c $(MAKEDEP) -isupper.o: isupper.c $(MAKEDEP) -isxdigit.o: isxdigit.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/char/isalnum.c b/Dump/hybos/lib/char/isalnum.c deleted file mode 100644 index 26b2a3a..0000000 --- a/Dump/hybos/lib/char/isalnum.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isalnum(const char c) -{ - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '1' && c <= '9')); -} diff --git a/Dump/hybos/lib/char/isalpha.c b/Dump/hybos/lib/char/isalpha.c deleted file mode 100644 index 6392de1..0000000 --- a/Dump/hybos/lib/char/isalpha.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isalpha(const char c) -{ - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); -} diff --git a/Dump/hybos/lib/char/isascii.c b/Dump/hybos/lib/char/isascii.c deleted file mode 100644 index 4ddcaee..0000000 --- a/Dump/hybos/lib/char/isascii.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isascii(const unsigned char c) -{ - return (c >= 0x00 && c <= 0x7F); -} diff --git a/Dump/hybos/lib/char/iscsym.c b/Dump/hybos/lib/char/iscsym.c deleted file mode 100644 index 575bb19..0000000 --- a/Dump/hybos/lib/char/iscsym.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool iscsym(const char c) -{ - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c == '_')); -} diff --git a/Dump/hybos/lib/char/iscsymf.c b/Dump/hybos/lib/char/iscsymf.c deleted file mode 100644 index c735f71..0000000 --- a/Dump/hybos/lib/char/iscsymf.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool iscsymf(const char c) -{ - return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '_')); -} diff --git a/Dump/hybos/lib/char/isctrl.c b/Dump/hybos/lib/char/isctrl.c deleted file mode 100644 index 894df6d..0000000 --- a/Dump/hybos/lib/char/isctrl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isctrl(const char c) -{ - return (!(c >= ' ' && c <= '~')); -} diff --git a/Dump/hybos/lib/char/isdigit.c b/Dump/hybos/lib/char/isdigit.c deleted file mode 100644 index 6eebe23..0000000 --- a/Dump/hybos/lib/char/isdigit.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isdigit(const char c) -{ - return (c >= '0' && c <= '9'); -} diff --git a/Dump/hybos/lib/char/isgraph.c b/Dump/hybos/lib/char/isgraph.c deleted file mode 100644 index f8103ca..0000000 --- a/Dump/hybos/lib/char/isgraph.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isgraph(const unsigned char c) -{ - return (!(c >= 0x00 && c <= 0x7F)); -} diff --git a/Dump/hybos/lib/char/islower.c b/Dump/hybos/lib/char/islower.c deleted file mode 100644 index 5e60bfc..0000000 --- a/Dump/hybos/lib/char/islower.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool islowwer(const char c) -{ - return (c >= 'a' && c <= 'z'); -} diff --git a/Dump/hybos/lib/char/isprint.c b/Dump/hybos/lib/char/isprint.c deleted file mode 100644 index 96f5caf..0000000 --- a/Dump/hybos/lib/char/isprint.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isprint(const char c) -{ - return (c >= ' ' && c <= '~'); -} diff --git a/Dump/hybos/lib/char/ispunct.c b/Dump/hybos/lib/char/ispunct.c deleted file mode 100644 index 72b4d4d..0000000 --- a/Dump/hybos/lib/char/ispunct.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool ispunct(const char c) -{ - return ((c >= '!' && c<= '/') || (c >= ':' && c<= '@') || (c >= '[' && c<= '`') || (c >= '{' && c<= '~')); -} diff --git a/Dump/hybos/lib/char/isspace.c b/Dump/hybos/lib/char/isspace.c deleted file mode 100644 index 29c6139..0000000 --- a/Dump/hybos/lib/char/isspace.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isspace(const char c) -{ - return (c == ' ' || (c >= 0x09 && c <= 0x0D)); -} diff --git a/Dump/hybos/lib/char/isupper.c b/Dump/hybos/lib/char/isupper.c deleted file mode 100644 index e54a05c..0000000 --- a/Dump/hybos/lib/char/isupper.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isupper(const char c) -{ - return (c >= 'A' && c <= 'Z'); -} diff --git a/Dump/hybos/lib/char/isxdigit.c b/Dump/hybos/lib/char/isxdigit.c deleted file mode 100644 index b67e005..0000000 --- a/Dump/hybos/lib/char/isxdigit.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -bool isxdigit(const char c) -{ - return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); -} diff --git a/Dump/hybos/lib/config/Makefile b/Dump/hybos/lib/config/Makefile deleted file mode 100644 index 2bd4b3d..0000000 --- a/Dump/hybos/lib/config/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -CONFIG =config.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(CONFIG) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\config.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -config.o: config.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/config/config.c b/Dump/hybos/lib/config/config.c deleted file mode 100644 index 3a46d5b..0000000 --- a/Dump/hybos/lib/config/config.c +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Compiler configuration - */ - -#ifdef __GNUC__ -#define COMPILER "GNU C Compiler " __VERSION__ -typedef enum {false = 0, true = !0} bool; -typedef unsigned size_t; -typedef signed char __int8; -typedef signed short int __int16; -typedef signed int __int32; -typedef signed long long int __int64; - -#define int8 __int8 -#define int16 __int16 -#define int32 __int32 -#define int64 __int64 - -typedef unsigned char uint8; -typedef unsigned short int uint16; -typedef unsigned int uint32; -typedef unsigned long long int uint64; - -#define uint8 __uint8 -#define uint16 __uint16 -#define uint32 __uint32 -#define uint64 __uint64 - -/*typedef void* pointer;*/ -/*typedef unsigned char string;*/ - -#define discardable -#else -#error "Compiler not supported" -#endif /* __GNUC__ */ - diff --git a/Dump/hybos/lib/convert/Makefile b/Dump/hybos/lib/convert/Makefile deleted file mode 100644 index a2a4409..0000000 --- a/Dump/hybos/lib/convert/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -CONVERT =atoi16.o \ - atoi32.o \ - atoi64.o \ - atoi.o \ - i16toa.o \ - i32toa.o \ - i64toa.o \ - itoa.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(CONVERT) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\atoi16.o - del ..\$(OBJ_DIR)\atoi32.o - del ..\$(OBJ_DIR)\atoi64.o - del ..\$(OBJ_DIR)\atoi.o - del ..\$(OBJ_DIR)\i16toa.o - del ..\$(OBJ_DIR)\i32toa.o - del ..\$(OBJ_DIR)\i64toa.o - del ..\$(OBJ_DIR)\itoa.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -atoi.o: atoi.c $(MAKEDEP) -itoa.o: itoa.c $(MAKEDEP) -atoi16.o: atoi16.c $(MAKEDEP) -atoi32.o: atoi32.c $(MAKEDEP) -atoi64.o: atoi64.c $(MAKEDEP) -i16toa.o: i16toa.c $(MAKEDEP) -i32toa.o: i32toa.c $(MAKEDEP) -i64toa.o: i64toa.c $(MAKEDEP) -u16toa.o: u16toa.c $(MAKEDEP) -u32toa.o: u32toa.c $(MAKEDEP) -u64toa.o: u64toa.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/convert/atoi.c b/Dump/hybos/lib/convert/atoi.c deleted file mode 100644 index 5a0ae8f..0000000 --- a/Dump/hybos/lib/convert/atoi.c +++ /dev/null @@ -1,33 +0,0 @@ -#include - -long atoi(const char *nptr) -{ - int c; /* current char */ - long total; /* current total */ - int sign; /* if '-', then negative, otherwise positive */ - - /* skip whitespace */ - while(isspace((int)(unsigned char)*nptr)) - ++nptr; - - c = (int)(unsigned char)*nptr++; - sign = c; /* save sign indication */ - - /* skip sign */ - if(c == '-' || c == '+') - c = (int)(unsigned char)*nptr++; - - total = 0; - - while(isdigit(c)) - { - total = 10 * total + (c - '0'); /* accumulate digit */ - c = (int)(unsigned char)*nptr++; /* get next char */ - } - - /* return result, negated if necessary */ - if(sign == '-') - return -total; - else - return total; -} diff --git a/Dump/hybos/lib/convert/atoi16.c b/Dump/hybos/lib/convert/atoi16.c deleted file mode 100644 index d3f5a12..0000000 --- a/Dump/hybos/lib/convert/atoi16.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Dump/hybos/lib/convert/atoi32.c b/Dump/hybos/lib/convert/atoi32.c deleted file mode 100644 index d3f5a12..0000000 --- a/Dump/hybos/lib/convert/atoi32.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Dump/hybos/lib/convert/atoi64.c b/Dump/hybos/lib/convert/atoi64.c deleted file mode 100644 index d3f5a12..0000000 --- a/Dump/hybos/lib/convert/atoi64.c +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Dump/hybos/lib/convert/i16toa.c b/Dump/hybos/lib/convert/i16toa.c deleted file mode 100644 index ed88e45..0000000 --- a/Dump/hybos/lib/convert/i16toa.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -void i16toa(int16_t value, char *string, uint8_t radix) -{ - char *i, *s, t, d; - - i = string; - - if(value < 0) - { - *i++ = '-'; - value = -value; - } - - s = i; - - do - { - d = value % radix; - value /= radix; - - if(d > 9) - *i++ = d + 'A' - 10; - else - *i++ = d + '0'; - } while (value > 0); - - *i-- = '\0'; - - do - { - t = *i; - *i = *s; - *s = t; - - --i; - ++s; - } while (s < i); -} diff --git a/Dump/hybos/lib/convert/i32toa.c b/Dump/hybos/lib/convert/i32toa.c deleted file mode 100644 index c8115ea..0000000 --- a/Dump/hybos/lib/convert/i32toa.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -void i32toa(int32_t value, char *string, uint8_t radix) -{ - char *i, *s, t, d; - - i = string; - - if(value < 0) - { - *i++ = '-'; - value = -value; - } - - s = i; - - do - { - d = value % radix; - value /= radix; - - if (d > 9) - *i++ = d + 'A' - 10; - else - *i++ = d + '0'; - } while (value > 0); - - *i-- = '\0'; - - do - { - t = *i; - *i = *s; - *s = t; - - --i; - ++s; - } while (s < i); -} diff --git a/Dump/hybos/lib/convert/i64toa.c b/Dump/hybos/lib/convert/i64toa.c deleted file mode 100644 index e75aa87..0000000 --- a/Dump/hybos/lib/convert/i64toa.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -void i64toa(int64_t value, char *string, uint8_t radix) -{ - char *i, *s, t, d; - - i = string; - - if(value < 0) - { - *i++ = '-'; - value = -value; - } - - s = i; - - do - { - d = value % radix; - value /= radix; - - if(d > 9) - *i++ = d + 'A' - 10; - else - *i++ = d + '0'; - } while (value > 0); - - *i-- = '\0'; - - do - { - t = *i; - *i = *s; - *s = t; - - --i; - ++s; - } while (s < i); -} diff --git a/Dump/hybos/lib/convert/itoa.c b/Dump/hybos/lib/convert/itoa.c deleted file mode 100644 index 3fc6ce7..0000000 --- a/Dump/hybos/lib/convert/itoa.c +++ /dev/null @@ -1,104 +0,0 @@ -/*** -*xtoa.c - convert integers/longs to ASCII string -* -* Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* The module has code to convert integers/longs to ASCII strings. See -* -*******************************************************************************/ - - -/*** -*char *_itoa, *_ltoa, *_ultoa(val, buf, radix) - convert binary int to ASCII -* string -* -*Purpose: -* Converts an int to a character string. -* -*Entry: -* val - number to be converted (int, long or unsigned long) -* int radix - base to convert into -* char *buf - ptr to buffer to place result -* -*Exit: -* fills in space pointed to by buf with string result -* returns a pointer to this buffer -* -*Exceptions: -* -*******************************************************************************/ - -/* helper routine that does the main job. */ - -static void xtoa(unsigned long val, char *buf, unsigned radix, int is_neg) -{ - char *p; /* pointer to traverse string */ - char *firstdig; /* pointer to first digit */ - char temp; /* temp char */ - unsigned digval; /* value of digit */ - - p = buf; - - if(is_neg) - { - /* negative, so output '-' and negate */ - *p++ = '-'; - val = (unsigned long)(-(long)val); - } - - firstdig = p; /* save pointer to first digit */ - - do - { - digval = (unsigned) (val % radix); - val /= radix; /* get next digit */ - - /* convert to ascii and store */ - if (digval > 9) - *p++ = (char) (digval - 10 + 'a'); /* a letter */ - else - *p++ = (char) (digval + '0'); /* a digit */ - } while (val > 0); - - /** - * We now have the digit of the number in the buffer, but in reverse - * order. Thus we reverse them now. - */ - - *p-- = '\0'; /* terminate string; p points to last digit */ - - do - { - temp = *p; - *p = *firstdig; - *firstdig = temp; /* swap *p and *firstdig */ - --p; - ++firstdig; /* advance to next two digits */ - } while (firstdig < p); /* repeat until halfway */ -} - -/** - * Actual functions just call conversion helper with neg flag set correctly, - * and return pointer to buffer. - */ -char * _itoa(int val, char *buf, int radix) -{ - if(radix == 10 && val < 0) - xtoa((unsigned long)val, buf, radix, 1); - else - xtoa((unsigned long)(unsigned int)val, buf, radix, 0); - return buf; -} - -char * _ltoa(long val, char *buf, int radix) -{ - xtoa((unsigned long)val, buf, radix, (radix == 10 && val < 0)); - return buf; -} - -char * _ultoa(unsigned long val, char *buf, int radix) -{ - xtoa(val, buf, radix, 0); - return buf; -} diff --git a/Dump/hybos/lib/convert/u16toa.c b/Dump/hybos/lib/convert/u16toa.c deleted file mode 100644 index 4998340..0000000 --- a/Dump/hybos/lib/convert/u16toa.c +++ /dev/null @@ -1,29 +0,0 @@ -void u16toa(unt16 value, char *string, unt8 radix) -{ - char *i, *s, t, d; - - s = i = string; - - do - { - d = value % radix; - value /= radix; - - if(d > 9) - *i++ = d + 'A' - 10; - else - *i++ = d + '0'; - } while (value > 0); - - *i-- = '\0'; - - do - { - t = *i; - *i = *s; - *s = t; - - --i; - ++s; - } while (s < i); -} diff --git a/Dump/hybos/lib/convert/u32toa.c b/Dump/hybos/lib/convert/u32toa.c deleted file mode 100644 index 3145cd8..0000000 --- a/Dump/hybos/lib/convert/u32toa.c +++ /dev/null @@ -1,29 +0,0 @@ -void u32toa(unt32 value, char *string, unt8 radix) -{ - char *i, *s, t, d; - - s = i = string; - - do - { - d = value % radix; - value /= radix; - - if(d > 9) - *i++ = d + 'A' - 10; - else - *i++ = d + '0'; - } while (value > 0); - - *i-- = '\0'; - - do - { - t = *i; - *i = *s; - *s = t; - - --i; - ++s; - } while (s < i); -} diff --git a/Dump/hybos/lib/convert/u64toa.c b/Dump/hybos/lib/convert/u64toa.c deleted file mode 100644 index 9ec5fa1..0000000 --- a/Dump/hybos/lib/convert/u64toa.c +++ /dev/null @@ -1,29 +0,0 @@ -void u64toa(unt64 value, char *string, unt8 radix) -{ - char *i, *s, t, d; - - s = i = string; - - do - { - d = value % radix; - value /= radix; - - if(d > 9) - *i++ = d + 'A' - 10; - else - *i++ = d + '0'; - } while (value > 0); - - *i-- = '\0'; - - do - { - t = *i; - *i = *s; - *s = t; - - --i; - ++s; - } while (s < i); -} diff --git a/Dump/hybos/lib/ctype/Makefile b/Dump/hybos/lib/ctype/Makefile deleted file mode 100644 index 5f7fddd..0000000 --- a/Dump/hybos/lib/ctype/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -CTYPE =ctype.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(CTYPE) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\ctype.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -ctype.o: ctype.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/ctype/ctype.c b/Dump/hybos/lib/ctype/ctype.c deleted file mode 100644 index acf64e3..0000000 --- a/Dump/hybos/lib/ctype/ctype.c +++ /dev/null @@ -1,46 +0,0 @@ -#include - -char _ctype[] = -{ - 0x00, -/* 0 */ CT_CTL, CT_CTL, CT_CTL, CT_CTL, - CT_CTL, CT_CTL, CT_CTL, CT_CTL, -/* 8 */ CT_CTL, CT_CTL | CT_WHT, CT_CTL | CT_WHT, CT_CTL | CT_WHT, - CT_CTL | CT_WHT, CT_CTL | CT_WHT, CT_CTL, CT_CTL, -/* 16 */CT_CTL, CT_CTL, CT_CTL, CT_CTL, - CT_CTL, CT_CTL, CT_CTL, CT_CTL, -/* 24 */CT_CTL, CT_CTL, CT_CTL, CT_CTL, - CT_CTL, CT_CTL, CT_CTL, CT_CTL, -/* ' ' */CT_WHT | CT_SP, CT_PUN, CT_PUN, CT_PUN, - CT_PUN, CT_PUN, CT_PUN, CT_PUN, -/* '(' */CT_PUN, CT_PUN, CT_PUN, CT_PUN, - CT_PUN, CT_PUN, CT_PUN, CT_PUN, -/* '0' */CT_DIG, CT_DIG, CT_DIG, CT_DIG, - CT_DIG, CT_DIG, CT_DIG, CT_DIG, -/* '8' */CT_DIG, CT_DIG, CT_PUN, CT_PUN, - CT_PUN, CT_PUN, CT_PUN, CT_PUN, -/* '@' */CT_PUN, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP | CT_HEX, - CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP | CT_HEX, CT_UP, -/* 'H' */CT_UP, CT_UP, CT_UP, CT_UP, - CT_UP, CT_UP, CT_UP, CT_UP, -/* 'P' */CT_UP, CT_UP, CT_UP, CT_UP, - CT_UP, CT_UP, CT_UP, CT_UP, -/* 'X' */CT_UP, CT_UP, CT_UP, CT_PUN, - CT_PUN, CT_PUN, CT_PUN, CT_PUN, -/* '`' */CT_PUN, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, - CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW | CT_HEX, CT_LOW, -/* h' */CT_LOW, CT_LOW, CT_LOW, CT_LOW, - CT_LOW, CT_LOW, CT_LOW, CT_LOW, -/* 'p' */CT_LOW, CT_LOW, CT_LOW, CT_LOW, - CT_LOW, CT_LOW, CT_LOW, CT_LOW, -/* 'x' */CT_LOW, CT_LOW, CT_LOW, CT_PUN, - CT_PUN, CT_PUN, CT_PUN, CT_CTL, -/* 128 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 144 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 160 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 176 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 192 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 208 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 224 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/* 240 */0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; diff --git a/Dump/hybos/lib/libc.a b/Dump/hybos/lib/libc.a deleted file mode 100644 index 68b8fcb..0000000 --- a/Dump/hybos/lib/libc.a +++ /dev/null Binary files differ diff --git a/Dump/hybos/lib/math/Makefile b/Dump/hybos/lib/math/Makefile deleted file mode 100644 index 9e7bf8e..0000000 --- a/Dump/hybos/lib/math/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -MATH =abs.o \ - max.o \ - min.o \ - rotl.o \ - rotr.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(MATH) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\abs.o - del ..\$(OBJ_DIR)\max.o - del ..\$(OBJ_DIR)\min.o - del ..\$(OBJ_DIR)\rotl.o - del ..\$(OBJ_DIR)\rotr.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -abs.o: abs.c $(MAKEDEP) -max.o: max.c $(MAKEDEP) -min.o: min.c $(MAKEDEP) -rotl.o: rotl.c $(MAKEDEP) -rotr.o: rotr.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/math/abs.c b/Dump/hybos/lib/math/abs.c deleted file mode 100644 index adf8157..0000000 --- a/Dump/hybos/lib/math/abs.c +++ /dev/null @@ -1,32 +0,0 @@ -/*** -*abs.c - find absolute value -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines abs() - find the absolute value of an int. -* -*******************************************************************************/ - - -/*** -*int abs(number) - find absolute value of number -* -*Purpose: -* Returns the absolute value of number (if number >= 0, returns number, -* else returns -number). -* -*Entry: -* int number - number to find absolute value of -* -*Exit: -* returns the aboslute value of number -* -*Exceptions: -* -*******************************************************************************/ - -int abs(int number) -{ - return( number>=0 ? number : -number ); -} diff --git a/Dump/hybos/lib/math/max.c b/Dump/hybos/lib/math/max.c deleted file mode 100644 index 869833a..0000000 --- a/Dump/hybos/lib/math/max.c +++ /dev/null @@ -1,4 +0,0 @@ -int max(int a, int b) -{ - return (a > b) ? a : b; -} diff --git a/Dump/hybos/lib/math/min.c b/Dump/hybos/lib/math/min.c deleted file mode 100644 index 10d4dc5..0000000 --- a/Dump/hybos/lib/math/min.c +++ /dev/null @@ -1,4 +0,0 @@ -int min(int a, int b) -{ - return (a < b) ? a : b; -} diff --git a/Dump/hybos/lib/math/rotl.c b/Dump/hybos/lib/math/rotl.c deleted file mode 100644 index 8981329..0000000 --- a/Dump/hybos/lib/math/rotl.c +++ /dev/null @@ -1,49 +0,0 @@ -/*** -*rotl.c - rotate an unsigned integer left -* -* Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines _rotl() - performs a rotate left on an unsigned integer. -* -*******************************************************************************/ - - -/*** -*unsigned _rotl(val, shift) - int rotate left -* -*Purpose: -* Performs a rotate left on an unsigned integer. -* -* [Note: The _lrotl entry is based on the assumption -* that sizeof(int) == sizeof(long).] -*Entry: -* unsigned val: value to rotate -* int shift: number of bits to shift by -* -*Exit: -* returns rotated value -* -*Exceptions: -* None. -* -*******************************************************************************/ - -unsigned rotl(unsigned val, int shift) -{ - register unsigned hibit; /* non-zero means hi bit set */ - register unsigned num = val; /* number to rotate */ - - shift &= 0x1f; /* modulo 32 -- this will also make - negative shifts work */ - - while(shift--) - { - hibit = num & 0x80000000; /* get high bit */ - num <<= 1; /* shift left one bit */ - if(hibit) - num |= 1; /* set lo bit if hi bit was set */ - } - - return num; -} diff --git a/Dump/hybos/lib/math/rotr.c b/Dump/hybos/lib/math/rotr.c deleted file mode 100644 index 10247ff..0000000 --- a/Dump/hybos/lib/math/rotr.c +++ /dev/null @@ -1,52 +0,0 @@ -/*** -*rotr.c - rotate an unsigned integer right -* -* Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines _rotr() - performs a rotate right on an unsigned integer. -* -*******************************************************************************/ - - - - -/*** -*unsigned _rotr(val, shift) - int rotate right -* -*Purpose: -* Performs a rotate right on an unsigned integer. -* -* [Note: The _lrotl entry is based on the assumption -* that sizeof(int) == sizeof(long).] -*Entry: -* unsigned val: value to rotate -* int shift: number of bits to shift by -* -*Exit: -* returns rotated value -* -*Exceptions: -* None. -* -*******************************************************************************/ - - -unsigned rotr(unsigned val, int shift) -{ - register unsigned lobit; /* non-zero means lo bit set */ - register unsigned num = val; /* number to rotate */ - - shift &= 0x1f; /* modulo 32 -- this will also make - negative shifts work */ - - while(shift--) - { - lobit = num & 1; /* get high bit */ - num >>= 1; /* shift right one bit */ - if(lobit) - num |= 0x80000000; /* set hi bit if lo bit was set */ - } - - return num; -} diff --git a/Dump/hybos/lib/mem/Makefile b/Dump/hybos/lib/mem/Makefile deleted file mode 100644 index 0cdbee4..0000000 --- a/Dump/hybos/lib/mem/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -MEM =memccpy.o \ - memchr.o \ - memcmp.o \ - memcpy.o \ - memcpybw.o \ - memicmp.o \ - memmove.o \ - memset.o \ - memsetw.o \ - swab.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(MEM) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\memccpy.o - del ..\$(OBJ_DIR)\memchr.o - del ..\$(OBJ_DIR)\memcmp.o - del ..\$(OBJ_DIR)\memcpy.o - del ..\$(OBJ_DIR)\memcpybw.o - del ..\$(OBJ_DIR)\memicmp.o - del ..\$(OBJ_DIR)\memmove.o - del ..\$(OBJ_DIR)\memset.o - del ..\$(OBJ_DIR)\memsetw.o - del ..\$(OBJ_DIR)\swab.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -memccpy.o: memccpy.c $(MAKEDEP) -memchr.o: memchr.c $(MAKEDEP) -memcmp.o: memcmp.c $(MAKEDEP) -memcpy.o: memcpy.c $(MAKEDEP) -memcpybw.o: memcpybw.c $(MAKEDEP) -memicmp.o: memicmp.c $(MAKEDEP) -memmove.o: memmove.c $(MAKEDEP) -memset.o: memset.c $(MAKEDEP) -memsetw.o: memsetw.c $(MAKEDEP) -swab.o: swab.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/mem/memccpy.c b/Dump/hybos/lib/mem/memccpy.c deleted file mode 100644 index 287057b..0000000 --- a/Dump/hybos/lib/mem/memccpy.c +++ /dev/null @@ -1,41 +0,0 @@ -/*** -*memccpy.c - copy bytes until a character is found -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines _memccpy() - copies bytes until a specifed character -* is found, or a maximum number of characters have been copied. -* -*******************************************************************************/ - - -/*** -*char *_memccpy(dest, src, c, count) - copy bytes until character found -* -*Purpose: -* Copies bytes from src to dest until count bytes have been -* copied, or up to and including the character c, whichever -* comes first. -* -*Entry: -* void *dest - pointer to memory to receive copy -* void *src - source of bytes -* int c - character to stop copy at -* unsigned int count - max number of bytes to copy -* -*Exit: -* returns pointer to byte immediately after c in dest -* returns NULL if c was never found -* -*Exceptions: -* -*******************************************************************************/ - -void *memccpy(void *dest, const void *src, int c, unsigned count) -{ - while(count && (*((char *)(dest = (char *)dest + 1) - 1) = *((char *)(src = (char *)src + 1) - 1)) != (char)c ) - count--; - - return count ? dest : 0; -} diff --git a/Dump/hybos/lib/mem/memchr.c b/Dump/hybos/lib/mem/memchr.c deleted file mode 100644 index ccf6e3b..0000000 --- a/Dump/hybos/lib/mem/memchr.c +++ /dev/null @@ -1,43 +0,0 @@ -/*** -*memchr.c - search block of memory for a given character -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines memchr() - search memory until a character is -* found or a limit is reached. -* -*******************************************************************************/ - - -/*** -*char *memchr(buf, chr, cnt) - search memory for given character. -* -*Purpose: -* Searches at buf for the given character, stopping when chr is -* first found or cnt bytes have been searched through. -* -*Entry: -* void *buf - memory buffer to be searched -* int chr - character to search for -* size_t cnt - max number of bytes to search -* -*Exit: -* returns pointer to first occurence of chr in buf -* returns NULL if chr not found in the first cnt bytes -* -*Exceptions: -* -*******************************************************************************/ -#include <_size_t.h> - -void *memchr(const void * buf, int chr, size_t cnt) -{ - while( cnt && (*(unsigned char *)buf != (unsigned char)chr)) - { - buf = (unsigned char *)buf + 1; - cnt--; - } - - return cnt ? (void *)buf : 0; -} diff --git a/Dump/hybos/lib/mem/memcmp.c b/Dump/hybos/lib/mem/memcmp.c deleted file mode 100644 index f4d498d..0000000 --- a/Dump/hybos/lib/mem/memcmp.c +++ /dev/null @@ -1,46 +0,0 @@ -/*** -*memcmp.c - compare two blocks of memory -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines memcmp() - compare two memory blocks lexically and -* find their order. -* -*******************************************************************************/ - - -/*** -*int memcmp(buf1, buf2, count) - compare memory for lexical order -* -*Purpose: -* Compares count bytes of memory starting at buf1 and buf2 -* and find if equal or which one is first in lexical order. -* -*Entry: -* void *buf1, *buf2 - pointers to memory sections to compare -* size_t count - length of sections to compare -* -*Exit: -* returns < 0 if buf1 < buf2 -* returns 0 if buf1 == buf2 -* returns > 0 if buf1 > buf2 -* -*Exceptions: -* -*******************************************************************************/ -#include <_size_t.h> - -int memcmp(const void *buf1, const void *buf2, size_t count) -{ - if(!count) - return(0); - - while(--count && *(char *)buf1 == *(char *)buf2) - { - buf1 = (char *)buf1 + 1; - buf2 = (char *)buf2 + 1; - } - - return *((unsigned char *)buf1) - *((unsigned char *)buf2); -} diff --git a/Dump/hybos/lib/mem/memcpy.c b/Dump/hybos/lib/mem/memcpy.c deleted file mode 100644 index bb86792..0000000 --- a/Dump/hybos/lib/mem/memcpy.c +++ /dev/null @@ -1,13 +0,0 @@ -void *memcpy(void *s, const void *t, unsigned n) -{ - void *ret = s; - - while(n--) - { - *(char *)s = *(char *)t; - s = (char *)s + 1; - t = (char *)t + 1; - } - - return ret; -} diff --git a/Dump/hybos/lib/mem/memcpybw.c b/Dump/hybos/lib/mem/memcpybw.c deleted file mode 100644 index 3db51f3..0000000 --- a/Dump/hybos/lib/mem/memcpybw.c +++ /dev/null @@ -1,13 +0,0 @@ -void *memcpybw(void *s, void *t, unsigned n) -{ - void *ret = s; - - while(n--) - { - *(char *)s = *(char *)t; - s = (char *)s + 2; - t = (char *)t + 1; - } - - return ret; -} diff --git a/Dump/hybos/lib/mem/memicmp.c b/Dump/hybos/lib/mem/memicmp.c deleted file mode 100644 index 74f2888..0000000 --- a/Dump/hybos/lib/mem/memicmp.c +++ /dev/null @@ -1,58 +0,0 @@ -/*** -*memicmp.c - compare memory, ignore case -* -* Copyright (c) 1988-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines _memicmp() - compare two blocks of memory for lexical -* order. Case is ignored in the comparison. -* -*******************************************************************************/ - - -#define _TOLOWER(c) ( ((c) >= 'A') && ((c) <= 'Z') ? ((c) - 'A' + 'a') :\ - (c) ) - -/*** -*int _memicmp(first, last, count) - compare two blocks of memory, ignore case -* -*Purpose: -* Compares count bytes of the two blocks of memory stored at first -* and last. The characters are converted to lowercase before -* comparing (not permanently), so case is ignored in the search. -* -*Entry: -* char *first, *last - memory buffers to compare -* unsigned count - maximum length to compare -* -*Exit: -* returns < 0 if first < last -* returns 0 if first == last -* returns > 0 if first > last -* -*Uses: -* -*Exceptions: -* -*******************************************************************************/ - -int _memicmp(const void * first, const void * last, unsigned int count) -{ - int f = 0; - int l = 0; - - while(count--) - { - if((*(unsigned char *)first == *(unsigned char *)last) || - ((f = _TOLOWER( *(unsigned char *)first)) == - (l = _TOLOWER( *(unsigned char *)last)))) - { - first = (char *)first + 1; - last = (char *)last + 1; - } - else - break; - } - - return (f - l); -} diff --git a/Dump/hybos/lib/mem/memmove.c b/Dump/hybos/lib/mem/memmove.c deleted file mode 100644 index 8c0266a..0000000 --- a/Dump/hybos/lib/mem/memmove.c +++ /dev/null @@ -1,68 +0,0 @@ -/*** -*memmove.c - contains memmove routine -* -* Copyright (c) 1988-1997, Microsoft Corporation. All right reserved. -* -*Purpose: -* memmove() copies a source memory buffer to a destination buffer. -* Overlapping buffers are treated specially, to avoid propogation. -* -*******************************************************************************/ - -/*** -*memmove - Copy source buffer to destination buffer -* -*Purpose: -* memmove() copies a source memory buffer to a destination memory buffer. -* This routine recognize overlapping buffers to avoid propogation. -* For cases where propogation is not a problem, memcpy() can be used. -* -*Entry: -* void *dst = pointer to destination buffer -* const void *src = pointer to source buffer -* size_t count = number of bytes to copy -* -*Exit: -* Returns a pointer to the destination buffer -* -*Exceptions: -*******************************************************************************/ -#include <_size_t.h> - -void *memmove(void *dst, const void *src, size_t count) -{ - void *ret = dst; - - - if(dst <= src || (char *)dst >= ((char *)src + count)) - { - /* - * Non-Overlapping Buffers - * copy from lower addresses to higher addresses - */ - while(count--) - { - *(char *)dst = *(char *)src; - dst = (char *)dst + 1; - src = (char *)src + 1; - } - } - else - { - /* - * Overlapping Buffers - * copy from higher addresses to lower addresses - */ - dst = (char *)dst + count - 1; - src = (char *)src + count - 1; - - while(count--) - { - *(char *)dst = *(char *)src; - dst = (char *)dst - 1; - src = (char *)src - 1; - } - } - - return ret; -} diff --git a/Dump/hybos/lib/mem/memset.c b/Dump/hybos/lib/mem/memset.c deleted file mode 100644 index 0dfd884..0000000 --- a/Dump/hybos/lib/mem/memset.c +++ /dev/null @@ -1,12 +0,0 @@ -void *memset(void *s, int i, unsigned n) -{ - void *start = s; - - while(n--) - { - *(char *)s = (char)i; - s = (char *)s + 1; - } - - return start; -} diff --git a/Dump/hybos/lib/mem/memsetw.c b/Dump/hybos/lib/mem/memsetw.c deleted file mode 100644 index a81ad7a..0000000 --- a/Dump/hybos/lib/mem/memsetw.c +++ /dev/null @@ -1,13 +0,0 @@ - -void *memsetw(void *s, short i, unsigned n) -{ - void *start = s; - - while(n--) - { - *(short *)s = (short)i; - s = (short *)s + 1; - } - - return(start); -} diff --git a/Dump/hybos/lib/mem/swab.c b/Dump/hybos/lib/mem/swab.c deleted file mode 100644 index 3220a4a..0000000 --- a/Dump/hybos/lib/mem/swab.c +++ /dev/null @@ -1,44 +0,0 @@ -/*** -*swab.c - block copy, while swapping even/odd bytes -* -* Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* This module contains the routine _swab() which swaps the odd/even -* bytes of words during a block copy. -* -*******************************************************************************/ - -/*** -*void _swab(srcptr, dstptr, nbytes) - swap ODD/EVEN bytes during word move -* -*Purpose: -* This routine copys a block of words and swaps the odd and even -* bytes. nbytes must be > 0, otherwise nothing is copied. If -* nbytes is odd, then only (nbytes-1) bytes are copied. -* -*Entry: -* srcptr = pointer to the source block -* dstptr = pointer to the destination block -* nbytes = number of bytes to swap -* -*Returns: -* None. -* -*Exceptions: -* -*******************************************************************************/ - -void swab(char *src, char *dest, int nbytes) -{ - char b1, b2; - - while(nbytes > 1) - { - b1 = *src++; - b2 = *src++; - *dest++ = b2; - *dest++ = b1; - nbytes -= 2; - } -} diff --git a/Dump/hybos/lib/setjmp/Makefile b/Dump/hybos/lib/setjmp/Makefile deleted file mode 100644 index 258ee28..0000000 --- a/Dump/hybos/lib/setjmp/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -SETJMP =longjmp.o \ - setjmp.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(SETJMP) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\longjmp.o - del ..\$(OBJ_DIR)\setjmp.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -setjmp.o: setjmp.asm $(MAKEDEP) -longjmp.o: longjmp.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/setjmp/longjmp.c b/Dump/hybos/lib/setjmp/longjmp.c deleted file mode 100644 index af06310..0000000 --- a/Dump/hybos/lib/setjmp/longjmp.c +++ /dev/null @@ -1,78 +0,0 @@ -#include /* jmp_buf */ -/***************************************************************************** -To use setjmp() and longjmp() for asynchronous (interrupt-driven; -pre-emptive) task-switching, we want to enable interrupts simultaneous -with jumping to the task. In other words, we want the EFLAGS and EIP -registers loaded at the same time. - -The only instruction that can do this is IRET, which also loads the CS -register. Changing CS is done in code that uses far pointers, and it's -also done when changing address spaces, and when changing privilege levels. -We're not interested in any of those, so just push the current CS value -on the stack and let IRET use that. - -Three distinct stack pointer (ESP) values are used in this routine: -- 'Old' or 'current' stack pointer value, which is discarded by - this routine (use setjmp() to save it) -- ESP is made to point, briefly, to the jmp_buf struct itself -- 'New' ESP value; stored in jmp_buf.esp - -Register values are restored from the jmp_buf as follows: -1. Push jmp_buf.eflags, the current CS value, and jmp_buf.eip - onto the 'new' stack -2. Make ESP point to the jmp_buf struct itself, then use the POPA - instruction to pop the 7 general purpose registers (ESP is not - loaded by POPA). The use of POPA means that registers in the - jmp_buf MUST be stored in the order that POPA expects. - (Maybe use MOVs instead, to eliminate this restriction? - Might have to rewrite entire function in asm, instead of C.) -3. Load ESP with the 'new' stack pointer, from jmp_buf.esp -4. Use IRET to pop EIP, CS, and EFLAGS from the 'new' stack -5. ??? -6. Profit! <--- obligatory Slashdot joke - -This code does NOT save the floating-point state of the CPU. Either: -1. Don't use floating point, or -2. Don't use floating point in more than one thread, or -3. Rewrite this code so it DOES save the floating-point state, or -4. Save/restore the floating-point state when entering/leaving - the kernel (protected OS only) -*****************************************************************************/ -void longjmp(jmp_buf buf, int ret_val) -{ - unsigned *esp; - -/* make sure return value is not 0 */ - if(ret_val == 0) - ret_val++; -/* EAX is used for return values, so store it in jmp_buf.EAX */ - buf->eax = ret_val; -/* get ESP for new stack */ - esp = (unsigned *)buf->esp; -/* push EFLAGS on the new stack */ - esp--; - *esp = buf->eflags; -/* push current CS on the new stack */ - esp--; - __asm__ __volatile__( - "mov %%cs,%0\n" - : "=m"(*esp)); -/* push EIP on the new stack */ - esp--; - *esp = buf->eip; -/* new ESP is 12 bytes lower; update jmp_buf.ESP */ - buf->esp = (unsigned)esp; -/* now, briefly, make the jmp_buf struct our stack */ - __asm__ __volatile__( - "movl %0,%%esp\n" -/* ESP now points to 8 general-purpose registers stored in jmp_buf -Pop them */ - "popa\n" -/* load new stack pointer from jmp_buf */ - "movl -20(%%esp),%%esp\n" -/* ESP now points to new stack, with the IRET frame (EIP, CS, EFLAGS) -we created just above. Pop these registers: */ - "iret\n" - : - : "m"(buf)); -} diff --git a/Dump/hybos/lib/setjmp/setjmp.asm b/Dump/hybos/lib/setjmp/setjmp.asm deleted file mode 100644 index dc0ae60..0000000 --- a/Dump/hybos/lib/setjmp/setjmp.asm +++ /dev/null @@ -1,35 +0,0 @@ -%include "asm.inc" - -SECTION .text - -EXP setjmp - push ebx - mov ebx,[8 + esp] - - mov [0 + ebx],edi ; buf->edi == 0(ebx) == EDI - mov [4 + ebx],esi ; buf->esi == 4(ebx) == ESI - mov [8 + ebx],ebp ; buf->ebp == 8(ebx) == EBP - - mov [20 + ebx],edx ; buf->edx == 20(ebx) == EDX - mov [24 + ebx],ecx ; buf->ecx == 24(ebx) == ECX - mov [28 + ebx],eax ; buf->eax == 28(ebx) == EAX - -; use EBX value saved on stack; not the current value - mov eax,[esp] - mov [16 + ebx],eax ; buf->ebx == 16(ebx) == EBX - -; use ESP value after RET; not the current value - lea eax,[8 + esp] - mov [12 + ebx],eax ; buf->esp == 32(ebx) == ESP - -; use return address of this routine (EIP value saved on stack); -; not the current value - mov eax,[4 + esp] - mov [32 + ebx],eax ; buf->eip == 36(ebx) == EIP - -; none of the PUSH or MOV instructions changed EFLAGS! - pushf - pop dword [36 + ebx] ; buf->eflags == 40(ebx) == EFLAGS - pop ebx - xor eax,eax - ret diff --git a/Dump/hybos/lib/stdio/.doprintf.c.swp b/Dump/hybos/lib/stdio/.doprintf.c.swp deleted file mode 100644 index 7956be6..0000000 --- a/Dump/hybos/lib/stdio/.doprintf.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/lib/stdio/Makefile b/Dump/hybos/lib/stdio/Makefile deleted file mode 100644 index 4d6994b..0000000 --- a/Dump/hybos/lib/stdio/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -STDIO =doprintf.o \ - sprintf.o \ - printf.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(STDIO) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\doprintf.o - del ..\$(OBJ_DIR)\sprintf.o - del ..\$(OBJ_DIR)\printf.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -doprintf.o: doprintf.c $(MAKEDEP) -sprintf.o: sprintf.c $(MAKEDEP) -printf.o: printf.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/stdio/doprintf.c b/Dump/hybos/lib/stdio/doprintf.c deleted file mode 100644 index dc9e8ac..0000000 --- a/Dump/hybos/lib/stdio/doprintf.c +++ /dev/null @@ -1,357 +0,0 @@ -#include <_printf.h> /* fnptr_t */ -#include /* strlen() */ -#include /* va_list, va_arg() */ -/***************************************************************************** -Revised Jan 28, 2002 -- changes to make characters 0x80-0xFF display properly - -Revised June 10, 2001 -- changes to make vsprintf() terminate string with '\0' - -Revised May 12, 2000 -- math in DO_NUM is now unsigned, as it should be -- %0 flag (pad left with zeroes) now works -- actually did some TESTING, maybe fixed some other bugs - - name: do_printf - action: minimal subfunction for ?printf, calls function - 'fn' with arg 'ptr' for each character to be output - returns:total number of characters output - - %[flag][width][.prec][mod][conv] - flag: - left justify, pad right w/ blanks DONE - 0 pad left w/ 0 for numerics DONE - + always print sign, + or - no - ' ' (blank) no - # (???) no - - width: (field width) DONE - - prec: (precision) no - - conv: d,i decimal int DONE - u decimal unsigned DONE - o octal DONE - x,X hex DONE - f,e,g,E,G float no - c char DONE - s string DONE - p ptr DONE - - mod: N near ptr DONE - F far ptr no - h short (16-bit) int DONE - l long (32-bit) int DONE - L long long (64-bit) int no -*****************************************************************************/ -/* flags used in processing format string */ -#define PR_LJ 0x01 /* left justify */ -#define PR_CA 0x02 /* use A-F instead of a-f for hex */ -#define PR_SG 0x04 /* signed numeric conversion (%d vs. %u) */ -#define PR_32 0x08 /* long (32-bit) numeric conversion */ -#define PR_16 0x10 /* short (16-bit) numeric conversion */ -#define PR_WS 0x20 /* PR_SG set and num was < 0 */ -#define PR_LZ 0x40 /* pad left with '0' instead of ' ' */ -#define PR_FP 0x80 /* pointers are far */ - -/* largest number handled is 2^32-1, lowest radix handled is 8. -2^32-1 in base 8 has 11 digits (add 5 for trailing NUL and for slop) */ -#define PR_BUFLEN 16 - -int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr) -{ - unsigned state, flags, radix, actual_wd, count, given_wd; - unsigned char *where, buf[PR_BUFLEN]; - long num; - - state = flags = count = given_wd = 0; -/* begin scanning format specifier list */ - for(; *fmt; fmt++) - { - switch(state) - { -/* STATE 0: AWAITING % */ - case 0: - if(*fmt != '%') /* not %... */ - { - fn(*fmt, &ptr); /* ...just echo it */ - count++; - break; - } -/* found %, get next char and advance state to check if next char is a flag */ - state++; - fmt++; - /* FALL THROUGH */ -/* STATE 1: AWAITING FLAGS (%-0) */ - case 1: - if(*fmt == '%') /* %% */ - { - fn(*fmt, &ptr); - count++; - state = flags = given_wd = 0; - break; - } - if(*fmt == '-') - { - if(flags & PR_LJ)/* %-- is illegal */ - state = flags = given_wd = 0; - else - flags |= PR_LJ; - break; - } -/* not a flag char: advance state to check if it's field width */ - state++; -/* check now for '%0...' */ - if(*fmt == '0') - { - flags |= PR_LZ; - fmt++; - } - /* FALL THROUGH */ -/* STATE 2: AWAITING (NUMERIC) FIELD WIDTH */ - case 2: - if(*fmt >= '0' && *fmt <= '9') - { - given_wd = 10 * given_wd + - (*fmt - '0'); - break; - } -/* not field width: advance state to check if it's a modifier */ - state++; - /* FALL THROUGH */ -/* STATE 3: AWAITING MODIFIER CHARS (FNlh) */ - case 3: - if(*fmt == 'F') - { - flags |= PR_FP; - break; - } - if(*fmt == 'N') - break; - if(*fmt == 'l') - { - flags |= PR_32; - break; - } - if(*fmt == 'h') - { - flags |= PR_16; - break; - } -/* not modifier: advance state to check if it's a conversion char */ - state++; - /* FALL THROUGH */ -/* STATE 4: AWAITING CONVERSION CHARS (Xxpndiuocs) */ - case 4: - where = buf + PR_BUFLEN - 1; - *where = '\0'; - switch(*fmt) - { - case 'X': - flags |= PR_CA; - /* FALL THROUGH */ -/* xxx - far pointers (%Fp, %Fn) not yet supported */ - case 'x': - case 'p': - case 'n': - radix = 16; - goto DO_NUM; - case 'd': - case 'i': - flags |= PR_SG; - /* FALL THROUGH */ - case 'u': - radix = 10; - goto DO_NUM; - case 'o': - radix = 8; -/* load the value to be printed. l=long=32 bits: */ -DO_NUM: if(flags & PR_32) - num = va_arg(args, unsigned long); -/* h=short=16 bits (signed or unsigned) */ - else if(flags & PR_16) - { - if(flags & PR_SG) - num = va_arg(args, short); - else - num = va_arg(args, unsigned short); - } -/* no h nor l: sizeof(int) bits (signed or unsigned) */ - else - { - if(flags & PR_SG) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } -/* take care of sign */ - if(flags & PR_SG) - { - if(num < 0) - { - flags |= PR_WS; - num = -num; - } - } -/* convert binary to octal/decimal/hex ASCII -OK, I found my mistake. The math here is _always_ unsigned */ - do - { - unsigned long temp; - - temp = (unsigned long)num % radix; - where--; - if(temp < 10) - *where = temp + '0'; - else if(flags & PR_CA) - *where = temp - 10 + 'A'; - else - *where = temp - 10 + 'a'; - num = (unsigned long)num / radix; - } - while(num != 0); - goto EMIT; - case 'c': -/* disallow pad-left-with-zeroes for %c */ - flags &= ~PR_LZ; - where--; - *where = (unsigned char)va_arg(args, - unsigned char); - actual_wd = 1; - goto EMIT2; - case 's': -/* disallow pad-left-with-zeroes for %s */ - flags &= ~PR_LZ; - where = va_arg(args, unsigned char *); -EMIT: - actual_wd = strlen(where); - if(flags & PR_WS) - actual_wd++; -/* if we pad left with ZEROES, do the sign now */ - if((flags & (PR_WS | PR_LZ)) == - (PR_WS | PR_LZ)) - { - fn('-', &ptr); - count++; - } -/* pad on left with spaces or zeroes (for right justify) */ -EMIT2: if((flags & PR_LJ) == 0) - { - while(given_wd > actual_wd) - { - fn(flags & PR_LZ ? '0' : - ' ', &ptr); - count++; - given_wd--; - } - } -/* if we pad left with SPACES, do the sign now */ - if((flags & (PR_WS | PR_LZ)) == PR_WS) - { - fn('-', &ptr); - count++; - } -/* emit string/char/converted number */ - while(*where != '\0') - { - fn(*where++, &ptr); - count++; - } -/* pad on right with spaces (for left justify) */ - if(given_wd < actual_wd) - given_wd = 0; - else given_wd -= actual_wd; - for(; given_wd; given_wd--) - { - fn(' ', &ptr); - count++; - } - break; - default: - break; - } - default: - state = flags = given_wd = 0; - break; - } - } - return count; -} -#if 0 /* testing */ -/***************************************************************************** -SPRINTF -*****************************************************************************/ -int vsprintf_help(unsigned c, void **ptr) -{ - char *dst; - - dst = *ptr; - *dst++ = c; - *ptr = dst; - return 0 ; -} -/***************************************************************************** -*****************************************************************************/ -int vsprintf(char *buffer, const char *fmt, va_list args) -{ - int ret_val; - - ret_val = do_printf(fmt, args, vsprintf_help, (void *)buffer); - buffer[ret_val] = '\0'; - return ret_val; -} -/***************************************************************************** -*****************************************************************************/ -int sprintf(char *buffer, const char *fmt, ...) -{ - va_list args; - int ret_val; - - va_start(args, fmt); - ret_val = vsprintf(buffer, fmt, args); - va_end(args); - return ret_val; -} -/***************************************************************************** -PRINTF -You must write your own putchar() -*****************************************************************************/ -int vprintf_help(unsigned c, void **ptr) -{ - putchar(c); - return 0 ; -} -/***************************************************************************** -*****************************************************************************/ -int vprintf(const char *fmt, va_list args) -{ - return do_printf(fmt, args, vprintf_help, NULL); -} -/***************************************************************************** -*****************************************************************************/ -int printf(const char *fmt, ...) -{ - va_list args; - int ret_val; - - va_start(args, fmt); - ret_val = vprintf(fmt, args); - va_end(args); - return ret_val; -} -/***************************************************************************** -*****************************************************************************/ -int main(void) -{ - char buf[64]; - - sprintf(buf, "%u score and %i years ago...\n", 4, -7); - puts(buf); - - sprintf(buf, "-1L == 0x%lX == octal %lo\n", -1L, -1L); - puts(buf); - - printf("<%-08s> and <%08s> justified strings\n", "left", "right"); - return 0; -} -#endif diff --git a/Dump/hybos/lib/stdio/printf.c b/Dump/hybos/lib/stdio/printf.c deleted file mode 100644 index 39b1647..0000000 --- a/Dump/hybos/lib/stdio/printf.c +++ /dev/null @@ -1,32 +0,0 @@ -/** - * printf.c - * - */ - -#include /* va_* */ -#include <_printf.h> /* fnptr_t */ -#include - -int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr); -void putch(unsigned c); - -int printf_help(unsigned c, void **ptr) -{ - /** - * Leave this for now - */ - ptr = ptr; - - putch(c); - return 0; -} - -void printf(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - (void)do_printf(fmt, args, printf_help, NULL); - va_end(args); -} - diff --git a/Dump/hybos/lib/stdio/sprintf.c b/Dump/hybos/lib/stdio/sprintf.c deleted file mode 100644 index 586bb6a..0000000 --- a/Dump/hybos/lib/stdio/sprintf.c +++ /dev/null @@ -1,19 +0,0 @@ -/** - * sprintf.c - * - */ - -#include /* va_* */ - -int vsprintf_help(unsigned c, void **ptr); - -int sprintf(char *buffer, const char *fmt, ...) -{ - va_list args; - int ret_val; - - va_start(args, fmt); - ret_val = vsprintf(buffer, fmt, args); - va_end(args); - return ret_val; -} diff --git a/Dump/hybos/lib/string/Makefile b/Dump/hybos/lib/string/Makefile deleted file mode 100644 index 4fd1d3c..0000000 --- a/Dump/hybos/lib/string/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -STRING =strcat.o \ - strchr.o \ - strcmp.o \ - strcpy.o \ - strcspn.o \ - stricmp.o \ - strlen.o \ - strncmp.o \ - strncpy.o \ - strnicmp.o \ - strnpst.o \ - strnset.o \ - strpbrk.o \ - strpst.o \ - strrchr.o \ - strrev.o \ - strset.o \ - strspn.o \ - strstr.o \ - tolower.o \ - toupper.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(STRING) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\strcat.o - del ..\$(OBJ_DIR)\strchr.o - del ..\$(OBJ_DIR)\strcmp.o - del ..\$(OBJ_DIR)\strcpy.o - del ..\$(OBJ_DIR)\strcspn.o - del ..\$(OBJ_DIR)\stricmp.o - del ..\$(OBJ_DIR)\strlen.o - del ..\$(OBJ_DIR)\strncmp.o - del ..\$(OBJ_DIR)\strncpy.o - del ..\$(OBJ_DIR)\strnicmp.o - del ..\$(OBJ_DIR)\strnpst.o - del ..\$(OBJ_DIR)\strnset.o - del ..\$(OBJ_DIR)\strpbrk.o - del ..\$(OBJ_DIR)\strpst.o - del ..\$(OBJ_DIR)\strrchr.o - del ..\$(OBJ_DIR)\strrev.o - del ..\$(OBJ_DIR)\strset.o - del ..\$(OBJ_DIR)\strspn.o - del ..\$(OBJ_DIR)\strstr.o - del ..\$(OBJ_DIR)\tolower.o - del ..\$(OBJ_DIR)\toupper.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -strcat.o: strcat.c $(MAKEDEP) -strchr.o: strchr.c $(MAKEDEP) -strcmp.o: strcmp.c $(MAKEDEP) -strcpy.o: strcpy.c $(MAKEDEP) -strcspn.o: strcspn.c $(MAKEDEP) -stricmp.o: stricmp.c $(MAKEDEP) -strlen.o: strlen.c $(MAKEDEP) -strcmp.o: strcmp.c $(MAKEDEP) -strncpy.o: strncpy.c $(MAKEDEP) -strnicmp.o: strnicmp.c $(MAKEDEP) -strnpst.o: strnpst.c $(MAKEDEP) -strnset.o: strnset.c $(MAKEDEP) -strpbrk.o: strpbrk.c $(MAKEDEP) -strpst.o: strpst.c $(MAKEDEP) -strrchr.o: strrchr.c $(MAKEDEP) -strrev.o: strrev.c $(MAKEDEP) -strset.o: strset.c $(MAKEDEP) -strspn.o: strspn.c $(MAKEDEP) -strstr.o: strstr.c $(MAKEDEP) -tolower.o: tolower.c $(MAKEDEP) -toupper.o: toupper.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/string/strcat.c b/Dump/hybos/lib/string/strcat.c deleted file mode 100644 index 9b87dc5..0000000 --- a/Dump/hybos/lib/string/strcat.c +++ /dev/null @@ -1,90 +0,0 @@ -/*** -*strncat.c - append n chars of string to new string -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strncat() - appends n characters of string onto -* end of other string -* -*******************************************************************************/ - - -/*** -*char *strncat(front, back, count) - append count chars of back onto front -* -*Purpose: -* Appends at most count characters of the string back onto the -* end of front, and ALWAYS terminates with a null character. -* If count is greater than the length of back, the length of back -* is used instead. (Unlike strncpy, this routine does not pad out -* to count characters). -* -*Entry: -* char *front - string to append onto -* char *back - string to append -* unsigned count - count of max characters to append -* -*Exit: -* returns a pointer to string appended onto (front). -* -*Uses: -* -*Exceptions: -* -*******************************************************************************/ -#include <_size_t.h> - -/******************************************************************************/ -/* strcat - Concatenate String */ -/* */ -/* This fuction concatenates two strings (add the source string to the end of */ -/* the destination string. It assumes there is enough space in the */ -/* destination to add the source string to it. */ -/* */ -/* s The destination string. */ -/* t The source string. */ -/* @ The destination string. */ -/******************************************************************************/ -char *strcat(char *s, const char *t) -{ - char *c = s; - - /* Find the end of the destination string. */ - while (*s) s++; - - /* Copy the source sting to the destination string. */ - while ((*s++ = *t++)); - - return (c); -} - -/******************************************************************************/ -/* strncat - Concatenate String up to n Characters */ -/* */ -/* This fuction concatenates two strings (add the source string to the end of */ -/* the destination string. It assumes there is enough space in the */ -/* destination to add the source string to it. The total lenght of the */ -/* concatened string may not be larger than n characters. This includes the */ -/* NULL charecter. */ -/* */ -/* s The destination string. */ -/* t The source string. */ -/* n The maximum lenght of the concatednated string. */ -/* @ The destination string. */ -/******************************************************************************/ - -char *strncat(char *front, const char *back, size_t count) -{ - char *start = front; - - while(*front++); - front--; - - while(count--) - if(!(*front++ = *back++)) - return(start); - - *front = '\0'; - return(start); -} diff --git a/Dump/hybos/lib/string/strcat.c~ b/Dump/hybos/lib/string/strcat.c~ deleted file mode 100644 index c46d321..0000000 --- a/Dump/hybos/lib/string/strcat.c~ +++ /dev/null @@ -1,90 +0,0 @@ -/*** -*strncat.c - append n chars of string to new string -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strncat() - appends n characters of string onto -* end of other string -* -*******************************************************************************/ - - -/*** -*char *strncat(front, back, count) - append count chars of back onto front -* -*Purpose: -* Appends at most count characters of the string back onto the -* end of front, and ALWAYS terminates with a null character. -* If count is greater than the length of back, the length of back -* is used instead. (Unlike strncpy, this routine does not pad out -* to count characters). -* -*Entry: -* char *front - string to append onto -* char *back - string to append -* unsigned count - count of max characters to append -* -*Exit: -* returns a pointer to string appended onto (front). -* -*Uses: -* -*Exceptions: -* -*******************************************************************************/ -#include <_size_t.h> - -/******************************************************************************/ -/* strcat - Concatenate String */ -/* */ -/* This fuction concatenates two strings (add the source string to the end of */ -/* the destination string. It assumes there is enough space in the */ -/* destination to add the source string to it. */ -/* */ -/* s The destination string. */ -/* t The source string. */ -/* @ The destination string. */ -/******************************************************************************/ -char *strcat(char *s, const char *t) -{ - char *c = s; - - /* Find the end of the destination string. */ - while (*s) s++; - - /* Copy the source sting to the destination string. */ - while (*s++ = *t++); - - return (c); -} - -/******************************************************************************/ -/* strncat - Concatenate String up to n Characters */ -/* */ -/* This fuction concatenates two strings (add the source string to the end of */ -/* the destination string. It assumes there is enough space in the */ -/* destination to add the source string to it. The total lenght of the */ -/* concatened string may not be larger than n characters. This includes the */ -/* NULL charecter. */ -/* */ -/* s The destination string. */ -/* t The source string. */ -/* n The maximum lenght of the concatednated string. */ -/* @ The destination string. */ -/******************************************************************************/ - -char *strncat(char *front, const char *back, size_t count) -{ - char *start = front; - - while(*front++); - front--; - - while(count--) - if(!(*front++ = *back++)) - return(start); - - *front = '\0'; - return(start); -} diff --git a/Dump/hybos/lib/string/strchr.c b/Dump/hybos/lib/string/strchr.c deleted file mode 100644 index 9a0ca0b..0000000 --- a/Dump/hybos/lib/string/strchr.c +++ /dev/null @@ -1,39 +0,0 @@ -/*** -*strchr.c - search a string for a given character -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strchr() - search a string for a character -* -*******************************************************************************/ - -/*** -*char *strchr(string, c) - search a string for a character -* -*Purpose: -* Searches a string for a given character, which may be the -* null character '\0'. -* -*Entry: -* char *string - string to search in -* char c - character to search for -* -*Exit: -* returns pointer to the first occurence of c in string -* returns NULL if c does not occur in string -* -*Exceptions: -* -*******************************************************************************/ - -char *strchr(const char * string, int ch) -{ - while(*string && *string != (char)ch) - string++; - - if(*string == (char)ch) - return((char *)string); - - return(0); -} diff --git a/Dump/hybos/lib/string/strcmp.c b/Dump/hybos/lib/string/strcmp.c deleted file mode 100644 index 518bb64..0000000 --- a/Dump/hybos/lib/string/strcmp.c +++ /dev/null @@ -1,14 +0,0 @@ -int strcmp(const char * src, const char * dst) -{ - int ret = 0 ; - - while(!(ret = *(unsigned char *)src - *(unsigned char *)dst) && *dst) - ++src, ++dst; - - if(ret < 0) - ret = -1 ; - else if(ret > 0) - ret = 1 ; - - return(ret); -} diff --git a/Dump/hybos/lib/string/strcpy.c b/Dump/hybos/lib/string/strcpy.c deleted file mode 100644 index 8922e3b..0000000 --- a/Dump/hybos/lib/string/strcpy.c +++ /dev/null @@ -1,7 +0,0 @@ - -char *strcpy(char *s, const char *t) -{ - while((*(s++) = *(t++))); - - return s; -} diff --git a/Dump/hybos/lib/string/strcspn.c b/Dump/hybos/lib/string/strcspn.c deleted file mode 100644 index 95dd844..0000000 --- a/Dump/hybos/lib/string/strcspn.c +++ /dev/null @@ -1,69 +0,0 @@ -/*** -*strspn.c - find length of initial substring of chars from a control string -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strspn() - finds the length of the initial substring of -* a string consisting entirely of characters from a control string. -* -* defines strcspn()- finds the length of the initial substring of -* a string consisting entirely of characters not in a control string. -* -* defines strpbrk()- finds the index of the first character in a string -* that is not in a control string -* -*******************************************************************************/ -#include -/*** -*int strcspn(string, control) - search for init substring w/o control chars -* -*Purpose: -* returns the index of the first character in string that belongs -* to the set of characters specified by control. This is equivalent -* to the length of the length of the initial substring of string -* composed entirely of characters not in control. Null chars not -* considered. -* -*Entry: -* char *string - string to search -* char *control - set of characters not allowed in init substring -* -*Exit: -* returns the index of the first char in string -* that is in the set of characters specified by control. -* -*Exceptions: -* -*******************************************************************************/ - -size_t strcspn(const char * string, const char * control) -{ - const unsigned char *str = (unsigned char *)string; - const unsigned char *ctrl = (unsigned char *)control; - - unsigned char map[32]; - int count; - - /* Clear out bit map */ - for(count=0; count<32; count++) - map[count] = 0; - - /* Set bits in control map */ - while(*ctrl) - { - map[*ctrl >> 3] |= (1 << (*ctrl & 7)); - ctrl++; - } - - /* 1st char in control map stops search */ - count=0; - map[0] |= 1; /* null chars not considered */ - while(!(map[*str >> 3] & (1 << (*str & 7)))) - { - count++; - str++; - } - - return count; -} diff --git a/Dump/hybos/lib/string/stricmp.c b/Dump/hybos/lib/string/stricmp.c deleted file mode 100644 index 50d64b4..0000000 --- a/Dump/hybos/lib/string/stricmp.c +++ /dev/null @@ -1,49 +0,0 @@ -/*** -*stricmp.c - contains case-insensitive string comp routine _stricmp/_strcmpi -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* contains _stricmp(), also known as _strcmpi() -* -*******************************************************************************/ - - -/*** -*int _stricmp(dst, src), _strcmpi(dst, src) - compare strings, ignore case -* -*Purpose: -* _stricmp/_strcmpi perform a case-insensitive string comparision. -* For differences, upper case letters are mapped to lower case. -* Thus, "abc_" < "ABCD" since "_" < "d". -* -*Entry: -* char *dst, *src - strings to compare -* -*Return: -* <0 if dst < src -* 0 if dst = src -* >0 if dst > src -* -*Exceptions: -* -*******************************************************************************/ - -/* strcmpi */ - -int stricmp(const char *dst, const char *src) -{ - int f,l; - - do - { - if(((f = (unsigned char)(*(dst++))) >= 'A') && (f <= 'Z')) - f -= ('A' - 'a'); - - if(((l = (unsigned char)(*(src++))) >= 'A') && (l <= 'Z')) - l -= ('A' - 'a'); - } while ( f && (f == l) ); - - - return (f - l); -} diff --git a/Dump/hybos/lib/string/strlen.c b/Dump/hybos/lib/string/strlen.c deleted file mode 100644 index d37eb21..0000000 --- a/Dump/hybos/lib/string/strlen.c +++ /dev/null @@ -1,11 +0,0 @@ -#include /* size_t */ -/***************************************************************************** -*****************************************************************************/ -size_t strlen(const char *str) -{ - size_t ret_val; - - for(ret_val = 0; *str != '\0'; str++) - ret_val++; - return ret_val; -} diff --git a/Dump/hybos/lib/string/strncmp.c b/Dump/hybos/lib/string/strncmp.c deleted file mode 100644 index ab61fd3..0000000 --- a/Dump/hybos/lib/string/strncmp.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -int strncmp(const char * first, const char * last, size_t count) -{ - if(!count) - return(0); - - while(--count && *first && *first == *last) - { - first++; - last++; - } - - return( *(unsigned char *)first - *(unsigned char *)last ); -} diff --git a/Dump/hybos/lib/string/strncpy.c b/Dump/hybos/lib/string/strncpy.c deleted file mode 100644 index 1de4174..0000000 --- a/Dump/hybos/lib/string/strncpy.c +++ /dev/null @@ -1,15 +0,0 @@ -#include /* size_t */ - -char *strncpy(char * dest, const char * source, size_t count) -{ - char *start = dest; - - while(count && (*dest++ = *source++)) /* copy string */ - count--; - - if(count) /* pad out with zeroes */ - while(--count) - *dest++ = '\0'; - - return(start); -} diff --git a/Dump/hybos/lib/string/strnicmp.c b/Dump/hybos/lib/string/strnicmp.c deleted file mode 100644 index 39204c6..0000000 --- a/Dump/hybos/lib/string/strnicmp.c +++ /dev/null @@ -1,56 +0,0 @@ -/*** -*strnicmp.c - compare n chars of strings, ignoring case -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines _strnicmp() - Compares at most n characters of two strings, -* without regard to case. -* -*******************************************************************************/ - -/*** -*int _strnicmp(first, last, count) - compares count char of strings, ignore case -* -*Purpose: -* Compare the two strings for lexical order. Stops the comparison -* when the following occurs: (1) strings differ, (2) the end of the -* strings is reached, or (3) count characters have been compared. -* For the purposes of the comparison, upper case characters are -* converted to lower case. -* -*Entry: -* char *first, *last - strings to compare -* size_t count - maximum number of characters to compare -* -*Exit: -* returns <0 if first < last -* returns 0 if first == last -* returns >0 if first > last -* -*Exceptions: -* -*******************************************************************************/ - -#include <_size_t.h> /* size_t */ - -int strnicmp(const char *first, const char *last, size_t count) -{ - int f,l; - - if(!count) - return 0; - - do - { - if(((f = (unsigned char)(*(first++))) >= 'A') && (f <= 'Z')) - f -= 'A' - 'a'; - - if(((l = (unsigned char)(*(last++))) >= 'A') && (l <= 'Z')) - l -= 'A' - 'a'; - - } while ( --count && f && (f == l) ); - - - return (f - l); -} diff --git a/Dump/hybos/lib/string/strnpst.c b/Dump/hybos/lib/string/strnpst.c deleted file mode 100644 index 6911536..0000000 --- a/Dump/hybos/lib/string/strnpst.c +++ /dev/null @@ -1,11 +0,0 @@ - -char *strnpst(char *s, const char *t, unsigned n) -{ - while(*t && n) - { - *(s++) = *(t++); - n--; - }; - - return s; -} diff --git a/Dump/hybos/lib/string/strnset.c b/Dump/hybos/lib/string/strnset.c deleted file mode 100644 index f1edada..0000000 --- a/Dump/hybos/lib/string/strnset.c +++ /dev/null @@ -1,11 +0,0 @@ -#include /* size_t */ - -char *_strnset(char * string, int val, size_t count) -{ - char *start = string; - - while(count-- && *string) - *string++ = (char)val; - - return start; -} diff --git a/Dump/hybos/lib/string/strpbrk.c b/Dump/hybos/lib/string/strpbrk.c deleted file mode 100644 index 26071e2..0000000 --- a/Dump/hybos/lib/string/strpbrk.c +++ /dev/null @@ -1,70 +0,0 @@ -/*** -*strspn.c - find length of initial substring of chars from a control string -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strspn() - finds the length of the initial substring of -* a string consisting entirely of characters from a control string. -* -* defines strcspn()- finds the length of the initial substring of -* a string consisting entirely of characters not in a control string. -* -* defines strpbrk()- finds the index of the first character in a string -* that is not in a control string -* -*******************************************************************************/ - - - -/*** -*char *strpbrk(string, control) - scans string for a character from control -* -*Purpose: -* Finds the first occurence in string of any character from -* the control string. -* -*Entry: -* char *string - string to search in -* char *control - string containing characters to search for -* -*Exit: -* returns a pointer to the first character from control found -* in string. -* returns NULL if string and control have no characters in common. -* -*Exceptions: -* -*******************************************************************************/ - - -char *strpbrk(const char * string, const char * control) -{ - const unsigned char *str = (unsigned char *)string; - const unsigned char *ctrl = (unsigned char *)control; - - unsigned char map[32]; - int count; - - /* Clear out bit map */ - for(count=0; count<32; count++) - map[count] = 0; - - /* Set bits in control map */ - while(*ctrl) - { - map[*ctrl >> 3] |= (1 << (*ctrl & 7)); - ctrl++; - } - - /* 1st char in control map stops search */ - while(*str) - { - if(map[*str >> 3] & (1 << (*str & 7))) - return((char *)str); - - str++; - } - - return 0; -} diff --git a/Dump/hybos/lib/string/strpst.c b/Dump/hybos/lib/string/strpst.c deleted file mode 100644 index a571764..0000000 --- a/Dump/hybos/lib/string/strpst.c +++ /dev/null @@ -1,10 +0,0 @@ - -char *strpst(char *s, const char *t) -{ - while(*t) - { - *(s++) = *(t++); - }; - - return s; -} diff --git a/Dump/hybos/lib/string/strrchr.c b/Dump/hybos/lib/string/strrchr.c deleted file mode 100644 index 0a888d7..0000000 --- a/Dump/hybos/lib/string/strrchr.c +++ /dev/null @@ -1,46 +0,0 @@ -/*** -*strrchr.c - find last occurrence of character in string -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strrchr() - find the last occurrence of a given character -* in a string. -* -*******************************************************************************/ - - -/*** -*char *strrchr(string, ch) - find last occurrence of ch in string -* -*Purpose: -* Finds the last occurrence of ch in string. The terminating -* null character is used as part of the search. -* -*Entry: -* char *string - string to search in -* char ch - character to search for -* -*Exit: -* returns a pointer to the last occurrence of ch in the given -* string -* returns NULL if ch does not occurr in the string -* -*Exceptions: -* -*******************************************************************************/ - -char *strrchr(const char * string, int ch) -{ - char *start = (char *)string; - - while(*string++); /* find end of string */ - - /* search towards front */ - while(--string != start && *string != (char)ch); - - if(*string == (char)ch) /* char found ? */ - return (char *)string; - - return 0; -} diff --git a/Dump/hybos/lib/string/strrev.c b/Dump/hybos/lib/string/strrev.c deleted file mode 100644 index 6c564ab..0000000 --- a/Dump/hybos/lib/string/strrev.c +++ /dev/null @@ -1,47 +0,0 @@ -/*** -*strrev.c - reverse a string in place -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines _strrev() - reverse a string in place (not including -* '\0' character) -* -*******************************************************************************/ - -/*** -*char *_strrev(string) - reverse a string in place -* -*Purpose: -* Reverses the order of characters in the string. The terminating -* null character remains in place. -* -*Entry: -* char *string - string to reverse -* -*Exit: -* returns string - now with reversed characters -* -*Exceptions: -* -*******************************************************************************/ - -char *_strrev(char *string) -{ - char *start = string; - char *left = string; - char ch; - - while(*string++); /* find end of string */ - - string -= 2; - - while(left < string) - { - ch = *left; - *left++ = *string; - *string-- = ch; - } - - return start; -} diff --git a/Dump/hybos/lib/string/strset.c b/Dump/hybos/lib/string/strset.c deleted file mode 100644 index 4202021..0000000 --- a/Dump/hybos/lib/string/strset.c +++ /dev/null @@ -1,10 +0,0 @@ - -char *_strset(char *string, int val) -{ - char *start = string; - - while(*string) - *string++ = (char)val; - - return start; -} diff --git a/Dump/hybos/lib/string/strspn.c b/Dump/hybos/lib/string/strspn.c deleted file mode 100644 index 7298b5d..0000000 --- a/Dump/hybos/lib/string/strspn.c +++ /dev/null @@ -1,75 +0,0 @@ -/*** -*strspn.c - find length of initial substring of chars from a control string -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strspn() - finds the length of the initial substring of -* a string consisting entirely of characters from a control string. -* -* defines strcspn()- finds the length of the initial substring of -* a string consisting entirely of characters not in a control string. -* -* defines strpbrk()- finds the index of the first character in a string -* that is not in a control string -* -*******************************************************************************/ - - -/*** -*int strspn(string, control) - find init substring of control chars -* -*Purpose: -* Finds the index of the first character in string that does belong -* to the set of characters specified by control. This is -* equivalent to the length of the initial substring of string that -* consists entirely of characters from control. The '\0' character -* that terminates control is not considered in the matching process. -* -*Entry: -* char *string - string to search -* char *control - string containing characters not to search for -* -*Exit: -* returns index of first char in string not in control -* -*Exceptions: -* -*******************************************************************************/ - -#include /* size_t */ - -size_t strspn(const char *string, const char *control) -{ - const unsigned char *str = (unsigned char *)string; - const unsigned char *ctrl = (unsigned char *)control; - - unsigned char map[32]; - int count; - - /* Clear out bit map */ - for(count=0; count<32; count++) - map[count] = 0; - - /* Set bits in control map */ - while(*ctrl) - { - map[*ctrl >> 3] |= (1 << (*ctrl & 7)); - ctrl++; - } - - /* 1st char NOT in control map stops search */ - if(*str) - { - count=0; - while(map[*str >> 3] & (1 << (*str & 7))) - { - count++; - str++; - } - - return count; - } - - return 0; -} diff --git a/Dump/hybos/lib/string/strstr.c b/Dump/hybos/lib/string/strstr.c deleted file mode 100644 index bc34107..0000000 --- a/Dump/hybos/lib/string/strstr.c +++ /dev/null @@ -1,54 +0,0 @@ -/*** -*strstr.c - search for one string inside another -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines strstr() - search for one string inside another -* -*******************************************************************************/ - -/*** -*char *strstr(string1, string2) - search for string2 in string1 -* -*Purpose: -* finds the first occurrence of string2 in string1 -* -*Entry: -* char *string1 - string to search in -* char *string2 - string to search for -* -*Exit: -* returns a pointer to the first occurrence of string2 in -* string1, or NULL if string2 does not occur in string1 -* -*Uses: -* -*Exceptions: -* -*******************************************************************************/ - -char *strstr(const char * str1, const char * str2) -{ - char *cp = (char *)str1; - char *s1, *s2; - - if(!*str2 ) - return (char *)str1; - - while(*cp) - { - s1 = cp; - s2 = (char *)str2; - - while(*s1 && *s2 && !(*s1-*s2)) - s1++, s2++; - - if(!*s2) - return cp; - - cp++; - } - - return 0; -} diff --git a/Dump/hybos/lib/string/tolower.c b/Dump/hybos/lib/string/tolower.c deleted file mode 100644 index afc2c0e..0000000 --- a/Dump/hybos/lib/string/tolower.c +++ /dev/null @@ -1,9 +0,0 @@ - -char *tolower(char* s) -{ - while(*s++) - if(*s >= 'A' && *s <= 'Z') - *s += 'a' - 'A'; - - return s; -} diff --git a/Dump/hybos/lib/string/toupper.c b/Dump/hybos/lib/string/toupper.c deleted file mode 100644 index 344820b..0000000 --- a/Dump/hybos/lib/string/toupper.c +++ /dev/null @@ -1,10 +0,0 @@ - -char *toupper(char *s) -{ - char *c = '\0'; - while(*s++) - if(*s >= 'a' && *s <= 'z') - *s += 'A' - 'a'; - - return c; -} diff --git a/Dump/hybos/lib/util/Makefile b/Dump/hybos/lib/util/Makefile deleted file mode 100644 index 483190c..0000000 --- a/Dump/hybos/lib/util/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -UTIL =rand.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(UTIL) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\rand.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -rand.o: rand.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/util/rand.c b/Dump/hybos/lib/util/rand.c deleted file mode 100644 index c9188a7..0000000 --- a/Dump/hybos/lib/util/rand.c +++ /dev/null @@ -1,56 +0,0 @@ -/*** -*rand.c - random number generator -* -* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved. -* -*Purpose: -* defines rand(), srand() - random number generator -* -*******************************************************************************/ - -static long holdrand = 1L; - - -/*** -*void srand(seed) - seed the random number generator -* -*Purpose: -* Seeds the random number generator with the int given. Adapted from the -* BASIC random number generator. -* -*Entry: -* unsigned seed - seed to seed rand # generator with -* -*Exit: -* None. -* -*Exceptions: -* -*******************************************************************************/ - -void srand(unsigned int seed) -{ - holdrand = (long)seed; -} - - -/*** -*int rand() - returns a random number -* -*Purpose: -* returns a pseudo-random number 0 through 32767. -* -*Entry: -* None. -* -*Exit: -* Returns a pseudo-random number 0 through 32767. -* -*Exceptions: -* -*******************************************************************************/ - -int rand(void) -{ - return (((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff); -} diff --git a/Dump/hybos/lib/x86/.inportb.c.swp b/Dump/hybos/lib/x86/.inportb.c.swp deleted file mode 100644 index 6532e11..0000000 --- a/Dump/hybos/lib/x86/.inportb.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/lib/x86/Makefile b/Dump/hybos/lib/x86/Makefile deleted file mode 100644 index 9039ed2..0000000 --- a/Dump/hybos/lib/x86/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) - -X86 =disable.o \ - enable.o \ - inportb.o \ - outportb.o \ - inportw.o \ - outportw.o - -# This will be one level above where we are now -OBJ_DIR =objects - -OBJS =$(X86) - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\disable.o - del ..\$(OBJ_DIR)\enable.o - del ..\$(OBJ_DIR)\inportb.o - del ..\$(OBJ_DIR)\outportb.o - del ..\$(OBJ_DIR)\inportw.o - del ..\$(OBJ_DIR)\outportw.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -disable.o: disable.c $(MAKEDEP) -enable.o: enable.c $(MAKEDEP) -inportb.o: inportb.c $(MAKEDEP) -outportb.o: outportb.c $(MAKEDEP) -inportw.o: inportw.c $(MAKEDEP) -outportw.o: outportw.c $(MAKEDEP) - diff --git a/Dump/hybos/lib/x86/disable.c b/Dump/hybos/lib/x86/disable.c deleted file mode 100644 index b31ef49..0000000 --- a/Dump/hybos/lib/x86/disable.c +++ /dev/null @@ -1,13 +0,0 @@ -/***************************************************************************** -*****************************************************************************/ -unsigned disable(void) -{ - unsigned ret_val; - - __asm__ __volatile__("pushfl\n" - "popl %0\n" - "cli" - : "=a"(ret_val) - :); - return ret_val; -} diff --git a/Dump/hybos/lib/x86/enable.c b/Dump/hybos/lib/x86/enable.c deleted file mode 100644 index bc98632..0000000 --- a/Dump/hybos/lib/x86/enable.c +++ /dev/null @@ -1,9 +0,0 @@ -/***************************************************************************** -*****************************************************************************/ -void enable(void) -{ - __asm__ __volatile__("sti" - : - : - ); -} diff --git a/Dump/hybos/lib/x86/inportb.c b/Dump/hybos/lib/x86/inportb.c deleted file mode 100644 index f3088fe..0000000 --- a/Dump/hybos/lib/x86/inportb.c +++ /dev/null @@ -1,11 +0,0 @@ -/***************************************************************************** -*****************************************************************************/ -unsigned inportb(unsigned short port) -{ - unsigned char ret_val; - - __asm__ __volatile__("inb %1,%0" - : "=a"(ret_val) - : "d"(port)); - return ret_val; -} diff --git a/Dump/hybos/lib/x86/inportw.c b/Dump/hybos/lib/x86/inportw.c deleted file mode 100644 index b541d59..0000000 --- a/Dump/hybos/lib/x86/inportw.c +++ /dev/null @@ -1,13 +0,0 @@ -unsigned short inportw(int port) -{ - register unsigned short r; - - __asm__ __volatile__ - ( - "inw %%dx, %%ax\n" - : "=a" (r) - : "d" (port) - ); - - return r; -} diff --git a/Dump/hybos/lib/x86/outportb.c b/Dump/hybos/lib/x86/outportb.c deleted file mode 100644 index 8346d67..0000000 --- a/Dump/hybos/lib/x86/outportb.c +++ /dev/null @@ -1,8 +0,0 @@ -/***************************************************************************** -*****************************************************************************/ -void outportb(unsigned port, unsigned val) -{ - __asm__ __volatile__("outb %b0,%w1" - : - : "a"(val), "d"(port)); -} diff --git a/Dump/hybos/lib/x86/outportw.c b/Dump/hybos/lib/x86/outportw.c deleted file mode 100644 index 5985172..0000000 --- a/Dump/hybos/lib/x86/outportw.c +++ /dev/null @@ -1,9 +0,0 @@ -void outportw(int port, unsigned short data) -{ - __asm__ __volatile__ - ( - "outw %%ax, %%dx\n\t" - : - : "a" (data), "d" (port) - ); -} diff --git a/Dump/hybos/src/._krnl.h.swp b/Dump/hybos/src/._krnl.h.swp deleted file mode 100644 index b54106a..0000000 --- a/Dump/hybos/src/._krnl.h.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.debug.c.swp b/Dump/hybos/src/.debug.c.swp deleted file mode 100644 index d6738a0..0000000 --- a/Dump/hybos/src/.debug.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.kbd.c.swp b/Dump/hybos/src/.kbd.c.swp deleted file mode 100644 index 977b87d..0000000 --- a/Dump/hybos/src/.kbd.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.krnl1m.ld.swp b/Dump/hybos/src/.krnl1m.ld.swp deleted file mode 100644 index f95cad1..0000000 --- a/Dump/hybos/src/.krnl1m.ld.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.main.c.swp b/Dump/hybos/src/.main.c.swp deleted file mode 100644 index 1dd3750..0000000 --- a/Dump/hybos/src/.main.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.ming.mak.swp b/Dump/hybos/src/.ming.mak.swp deleted file mode 100644 index feda0c7..0000000 --- a/Dump/hybos/src/.ming.mak.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.sched.c.swp b/Dump/hybos/src/.sched.c.swp deleted file mode 100644 index c75ddf3..0000000 --- a/Dump/hybos/src/.sched.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.tasks.c.swp b/Dump/hybos/src/.tasks.c.swp deleted file mode 100644 index abe0e47..0000000 --- a/Dump/hybos/src/.tasks.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/.video.c.swp b/Dump/hybos/src/.video.c.swp deleted file mode 100644 index 50cb716..0000000 --- a/Dump/hybos/src/.video.c.swp +++ /dev/null Binary files differ diff --git a/Dump/hybos/src/Makefile b/Dump/hybos/src/Makefile deleted file mode 100644 index ab24d4d..0000000 --- a/Dump/hybos/src/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -#MAKEFILE=ming.mak -MAKEFILE=Makefile - -all: - make -f $(MAKEFILE) -C kernel - make -f $(MAKEFILE) -C mm - make -f $(MAKEFILE) -C esh - -install: - make -f $(MAKEFILE) -C mm - make -f $(MAKEFILE) -C esh - make -f $(MAKEFILE) -C kernel install - -clean: - make -f $(MAKEFILE) -C kernel clean - make -f $(MAKEFILE) -C mm clean - make -f $(MAKEFILE) -C esh clean - diff --git a/Dump/hybos/src/README b/Dump/hybos/src/README deleted file mode 100644 index dfca7af..0000000 --- a/Dump/hybos/src/README +++ /dev/null @@ -1,20 +0,0 @@ -Directory structure layout for HybOS - -kernel - HybOS kernel source -keymaps - Keyboard keymaps -objects - .o files -fs - Filesystem source -etc - /etc entries for installed system -test - Various system tests -mm - Memory management source -osh - OpenSHell source -esh - ESHell (HybOS Emergency Shell) source diff --git a/Dump/hybos/src/esh/Makefile b/Dump/hybos/src/esh/Makefile deleted file mode 100644 index 48f19d4..0000000 --- a/Dump/hybos/src/esh/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -LDSCRIPT =../../krnl1m.ld -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) -LD =ld -g -T $(LDSCRIPT) -nostdlib -LIBC =../../lib/libc.a - -OBJS =esh.o - -OBJS_DEP =*.o - -OBJ_DIR =objects - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\esh.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -esh.o: esh.c $(MAKEDEP) - diff --git a/Dump/hybos/src/esh/esh.c b/Dump/hybos/src/esh/esh.c deleted file mode 100644 index 5df2ced..0000000 --- a/Dump/hybos/src/esh/esh.c +++ /dev/null @@ -1,372 +0,0 @@ -/** - * esh.c - * - * Error SHell for HybOS - * - * Exports: - * None. - * - * Imports: - * None. - * - * Description: - * Since esh is called on a new thread in user-space and not in - * kernel-space, imports and exports are not necessary. All the - * kernel needs to know is what functions to call when the - * keyboard buffer has been filled (this even happens when the - * user presses the EOL key, which is the ENTER key on either - * the keypad or the "normal" keyboard). - */ - -#include -#include -#include -#include -#include - -void dumpheapk(void); - -ESHCOMMANDS eshCommands[COMMAND_COUNT]; - - -/** - * keyDown() - * - * This function is called when a key is pressed and is called - * on a new thread which resides in user-space so that esh - * cannot lock up the kernel. - * - * @param unsigned Which key was pressed. See keyboard.h - * - * @return void - */ -void keyDown(unsigned key) -{ - key = key; /* to shut gcc up */ -} - -/** - * keyUp() - * - * This function is called when a key is released. - * - * @param unsigned Which key was released. See keyboard.h - * - * @return void - */ -void keyUp(unsigned key) -{ - key = key; /* to shut gcc up */ -} - -void initCommands(void) -{ - eshCommands[0].minparams = 0; - eshCommands[0].maxparams = 0; - strcpy(eshCommands[0].command, "dumpheap\0"); - strcpy(eshCommands[0].params[0], "-h\0"); - strcpy(eshCommands[0].description, "Print listing of heap usage and status.\0"); - - eshCommands[1].minparams = 1; - eshCommands[1].maxparams = MAX_PARAMS; - strcpy(eshCommands[1].params[0], "-h\0"); - strcpy(eshCommands[1].command, "echo\0"); - strcpy(eshCommands[1].description, "Echo a line of text to the terminal.\0"); - - /*this will be called with either "help" or "help command" */ - eshCommands[2].minparams = 0; - eshCommands[2].maxparams = 1; - strcpy(eshCommands[2].params[0], "-h\0"); - strcpy(eshCommands[2].command, "help\0"); - strcpy(eshCommands[2].description, "Displays general help menu or help on specific command.\0"); - - /* -r|-h [time] */ - eshCommands[3].minparams = 1; - eshCommands[3].maxparams = 2; - strcpy(eshCommands[3].command, "shutdown\0"); - strcpy(eshCommands[3].params[0], "-r\0"); - strcpy(eshCommands[3].params[1], "-h\0"); - strcpy(eshCommands[3].params[2], "NOW\0"); - strcpy(eshCommands[3].description, "Halt or restart the system.\0"); - - /* clear screen */ - eshCommands[4].minparams = 0; - eshCommands[4].maxparams = 0; - strcpy(eshCommands[4].params[0], "-h\0"); - strcpy(eshCommands[4].command, "cls\0"); - strcpy(eshCommands[4].description, "Clears the terminal of all output.\0"); - - /* print working directory */ - eshCommands[5].minparams = 0; - eshCommands[5].maxparams = 0; - strcpy(eshCommands[5].params[0], "-h\0"); - strcpy(eshCommands[5].command, "pwd\0"); - strcpy(eshCommands[5].description, "Prints the current working directory.\0"); -} - -/** - * mapCommand() - * - * Used internally by esh to map a command to it's zero-based - * index of commands. - * - * @param char * the entire line of the command - * - * @return int index of command entry if found, otherwise -1 - */ -int mapCommand(char *cmd) -{ - int i; /* for our loops */ - int params; /* number of parameters found for the command */ - int previdx; /* previous index */ - char cmdName[MAX_LEN]; /* name of the command */ - - i = 0; - previdx = 0; - params = 0; - - /** - * Loop while cmd[i] is not a space - */ - i = 0; - for(i = 0; i < (int)strlen(cmd); i++) - { - if(cmd[i] == ' ') - break; - } - - strncpy(cmdName, cmd, i); - cmdName[i] = '\0'; - - for(i = 0; i < COMMAND_COUNT; i++) - { - if(!strcmp(eshCommands[i].command, cmdName)) - return i; - } - - return -1; -} - -/** - * isParam() - * - * Determines if the supplied parameter is valid for the - * given command. - * - * @param int index of command - * @param char * command string - * - * @return bool true if parameter is valid, false otherwise - */ -bool isParam(int argc, char *argv) -{ - int i; - - for(i = 0; i < MAX_PARAMS; i++) - { - if(!strcmp(eshCommands[argc].params[i], argv)) - return true; - } - - return false; -} - -/** - * mapParams() - * - * Maps each parameter to the pars struct - * - * @param char * Buffer from the command line - * @param struct Parameter structure - * - * @return int Number of command line parameters (arguments) parsed - */ -int mapParams(char *buf, ESHCURRCOMMAND *pars) -{ - int i; /* for our loops */ - int previdx; /* previous index */ - int idx; /* current index */ - int j; /* loops */ - - i = 0; - j = 0; - previdx = 0; - pars->count = 0; - - previdx = mapCommand(buf); - - if(previdx == -1) - return 0; - - strcpy(pars->param[0], eshCommands[previdx].command); - j++; - pars->count++; - - i = 0; - idx = 0; - - for(i = 0; i < (int)strlen(buf); i++) - { - /* we have encountered a seperator */ - if(buf[i] == ' ') - { - if(j > MAX_PARAMS) - break; - - i++; /* skip one space */ - - idx = i; - - if(buf[i] == '"') - { - i++; - idx++; - - while(buf[i] != '"' && i != (int)strlen(buf)) - i++; - - strncpy(pars->param[j], &buf[idx], (i - idx)); - pars->param[j][i - idx] = '\0'; - - idx = i; - j++; - pars->count++; - } - else - { - while(buf[i] != ' ' && i != (int)strlen(buf)) - i++; - - strncpy(pars->param[j], &buf[idx], i - idx); - pars->param[j][i - idx] = '\0'; - i = idx; - j++; - pars->count++; - } - } - } - - return pars->count; -} - -/** - * processCommand() - * - * This function is called when the user has pressed - * the ENTER key. - * - * @param char * The contents of the current buffer or NULL if empty - * @param int Size of the buffer (number of characters) - * - * @return void - */ -void processCommand(char *line, int count) -{ - int i; - int cmd; /* stores the numeric index of the command */ - ESHCURRCOMMAND params; - - count = count; /* to shut gcc up */ - - /*for(i = 0; i < MAX_PARAMS; i++) - params.param[i][0] = '\0';*/ - params.param[0][0] = '\0'; - - initCommands(); - - cmd = mapCommand(line); - mapParams(line, ¶ms); - - switch(cmd) - { - case 0: /* dumpheap */ - dumpheapk(); - //testheap(); - break; - case 1: /* echo */ - for(i = 1; i < params.count; i++) - printf("%s", params.param[i]); - - printf("\n"); - break; - case 2: /* help */ - if(params.count == 1) - { - printf("HybOS EShell Commands:\n"); - for(i = 0; i < COMMAND_COUNT; i++) - if(strlen(eshCommands[i].command) > 0) - printf("%10s %-s\n", eshCommands[i].command, eshCommands[i].description); - } - else - { - cmd = mapCommand(params.param[0]); - mapParams(params.param[1], ¶ms); - - //if(isParam(cmd, params.param[1])) - if(cmd != -1) - { - printf("Usage: %s %s\n", params.param[0], eshCommands[cmd].params[1]); - } - else - printf("esh: '%s' not found.\n", params.param[1]); - } - break; - default: - if(strlen(params.param[0]) > 0 && strcmp(params.param[0], "help")) - printf("esh: '%s' not found.\n", params.param[0]); - else - printf("esh: '%s' not found.\n", &line[0]); - break; - } - - /*for(i = 0; i < params.count; i++) - printf("param[%i]: %s\n", i, params.param[i]);*/ - - //if(isParam(3, ¶ms.param[1])) - // printf("valid parameter\n"); - //else - // printf("invalid parameter\n"); - - return; - - if(!strcmp(line, "dumpheap")) - dumpheapk(); - else if(!strncmp(line, "echo", 4)) - printf("%s\n", line[4] == ' ' ? &line[5] : &line[4]); - else if(!strcmp(line, "help")) - { - printf("HybOS EShell Commands:\n"); - printf("dumpheap\tPrint listing of heap usage and status\n"); - printf("testheap\tTest the heap and print out results\n"); - printf("shutdown -r\tRestart the system.\n"); - printf("pwd\t\tPrint the current working directory.\n"); - } - else if(!strncmp(line, "shutdown", 8)) - { - if(strlen(line) > 9 && !strncmp(&line[9], "-r", 2)) - { - printf("\nSystem shutdown from vtty%u\n", get_current_vc()); - printf("Restarting..."); - //reboot(); - } - else - { - if((strlen(line) > 9) && (strlen(&line[9]) > 0)) - printf("shutdown: Invalid argument \"%s\".\n", &line[9]); - else - printf("Usage: shutdown -r\n"); - } - } - else if((strlen(line) > 0) && (!strcmp(line, "cls"))) - { - printf("\x1B[2J"); - } - else if((strlen(line) >= 8) && (!strcmp(line, "testheap"))) - { - //testheap(); - } - else if((strlen(line) > 0) && (!strcmp(line, "pwd"))) - printf("/\n"); - else if(strlen(line) > 0) - printf("eshell: \"%s\" not found.\n", line); -} diff --git a/Dump/hybos/src/etc/fstab b/Dump/hybos/src/etc/fstab deleted file mode 100644 index 5de9431..0000000 --- a/Dump/hybos/src/etc/fstab +++ /dev/null @@ -1,4 +0,0 @@ -# Poor man's File System Table. - -root=/dev/ROOT -usr=/dev/USR diff --git a/Dump/hybos/src/etc/group b/Dump/hybos/src/etc/group deleted file mode 100644 index 4c7996a..0000000 --- a/Dump/hybos/src/etc/group +++ /dev/null @@ -1,10 +0,0 @@ -operator:*:0: -daemon:*:1: -bin:*:2: -other:*:3: -tty:*:4: -uucp:*:5: -news:*:6: -ftp:*:7: -kmem:*:8: -nogroup:*:99: diff --git a/Dump/hybos/src/etc/passwd b/Dump/hybos/src/etc/passwd deleted file mode 100644 index 1560b30..0000000 --- a/Dump/hybos/src/etc/passwd +++ /dev/null @@ -1,8 +0,0 @@ -root:##root:0:0::/: -daemon:*:1:1::/etc: -bin:##root:2:0:Binaries:/usr/src:/usr/bin/ash -uucp:*:5:5:UNIX to UNIX copy:/usr/spool/uucp:/usr/bin/uucico -news:*:6:6:Usenet news:/usr/spool/news: -ftp:*:7:7:Anonymous FTP:/usr/ftp: -nobody:*:9999:99::/tmp: -ast:*:8:3:Andrew S. Tanenbaum:/usr/ast: diff --git a/Dump/hybos/src/etc/profile b/Dump/hybos/src/etc/profile deleted file mode 100644 index 741e407..0000000 --- a/Dump/hybos/src/etc/profile +++ /dev/null @@ -1,3 +0,0 @@ -# Set timezone for Middle European Time. - -TZ='MET-1MET DST,M3.5.0/2,M9.5.0/3' export TZ diff --git a/Dump/hybos/src/etc/protocols b/Dump/hybos/src/etc/protocols deleted file mode 100644 index 313d915..0000000 --- a/Dump/hybos/src/etc/protocols +++ /dev/null @@ -1,19 +0,0 @@ -# -# Internet (IP) protocols -# -# @(#)protocols 8.1 (Berkeley) 6/9/93 -# -ip 0 IP # internet protocol, pseudo protocol number -icmp 1 ICMP # internet control message protocol -igmp 2 IGMP # internet group management protocol -ggp 3 GGP # gateway-gateway protocol -tcp 6 TCP # transmission control protocol -egp 8 EGP # exterior gateway protocol -pup 12 PUP # PARC universal packet protocol -udp 17 UDP # user datagram protocol -hmp 20 HMP # host monitoring protocol -xns-idp 22 XNS-IDP # Xerox NS IDP -rdp 27 RDP # reliable data protocol -iso-tp4 29 ISO-TP4 # ISO Transport Protocol Class 4 -iso-ip 80 ISO-IP # ISO Internet Protocol -encap 98 ENCAP # RFC1241 encapsulation diff --git a/Dump/hybos/src/etc/rc b/Dump/hybos/src/etc/rc deleted file mode 100644 index d9a3a1d..0000000 --- a/Dump/hybos/src/etc/rc +++ /dev/null @@ -1,24 +0,0 @@ -# This file performs various system initializations. - -umask 022 -PATH=/usr/local/bin:/bin:/usr/bin -export PATH - -# National keyboard? -test -f /etc/keymap && loadkeys /etc/keymap - -# Set timezone. (If the clock tells GMT then put this after 'date'.) -. /etc/profile - -# Try to read the hardware real-time clock, if there is one, to set the date -date `readclock` - -# Initialize files. -printroot >/etc/mtab # /etc/mtab keeps track of mounts ->/etc/utmp # /etc/utmp keeps track of logins - -# /etc/fstab lists the root, tmp and usr devices. -. /etc/fstab - -# Any messages? -test -f /etc/issue && cat /etc/issue diff --git a/Dump/hybos/src/etc/services b/Dump/hybos/src/etc/services deleted file mode 100644 index 9bcd523..0000000 --- a/Dump/hybos/src/etc/services +++ /dev/null @@ -1,85 +0,0 @@ -# -# Network services, Internet style -# -# @(#)services 8.1 (Berkeley) 6/9/93 -# -tcpmux 1/tcp # TCP port multiplexer (RFC1078) -echo 7/tcp -echo 7/udp -discard 9/tcp sink null -discard 9/udp sink null -systat 11/tcp users -daytime 13/tcp -daytime 13/udp -netstat 15/tcp -qotd 17/tcp quote -chargen 19/tcp ttytst source -chargen 19/udp ttytst source -ftp 21/tcp -telnet 23/tcp -smtp 25/tcp mail -time 37/tcp timserver -time 37/udp timserver -rlp 39/udp resource # resource location -nameserver 42/tcp name # IEN 116 -whois 43/tcp nicname -domain 53/tcp nameserver # name-domain server -domain 53/udp nameserver -mtp 57/tcp # deprecated -# Bootp experimental (sellgren@vangogh) -bootp 67/udp # bootp server -#bootpc 68/udp # bootp client -# -tftp 69/udp -rje 77/tcp netrjs -finger 79/tcp -http 80/tcp # World Wide Web -link 87/tcp ttylink -supdup 95/tcp -hostnames 101/tcp hostname # usually from sri-nic -tsap 102/tcp # part of ISODE. -#csnet-cs 105/? -pop 110/tcp postoffice -sunrpc 111/tcp -sunrpc 111/udp -auth 113/tcp authentication -sftp 115/tcp -uucp-path 117/tcp -nntp 119/tcp readnews untp # USENET News Transfer Protocol -ntp 123/udp -snmp 161/udp -snmp-trap 162/udp -# -# UNIX specific services -# -exec 512/tcp -biff 512/udp comsat -login 513/tcp -who 513/udp whod -shell 514/tcp cmd # no passwords used -syslog 514/udp -printer 515/tcp spooler # line printer spooler -talk 517/udp -ntalk 518/udp -route 520/udp router routed -timed 525/udp timeserver -tempo 526/tcp newdate -courier 530/tcp rpc -conference 531/tcp chat -netnews 532/tcp readnews -netwall 533/udp # -for emergency broadcasts -uucp 540/tcp uucpd # uucp daemon -rdist 541/tcp rdistd # rdist daemon -remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem - -ingreslock 1524/tcp -# -# Kerberos (Project Athena/MIT) services -# -kerberos 750/udp kdc # Kerberos (server) udp -kerberos 750/tcp kdc # Kerberos (server) tcp -krbupdate 760/tcp kreg # Kerberos registration -kpasswd 761/tcp kpwd # Kerberos "passwd" -klogin 543/tcp # Kerberos rlogin -eklogin 2105/tcp # Kerberos encrypted rlogin -kshell 544/tcp krcmd # Kerberos remote shell diff --git a/Dump/hybos/src/etc/shadow b/Dump/hybos/src/etc/shadow deleted file mode 100644 index 15fa36d..0000000 --- a/Dump/hybos/src/etc/shadow +++ /dev/null @@ -1 +0,0 @@ -root::0:0::: diff --git a/Dump/hybos/src/etc/termcap b/Dump/hybos/src/etc/termcap deleted file mode 100644 index c5f89b4..0000000 --- a/Dump/hybos/src/etc/termcap +++ /dev/null @@ -1,64 +0,0 @@ -mx|minix|minix console:\ - :am:xn:bs:\ - :co#80:li#25:\ - :is=\E[0m:\ - :cd=\E[0J:cl=\E[H\E[0J:\ - :so=\E[7m:se=\E[0m:\ - :us=\E[4m:ue=\E[0m:\ - :mb=\E[5m:md=\E[1m:\ - :mr=\E[7m:me=\E[0m:\ - :sr=\EM:\ - :cm=\E[%i%d;%dH:\ - :ho=\E[H:\ - :al=\E[L:AL=\E[%dL:\ - :ce=\E[K:\ - :DC=\E[%dP:dc=\E[P:\ - :DL=\E[%dM:dl=\E[M:\ - :DO=\E[%dB:do=\E[B:\ - :IC=\E[%d@:ic=\E[@:\ - :it#8:\ - :le=^H:LE=\E[%dD:nd=\E[C:\ - :ri=\E[C:RI=\E[%dC:\ - :up=\E[A:UP=\E[%dA:\ - :ku=\E[A:kd=\E[B:\ - :kl=\E[D:kr=\E[C:\ - :kh=\E[H:\ - :k0=\E[Y:l0=End:\ - :k1=\E[V:l1=PgUp:\ - :k2=\E[U:l2=PgDn:\ - :k3=\E[T:l3=Num +:\ - :k4=\E[S:l4=Num -:\ - :k5=\E[G:l5=Num 5: -du|dialup|Dialup line:\ - :bs:co#80:li#24: -db|dumb|Really dumb terminal:\ - :bs:co#80:li#24: -lp|lp|Line Printer:\ - :co#80:li#66: -li|ansi|Ansi standard crt:\ - :am:bs:cd=\E[J:ce=\E[K:cl=\E[2J\E[H:cm=\E[%i%d;%dH:co#80:\ - :dn=\E[B:me=\E[0m:mb=\E[5m:mr=\E[7m:md=\E[1m:ho=\E[H:li#24:\ - :nd=\E[C:ms:pt:so=\E[7m:se=\E[0m:us=\E[4m:ue=\E[0m:up=\E[A:\ - :kb=^h:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C: -vs|xterm|xterms|vs100|xterm terminal emulator (X window system):\ - :am:cr=^M:do=^J:nl=^J:bl=^G:le=^H:ho=\E[H:\ - :co#80:li#24:cl=\E[H\E[2J:bs:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ - :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ - :md=\E[1m:mr=\E[7m:me=\E[m:\ - :ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:kb=^H:\ - :k1=\E[P:k2=\E[Q:k3=\E[R:k4=\E[S:ta=^I:pt:sf=\n:sr=\EM:\ - :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:\ - :MT:ks=\E[?1h\E=:ke=\E[?1l\E>:\ - :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l:\ - :rs=\E[r\E<\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l:xn:\ - :AL=\E[%dL:DL=\E[%dM:IC=\E[%d@:DC=\E[%dP:\ - :hs:ts=\E]2;:fs=^G:ds=\E]2;^G: -d0|vt100|vt100-am|vt100am|dec-vt100|dec vt100:\ - :do=^J:co#80:li#24:cl=\E[;H\E[2J:sf=\ED:\ - :le=^H:bs:am:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\ - :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\ - :md=\E[1m:mr=\E[7m:mb=\E[5m:me=\E[m:is=\E[1;24r\E[24;1H:\ - :rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:\ - :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ - :ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=\EM:vt#3:xn:\ - :sc=\E7:rc=\E8:cs=\E[%i%d;%dr: diff --git a/Dump/hybos/src/etc/ttytab b/Dump/hybos/src/etc/ttytab deleted file mode 100644 index cd566f5..0000000 --- a/Dump/hybos/src/etc/ttytab +++ /dev/null @@ -1,13 +0,0 @@ -# ttytab - terminals -# -# Device Type Program Init -console hybos getty -ttyc1 hybos getty -ttyc2 hybos getty -ttyc3 hybos getty -tty00 unknown -tty01 unknown -ttyp0 network -ttyp1 network -ttyp2 network -ttyp3 network diff --git a/Dump/hybos/src/fs/buf.h b/Dump/hybos/src/fs/buf.h deleted file mode 100644 index 0de78da..0000000 --- a/Dump/hybos/src/fs/buf.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _BUF_H -#define _BUF_H - -#include - -typedef struct buf -{ - union - { - char b__data[BLOCK_SIZE]; /* ordinary user data */ - direct b__dir[NR_DIR_ENTRIES]; /* directory block */ - zone1_t b__v1_ind[V1_INDIRECTS]; /* V1 indirect block */ - zone_t b__v2_ind[V2_INDIRECTS]; /* V2 indirect block */ - d1_inode b__v1_ino[V1_INODES_PER_BLOCK]; /* V1 inode block */ - d2_inode b__v2_ino[V2_INODES_PER_BLOCK]; /* V2 inode block */ - bitchunk_t b__bitmap[BITMAP_CHUNKS]; /* bit map block */ - } b; - - /** - * Header portion of the buffer - */ - struct buf *b_next; /* used to link all free bufs in a chain */ - struct buf *b_prev; /* used to link all free bufs the other way */ - struct buf *b_hash; /* used to link all bufs on hash chains */ - block_t b_blocknr; /* block number of its (minor) device */ - dev_t b_dev; /* major | minor device where block resides */ - char b_dirt; /* CLEAN or DIRTY */ - char b_count; /* number of users of this buffer */ -} buf[NR_BUFFS]; - -#endif /* _BUF_H */ diff --git a/Dump/hybos/src/kernel/Makefile b/Dump/hybos/src/kernel/Makefile deleted file mode 100644 index 5e7a2d1..0000000 --- a/Dump/hybos/src/kernel/Makefile +++ /dev/null @@ -1,73 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -LDSCRIPT =../krnl1m.ld -NASM =nasm -f elf -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) -LD =ld -g -T $(LDSCRIPT) -nostdlib -#LD =D:/cygwin/usr/cross/bin/i586-elf-ld.exe -g -T $(LDSCRIPT) -nostdlib -LIBC =../../lib/libc.a - -OBJS =debug.o \ - main.o \ - kstart.o \ - keyboard.o \ - sched.o \ - tasks.o \ - video.o \ - bootlog.o -# cpu.o -OBJS_DEP =*.o - -OBJ_DIR =objects - -# targets -all: kernel.bin - -install: kernel.bin - copy ..\..\boot\kernel.bin a:\kernel.bin - -clean: - del ..\$(OBJ_DIR)\debug.o - del ..\$(OBJ_DIR)\keyboard.o - del ..\$(OBJ_DIR)\kstart.o - del ..\$(OBJ_DIR)\main.o - del ..\$(OBJ_DIR)\sched.o - del ..\$(OBJ_DIR)\tasks.o - del ..\$(OBJ_DIR)\video.o - del ..\..\boot\kernel.bin - del ..\$(OBJ_DIR)\kernel.dis - del ..\$(OBJ_DIR)\kernel.sym - del ..\$(OBJ_DIR)\bootlog.o -# del ..\$(OBJ_DIR)\cpu.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -kstart.o: kstart.asm $(MAKEDEP) -main.o: main.c $(MAKEDEP) -video.o: video.c $(MAKEDEP) -debug.o: debug.c $(MAKEDEP) -kbd.o: kbd.c $(MAKEDEP) -sched.o: sched.c $(MAKEDEP) -tasks.o: tasks.c $(MAKEDEP) -bootlog.o: bootlog.c $(MAKEDEP) -#cpu.o: cpu.c $(MAKEDEP) - -# explicit rules -$(LIBC): ../../lib/$(MAKEFILE) - make -C ../../lib -f $(MAKEFILE) - -kernel.bin: $(OBJS) $(LDSCRIPT) $(LIBC) $(MAKEDEP) - $(LD) -o../../boot/$@ ../$(OBJ_DIR)/*.o $(LIBC) - objdump --source ../../boot/$@ >../$(OBJ_DIR)/kernel.dis - nm --line-numbers ../../boot/$@ | sort >../$(OBJ_DIR)/kernel.sym - strip ../../boot/$@ diff --git a/Dump/hybos/src/kernel/_krnl.h b/Dump/hybos/src/kernel/_krnl.h deleted file mode 100644 index 8354cca..0000000 --- a/Dump/hybos/src/kernel/_krnl.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef __TL__KRNL_H -#define __TL__KRNL_H - -//#ifdef __cplusplus -//extern "C" -//{ -//#endif - -#include /* jmp_buf */ - -#define MAX_VC 12 /* maximum number of virtual terminals */ - -/** - * CPU error codes - */ -#define _K_CPU_DBZ 0 /* Divide by zero */ -#define _K_CPU_SS 1 /* Single Step */ -#define _K_CPU_NMI 2 /* Non-maskable (NMI) */ -#define _K_CPU_BPX 3 /* Breakpoint */ -#define _K_CPU_OFT 4 /* Overflow trap */ -#define _K_CPU_BND 5 /* BOUND range exceeded */ -#define _K_CPU_IOP 6 /* Invalid opcode */ -#define _K_CPU_CNA 7 /* Coprocessor not available */ -#define _K_CPU_DFE 8 /* Double fault exception */ -#define _K_CPU_CSO 9 /* Coprocessor segment overrun */ -#define _K_CPU_CPE 10 /* Coprocessor error */ -#define _K_CPU_ITS 0x0A /* Invalid task state management */ -#define _K_CPU_SNP 0x0B /* Segment not present */ -#define _K_CPU_SEX 0x0C /* Stack exception (or illicit sex) */ -#define _K_CPU_GPF 0x0D /* General protection exception */ -#define _K_CPU_PGF 0x0E /* Page fault */ - -/** - * Interrupt table - */ -#define _K_IRQ_TIMER 0x08 /* timer (55ms intervals, 18.21590/sec) */ -#define _K_IRQ_KEYBOARD 0x09 /* keyboard service required */ -#define _K_IRQ_S8259 0x0A /* slave 8259 or EGA/VGA vertical retrace */ -#define _K_IRQ_COM2 0x0B /* COM2 service required (PS/2 MCA COM3-COM8) */ -#define _K_IRQ_COM1 0x0C /* COM1 service required */ -#define _K_IRQ_HDDREQ 0x0D /* fixed disk or data request from LPT2 */ -#define _K_IRQ_FDDSERV 0x0E /* floppy disk service required */ -#define _K_IRQ_LPT1REQ 0x0F /* data request from LPT1 */ -#define _K_IRQ_VIDEO 0x10 /* video (int 10h) */ -#define _K_IRQ_EQPDET 0x11 /* equipment determination (int 11h) */ -#define _K_IRQ_MEMORY 0x12 /* memory size (int 12h) */ -#define _K_IRQ_DIO 0x13 /* disk I/O service (int 13h) */ -#define _K_IRQ_SERIAL 0x14 /* serial communications (int 14h) */ -#define _K_IRQ_SYSTEM 0x15 /* system services, cassette (int 15h) */ -#define _K_IRQ_KBDSERV 0x16 /* keyboard services (int 16h) */ -#define _K_IRQ_LPT 0x17 /* parallel printer (int 17h) */ -#define _K_IRQ_ROM 0x18 /* ROM BASIC loader */ -#define _K_IRQ_BTSTRAP 0x19 /* bootstrap loader (unreliable, int 19h) */ -#define _K_IRQ_TOD 0x1A /* time of day (int 1A) */ -#define _K_IRQ_CBREAK 0x1B /* user defined ctrl-break handler (int 1B) */ -#define _K_IRQ_TICK 0x1C /* user defined clock tick handler (int 1C) */ -#define _K_IRQ_VIDEOP 0x1D /* 6845 video parameter pointer */ -#define _K_IRQ_DISKPARAM 0x1E /* diskette parameter pointer (base table) */ -#define _K_IRQ_GCHTBL 0x1F /* graphics character table */ -#define _K_IRQ_HDD 0x40 /* hard disk */ -#define _K_IRQ_FIXEDD0 0x41 /* fixed disk 0 parameters pointer (int 13h, int 9h) */ -#define _K_IRQ_RELVID 0x42 /* relocated video handler (EGA/VGA/PS) */ -#define _K_IRQ_UFT 0x43 /* user font table (EGA/VGA/PS) */ -#define _K_IRQ_GRAPH 0x44 /* first 128 graphics characters (also Netware) */ -#define _K_IRQ_FIXED1 0x46 /* fixed disk 1 parameters ptr (int 13h, int 9h/int 41h) */ -#define _K_IRQ_PCJR 0x48 /* PCjr cordless keyboard translation */ -#define _K_IRQ_PCJRSCAN 0x49 /* PCjr non-keyboard scancode translation table */ -#define _K_IRQ_USERALARM 0x4A /* user alarm (int 4A) */ -#define _K_IRQ_PALARM 0x50 /* periodic alarm timer (PS/2) */ -#define _K_IRQ_GSS 0x59 /* GSS computer graphics interface */ -#define _K_IRQ_BIOSEP 0x5A /* cluster adapter BIOS entry point */ -#define _K_IRQ_CADAPBT 0x5B /* cluster adapter boot */ -#define _K_IRQ_NETBIOS 0x5C /* NETBIOS interface, TOPS interface */ -#define _K_IRQ_EMS 0x67 /* LIM/EMS specifications (int 67h) */ -#define _K_IRQ_APPC 0x68 /* APPC */ -#define _K_IRQ_RTC 0x70 /* real time clock (int 15h) */ -#define _K_IRQ_REDIRIRQ2 0x71 /* software redirected to IRQ2 */ -#define _K_IRQ_MOUSE 0x74 /* mouse interrupt */ -#define _K_IRQ_HDC 0x76 /* fixed disk controller */ - -/* the code for setvect() and getvect() in -KSTART.ASM depends on the layout of this structure */ -typedef struct -{ - unsigned access_byte, eip; -} vector_t; - -/* the layout of this structure must match the order of registers -pushed and popped by the exception handlers in KSTART.ASM */ -typedef struct -{ -/* pushed by pusha */ - unsigned edi, esi, ebp, esp, ebx, edx, ecx, eax; -/* pushed separately */ - unsigned ds, es, fs, gs; - unsigned which_int, err_code; -/* pushed by exception. Exception may also push err_code. -user_esp and user_ss are pushed only if a privilege change occurs. */ - unsigned eip, cs, eflags, user_esp, user_ss; -} regs_t; - -typedef struct /* circular queue */ -{ - unsigned char *data; - unsigned size, in_base, in_ptr/*, out_base*/, out_ptr; -} queue_t; - -typedef struct -{ -/* virtual console input */ - queue_t keystrokes; -/* virtual console output */ - unsigned esc, attrib, csr_x, csr_y, esc1, esc2, esc3; - unsigned short *fb_adr; -} console_t; - -typedef struct -{ - console_t *vc; - jmp_buf state; - enum - { - TS_RUNNABLE = 1, TS_BLOCKED = 2, TS_ZOMBIE = 3 - } status; -} task_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Dump/hybos/src/kernel/bootlog.c b/Dump/hybos/src/kernel/bootlog.c deleted file mode 100644 index c03200a..0000000 --- a/Dump/hybos/src/kernel/bootlog.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include -#include <_printf.h> /* do_printf() */ -#include "_krnl.h" -#include "bootlog.h" - -void klog(char *proc, char *entry, KLOGRESULT result, console_t *vtty0) -{ - unsigned oldattrib; - int i = 0; - int offset = 69; /* -4 for the "[ ]" part, -2 for the ": " part, -1 for space at end, and -4 for the status */ - char status[4]; - va_list args; - - args = args; - status[0] = '\0'; - - /** - * Save our old color attributes - */ - oldattrib = vtty0->attrib; - - if(result == K_KLOG_SUCCESS) - { - /** - * Successfull initialization of something. - * Write "..Ok" then leave - */ - vtty0->attrib = 8; - printf("\b\b\b\b.."); - vtty0->attrib = 2; - printf("Ok\n"); - vtty0->attrib = oldattrib; - - return; - } - else if(result == K_KLOG_FAILURE) - { - /** - * Unsuccessfull initialization of something. - * Write "Fail" then leave - */ - vtty0->attrib = 4; - printf("\b\b\b\bFail\n"); - vtty0->attrib = oldattrib; - - return; - } - - /** - * FIXME - * - * Should "wrap" the line instead - */ - if(strlen(entry) + 8 > 80) - return; - - vtty0->attrib = 8; - printf("[ "); - vtty0->attrib = 15; - printf("%s: %s", proc, entry); - vtty0->attrib = 8; - printf(" ]"); - - offset -= strlen(proc); - offset -= strlen(entry); - - for(i = 0; i < offset; i++) - printf("."); - - vtty0->attrib = 8; - printf("Wait"); - - vtty0->attrib = oldattrib; -} - diff --git a/Dump/hybos/src/kernel/bootlog.h b/Dump/hybos/src/kernel/bootlog.h deleted file mode 100644 index 83c3b86..0000000 --- a/Dump/hybos/src/kernel/bootlog.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _BOOTLOG_H -#define _BOOTLOG_H -#include -#include -#include "_krnl.h" - -typedef unsigned KLOGRESULT; - -#define K_KLOG_SUCCESS 0x00 /* successfull completion of task, finish log message */ -#define K_KLOG_PENDING 0x01 /* task hasn't completed yet, delay logging status */ -#define K_KLOG_FAILURE 0x02 /* unsuccessfull completion of task, finish log message */ - -void klog(char *proc, char *entry, KLOGRESULT result, console_t *vtty0); - -#endif /* !defined(_BOOTLOG_H) */ diff --git a/Dump/hybos/src/kernel/cpu.c b/Dump/hybos/src/kernel/cpu.c deleted file mode 100644 index 4675fda..0000000 --- a/Dump/hybos/src/kernel/cpu.c +++ /dev/null @@ -1,1351 +0,0 @@ -/** - * Processor Management - */ - -/** - * Processor Identification - */ - -/** - * Name Title Revision - * ---------------------------------------------------------------------------------------------------- - * AMD AMD-K6 Processor Model 6 Revision Guide G 1998 August - * AMD AMD-K6 Processor Model 7 Revision Guide H 1999 June - * AMD AMD-K6-2 Processor Model 8 Revision Guide F 1999 June - * AMD AMD-K6-III Processor Model 9 Revision Guide C 1999 July - * AMD AMD Athlon Processor Model 1 & Model 2 Revision Guide D 2000 August - * AMD AMD Duron Processor Model 3 Revision Guide I 2002 December - * AMD AMD Athlon Processor Model 4 Revision Guide I 2002 December - * AMD AMD Athlon Processor Model 6 Revision Guide E 2002 December - * AMD AMD Duron Processor Model 7 Revision Guide C 2002 December - * AMD AMD Athlon Processor Model 8 Revision Guide C 2002 December - * - * Intel Intel386 CX/SXSA Microprocessor Specification Update 002 1997 January - * Intel Intel386 DX Processor Specification Update 002 1997 January - * Intel Intel386 EX Embedded Processor Specification Update 010 1998 October - * Intel 60- and 66-MHz Pentium Processor Specification Update 001 1997 February - * Intel Pentium Processor Specification Update 041 1999 January - * Intel Pentium Pro Processor Specification Update 039 1999 January - * Intel Mobile Intel Celeron Processor at 466 MHz, ... Specification Update 038 2002 November - * Intel Mobile Intel Pentium II Processor Specification Update 046 2002 November - * Intel Intel Pentium II Xeon Processor Specification Update 032 2002 January - * Intel Intel Pentium II Processor Specification Update 049 2002 July - * Intel Intel Celeron Processor Specification Update 047 2002 October - * Intel Intel Pentium III Processor Specification Update 045 2002 November - * Intel Mobile Intel Celeron Processor (0.18� and 0.13�) Specification Update 030 2002 August - * Intel Mobile Intel Pentium III Processor and ... Specification Update 036 2002 November - * Intel Intel Pentium III Xeon Processor Specification Update 037 2002 July - * Intel Intel Pentium 4 Processor Specification Update 029 2002 November - * Intel Mobile Intel Pentium 4 Processor-M Specification Update 008 2002 November - * Intel Intel Celeron Processor in the 478-Pin Package Specification Update 005 2002 November - * Intel Mobile Intel Celeron Processor on .13 Micron ... Specification Update 002 2002 August - * Intel Intel Xeon Processor Specification Update 020 2002 November - * Intel Intel Xeon Processor MP Specification Updata 009 2002 November - * Intel Low Voltage Intel Xeon Processor Specification Update 003 2002 November - * Intel Intel Pentium M Processor 001 2003 March - * Intel Intel Itanium Processor Specification Update 008 2003 January - * Intel Intel Itanium 2 Processor Specification Update 007 2003 January - * AMD AMD Processor Recognition W-1 2002 November - * Intel Intel Processor Identification and the CPUID Instruction 023 2003 March - * Intel Intel Processor Serial Number 001 1999 March - * IDT IDT WinChip C6 Data Sheet 1.10 1998 March - */ - -/** - * Mobile Athlon Detection - * - * Problems with CPU identication: - * 1) How much information? - * 2) Getting the information - * - * CPU identification has two purposes: OS information and user information. Since this module wil be - * used in TriOS we'll only need OS information (ident upto stepping for erratas) No process size, - * packaging or voltage info. I can be found withofficial name and codename. To prevent user confusion - * we need to show the diff between Celeron / Pentium / Xeon. Cache info is important for some memory - * defragmentation and alignment algorithms, perhaps. - * - * OLD CPUS: - * - * i4004 / i4040 - * i8008 / i8080 / i8080A / Zilog Z80 / i8085A / i8085AH - * - * 2.13 Contemporary CPUs - * Contemporary 16 bit CPUs to 8086/8088 were Zilog Z8000 CPU, Fairchild 9445 CPU, Texas Instruments TI9900 CPU and Mil-Std 1750A CPU. Last is reason DOD (Department Of Defence) contractors were not interested in 8086/8088. Mil-Std 1750A CPU was specified in all contracts of 1979 - 1984 period. - * Texas Instruments TI9900 CPU was probably the best of the lot, but Texas Instruments considered it a closed architecture, so no-one used it. - * - * 8086 - 80368 Intel Only - * 80486 Lots of manufacturers, almost no stpping info - * 80586 Lots of incorrect information and processors that were never sold, no stepping info - * 80686 Celeron / Pentium / Xeon // !Mobile! (Inel realy srewed up the names here) - * 80786 VERY WELL DONE BY INTEL (at least names are a bit more consistant) - * 80886 Not officialy realeasd at the moment - * - * Intel detection: AAA xxh doesn't #UD - * Cyrix Detection: Read the chipset data, but I heard there was a better one - * AMD Detection If there not TI, IBM, UMC, Cyrix or Intel, must be AMD, need sometin' better - * UMC Detection support CPUID I believe - * Texas Detection Models do not real conflic (aren't those things the same as IBM have to check) - * IBM Detection Ax or 8x as family (but there are exceptions) and models do not conflict - * - * CYRIX/TI/IBM Identificaton through Chipset Data (I/O 22h and 23h) - * - * Not about the use of stepping and revision: - * - * Stepping is used always. I try to change this into: Stepping = A0 / Revision = 3h - * Intel also calls the revion Stepping ID - * - * 386 Reset Data - * 0- 3 Minor Stepping Revision - * 4- 7 Major Stepping Model - * 8-11 Family Family - * 12-15 Type DX/SX/SL and TI/IBM/Intel - * - * 486+ Reset Data - * 0- 3 Revision - * 4- 7 Model - * 8-11 Family - * 12-13 Type 0 = Normal, 1 = OverDrive, 2 = Second Processor, 3 = Reserved - * 14-15 Reserved - * 16-19 Extended Model - * 20-27 Extended Family - * 28-30 Reserved - * 31 Reserved Has Serial Number - * - * All over drives could also have type 0 if they are an errata (whatever that means) - * - * Legal Mumbo Jumbo: In the CPUID Documentation, Intel says the PSN could be reported wrongly, for - * example if the voltage or frequency is wrong. It doesn't say it's corec when the processor is - * working on the correct voltage and frequency... - * - * IF HighetExtened CPUID Fucntion > 0x80000000 Brand String is supported, even if 0x800000001 or 2 ??? - * - * Should OverDrives just be ignored? According to Intel internal caches or execution times may vary - * According to Intel CPUID is unreliable in V86 Mode - * According to Intel MSRs vary between different Models of the Pentium (P5 that is) - * PSN is not guaranteed to be unique - * Intel PSN Style: XXXX-XXXX-XXXX-XXXX-XXXX-XXXX (96 bit) - * Transmeta PSN S: XXXXXXXX:XXXXXXXX:XXXXXXXX:XXXXXXXX (128 bit) - * - * Intel says apps need to use the BRAND STRING to identify the processor (ARE THEY CRAZY???) - * Intel says apps need to use the BRAND ID to identify the processor (not crazy, but useless) - * - * DAZ DAZ DAZ DAZ DAZ DAZ DAZ - * - * 11 DENORMALS ARE ZERO - * With the introduction of the SSE2 extensions, some Intel Architecture processors have the ability to convert SSE - * and SSE2 source operand denormal numbers to zero. This feature is referred to as Denormals -Are-Zero (DAZ). The - * DAZ mode is not compatible with IEEE Standard 754. The DAZ mode is provided to improve processor - * performance for applications such as streaming media processing, where rounding a denormal operand to zero does - * not appreciably affect the quality of the processed data. - * Some processor steppings support SSE2 but do not support the DAZ mode. To determine if a processor supports the - * DAZ mode, software must perform the following steps. - * 1. Execute the CPUID instruction with an input value of EAX=0 and ensure the vendor-ID string returned is �GenuineIntel�. - * 2. Execute the CPUID instruction with EAX=1. This will load the EDX register with the feature flags. - * 3. Ensure that the FXSR feature flag (EDX bit 24) is set. This indicates the processor supports the FXSAVE and FXRSTOR - * instructions. - * 4. Ensure that the XMM feature flag (EDX bit 25) or the EMM feature flag (EDX bit 26) is set. This indicates that the - * processor supports at least one of the SSE/SSE2 instruction sets and its MXCSR control register. - * 5. Zero a 16-byte aligned, 512-byte area of memory. This is necessary since some implementations of FXSAVE do not modify - * reserved areas within the image. - * 6. Execute an FXSAVE into the cleared area. - * 7. Bytes 28-31 of the FXSAVE image are defined to contain the MXCSR_MASK. If this value is 0, then the processor's - * MXCSR_MASK is 0xFFBF, otherwise MXCSR_MASK is the value of this dword. - * 8. If bit 6 of the MXCSR_MASK is set, then DAZ is supported. - * After completing this algorithm, if DAZ is supported, software can enable DAZ mode by setting bit 6 in the - * MXCSR register save area and executing the FXRSTOR instruction. Alternately software can enable DAZ mode by - * setting bit 6 in the MXCSR by executing the LDMXCSR instruction. Refer to the chapter titled �Programming with - * the Streaming SIMD Extensions (SSE)� in the Intel Architecture Software Developer�s Manual volume 1: Basic - * Architecture. - * - * DAZ DAZ DAZ DAZ DAZ DAZ DAZ - * - * Legacy detecyion - * 8086 EFLAGS 12-15 are always set - * 80286 EFLAGS 12-15 are clear in RM - * 80366 EFLAGS 18 Cant be set, if it can it a 486+ - * 80848 EFLAGS 21 Can't be set, if it can use CPUID - * - * FPU If control/status word can be saved it's present - * 27/387 Infinity control Rounding Stuff - * 487 486 with coproc - * - * What about the Xeon DP???? - * - * CMXCHG8B Disabled because of Stuoid MSWinNT bug (studpid. Microsft not diabling. stupid) - * - * sAVE bRAND sTRING BEFRORE s3 POWER DOWN - * - * NSC Geode!!!! - * - * "The iAPX 286 will push a different value on the stack for PUSH SP than the iAPX 86/88." - * "When a word write is performed at offset FFFFh in a segment, the 8086 will write one byte at offset - * FFFFh, and the other at offset 0, while an 80186 family processor will write one byte at offset - * FFFFh, and the other at offset 10000h (one byte beyond the end of the segment)." - * - * A finalty note: I'm looking for some information on the Intel Timna (Intel's MediaGX). The project - * was abandonned so Intel never published any useful material on this. It was based on the P-III. - * Also some info in the Microsoft X-Box' special P-III would help - */ - -#include -#include "bootlog.h" - -typedef struct { - unsigned n; - char* i; - char* v; -} VENDORLIST; - -VENDORLIST VendorList[] = -{ - {0x0001, "ThinkTrinary", "Trinary Technologies"}, - {0x0002, "GenuineIntel", "Intel"}, - {0x0003, "AuthenticAMD", "AMD"}, - {0x0003, "AMD ISBETTER", "AMD"}, - {0x0004, "CentaurHauls", "Centaur (IDT / VIA)"}, - {0x0005, "CyrixInstead", "Cyrix (VIA)"}, - {0x0006, "GenuineTMx86", "Transmeta"}, - {0x0007, "Geode by NSC", "National Semiconductor"}, - {0x0008, "NexGenDriven", "NexGen"}, - {0x0009, "RiseRiseRise", "Rise"}, - {0x000A, "SiS SiS SiS ", "SiS"}, - {0x000B, "UMC UMC UMC ", "UMC"}, -}; - -typedef struct { - long long id; - bool verified; - char* name; -} PROCLIST; - - - -PROCLIST ProcessorList[] = -{ - {0x00FFFFFF, false, "Unknown x86 Processor"}, - {0x0000FFFF, false, "Unknown 8086 Compatible Processor"}, - {0x0001FFFF, false, "Unknown 186 Compatible Processor"}, - {0x0002FFFF, false, "Unknown 286 Compatible Processor"}, - {0x0003FFFF, false, "Unknown 386 Compatible Processor"}, - {0x0004FFFF, false, "Unknown 486 Compatible Processor"}, - {0x0005FFFF, false, "Unknown 586 Compatible Processor"}, - {0x0006FFFF, false, "Unknown 686 Compatible Processor"}, - {0x02FFFFFF, false, "Unknown Intel Processor"}, - {0x0203FFFF, false, "Unknown Intel i386 Processor"}, - {0x0204FFFF, false, "Unknown Intel i486 Processor"}, - {0x0205FFFF, false, "Unknown Intel Pentium Processor"}, - {0x020501FF, false, "Intel Pentium Classic"}, - {0x020502FF, false, "Intel Pentium"}, - {0x020503FF, false, "Intel Pentium OverDrive"}, - {0x020504FF, false, "Intel Pentium MMX"}, - {0x020507FF, false, "Intel Pentium Mobile"}, - {0x020508FF, false, "Intel Pentium MMX Mobile 'Tillamook'"}, - {0x0206FFFF, false, "Unknown Intel P6 Processor"}, - {0x020601FF, false, "Intel Pentium Pro"}, - {0x020603FF, false, "Unknown Intel Pentium II"}, - {0x02060301, false, "Intel Pentium II 'Klamath'"}, /* 0512 - 0512 */ - {0x02060305, false, "Intel Pentium II OverDrive"}, /* OVERDRIVE */ - {0x020605FF, false, "Unknown Intel Pentium II"}, - {0x02060500, false, "Intel Celeron II 'Covington'"}, /* 0000 - 0000 */ - {0x02060501, false, "Intel Pentium II 'Deschutes'"}, /* 0512 - 0512 */ - {0x02060502, false, "Intel Xeon II 'Drake'"}, /* 0512 - 2048 */ - {0x02060504, false, "Intel Pentium II Mobile 'Tonga'"}, /* 0512 - 0512 */ - {0x020606FF, false, "Unknown Intel Pentium II"}, - {0x02060600, false, "Intel Celeron II 'Mendocino'"}, /* 0128 - 0128 */ -/**/ {0x02060603, false, "Intel Celeron II Mobile"}, /* 0128 - 0128 (A) */ - {0x02060604, false, "Intel Pentium II Mobile 'Dixon'"}, /* 0256 - 0256 (A) */ - {0x020607FF, false, "Unknown Intel Pentium III"}, - {0x02060701, false, "Intel Pentium III 'Katmai'"}, /* 0512 - 0512 */ - {0x02060702, false, "Intel Xeon III 'Tanner'"}, /* 0512 - 2048 */ - {0x020608FF, false, "Unknown Intel Pentium III"}, - {0x02060801, false, "Intel Celeron III 'Coppermine'"}, - {0x02060802, false, "Intel Pentium III (Mobile) 'Coppermine'"}, - {0x02060803, false, "Intel Xeon III 'Cascades'"}, - {0x020609FF, false, "Unknown Intel Pentium M"}, - {0x02060916, false, "Intel Pentium M 'Banias'"}, - {0x02060AFF, false, "Unknown Intel Pentium III"}, - {0x02060A03, false, "Intel Xeon III 'Cascades'"}, - {0x02060BFF, false, "Unknown Intel Pentium III"}, - {0x02060B03, false, "Intel Celeron III 'Tualatin'"}, - {0x02060B04, false, "Intel Pentium III 'Coppermine'"}, - {0x02060B06, false, "Intel Pentium III Mobile 'Geyserville'"}, - {0x02060B07, false, "Intel Celeron III Mobile 'Geyserville'"}, - {0x0207FFFF, false, "Unknown Intel Itanium"}, - {0x020FFFFF, false, "Unknown Intel NetBurst Processor"}, - {0x020F0008, false, "Intel Pentium 4 'Willamette'"}, - {0x020F000E, false, "Intel Xeon 4 'Foster'"}, - {0x020F0108, false, "Intel Pentium 4 'Willamette'"}, - {0x020F0109, false, "Intel Pentium 4 'Willamette'"}, - {0x020F010A, false, "Intel Celeron 4 'Willamette'"}, - {0x020F010B, false, "Intel Xeon 4 MP 'Foster'"}, - {0x020F010E, false, "Intel Xeon 4 'Foster'"}, - {0x020F020C, false, "Intel Xeon 4 MP 'Gallatin'"}, - {0x020F0208, false, "Intel Celeron 4 Mobile 'Northwood'"}, - {0x020F0209, false, "Intel Pentium 4 'Northwood'"}, - {0x020F020B, false, "Intel Xeon 4 'Prestonia'"}, - {0x020F020E, false, "Intel Pentium 4 Mobile 'Northwood'"}, - {0x020F020A, false, "Intel Celeron 4 'Northwood'"}, - {0x0210FFFF, false, "Unknown Intel Itanium 2"}, - {0x03FFFFFF, false, "Unknown AMD Processor"}, - {0x0306FFFF, false, "Unknown AMD Athlon Processor"}, - {0x030601FF, false, "AMD Athlon 'Pluto'"}, - {0x030602FF, false, "AMD Athlon 'Argon'"}, - {0x030603FF, false, "AMD Duron 'Spitfire'"}, - {0x030604FF, false, "AMD Athlon 'Thunderbird'"}, - {0x030605FF, false, "AMD Athlon Ultra 'Mustang'"}, - {0x030606FF, false, "AMD Athlon MP 'Palomino'"}, - {0x030606FF, false, "AMD Athlon XP/MP 'Palomino'"}, - {0x030606FF, false, "AMD Athlon 4 Mobile 'Palomino'"}, - {0x030607FF, false, "AMD Duron 'Morgan'"}, - {0x030607FF, false, "AMD Duron MP 'Morgan'"}, - {0x030607FF, false, "AMD Duron Mobile 'Morgan'"}, - {0x030608FF, false, "AMD Athlon XP 'Thoroughbred'"}, - {0x030608FF, false, "AMD Athlon MP 'Thoroughbred'"}, - {0x030608FF, false, "AMD Athlon XP Mobile 'Thoroughbred'"}, - {0x030609FF, false, "AMD Duron 'Appaloosa'"}, - {0x030609FF, false, "AMD Duron MP 'Appaloosa'"}, - {0x030609FF, false, "AMD Duron Mobile 'Appaloosa'"}, - {0x03060AFF, false, "AMD Athlon XP 'Barton'"}, - {0x03060AFF, false, "AMD Athlon MP 'Barton'"}, - {0x04FFFFFF, false, "Unknown IDT / VIA Processor"}, - {0x0405FFFF, false, "Unknown IDT WinChip"}, - {0x040504FF, false, "IDT WinChip C6"}, - {0x040508FF, false, "IDT WinChip 2"}, - {0x040509FF, false, "IDT WinChip 3"}, - {0x0406FFFF, false, "Unknown VIA C3"}, - {0x040606FF, false, "VIA C3 'Samuel 1' / VIA Eden 4000"}, - {0x040607FF, false, "VIA C3 'Samuel 2 / Ezra' / VIA Eden 5000 / VIA Eden 6000"}, /* 0-7 / 8-F */ - {0x040608FF, false, "VIA C3 'Ezra-T' (VIA Eden 7000)"}, -// {0x040609FF, false, "VIA C3 'Nehalem VIA Eden 8000"}, - {0x05FFFFFF, false, "Unknown Cyrix Processor"}, - {0x0506FFFF, false, "Unknown VIA Cyrix III"}, - {0x050605FF, false, "VIA Cyrix III 'Joshua'"}, - {0x06FFFFFF, false, "Unknown Transmeta Processor"}, - {0x0604FFFF, false, "Transmeta Crusoe 3x00 / 5x00 Processor"}, - {0x08FFFFFF, false, "Unknown NexGen Processor"}, - {0x0805FFFF, false, "Unknown NexGen Nx586 / Nx686 Processor"}, - {0x080500FF, false, "Unknown NexGen Nx586"}, - {0x08050000, false, "NexGen Nx586"}, - {0x08050001, false, "NexGen Nx586FP"}, - //{0x0805??FF, false, "Unknown NexGen Nx686"}, - {0x0CFFFFFF, false, "Unknown UMC Processor"}, - {0x0C04FFFF, false, "Unknown UMC 486 Processor"}, - {0x0C0401FF, false, "UMC U5SD"}, - {0x0C0402FF, false, "UMC U5S"}, - {0x0C0403FF, false, "UMC U486DX2"}, - {0x0C0405FF, false, "UMC U486SX2"}, - - - - - - - - - {0xABCDABCD, false, "XXX"} -}; - - -#if 0 - /**********************************************************************************************/ -// {"GenuineIntel", 0x05, 0x00, 0x0?, 0, false, "Intel Pentium Classic (A*)"}, -// {"GenuineIntel", 0x05, 0x01, 0x02, 0, false, "Intel Pentium Classic (B*)"}, -// {"GenuineIntel", 0x05, 0x01, 0x04, 0, false, "Intel Pentium Classic (B2)"}, -// {"GenuineIntel", 0x05, 0x04, 0x01, 0, false, "Intel Pentium MMX (A1)"}, -// {"GenuineIntel", 0x05, 0x04, 0x02, 0, false, "Intel Pentium MMX (A2)"}, -// {"GenuineIntel", 0x05, 0x05, 0x0?, 0, false, "Intel Pentium MMX OverDrive"}, -// {"GenuineIntel", 0x05, 0x06, 0x0?, 0, false, "Intel Pentium MMX OverDrive"}, -// {"GenuineIntel", 0x06, 0x00, 0x0?, 0, false, "Intel Pentium Pro (A0)"}, -// {"GenuineIntel", 0x06, 0x04, 0x0?, 0, false, "Intel Pentium II OverDrive (?)"}, -// {"GenuineIntel", 0x0F, 0x02, 0x07, 0x0E, false, "Intel Pentium 4 Mobile (C1)"}, -// {"AuthenticAMD", 0x06, 4, 4, 0, false, "AMD Athlon 'Thunderbird' Model 4 (B0)"}, //??Grzegorz -// {"AuthenticAMD", 0x06,5?, ?, 0, false, "AMD Athlon Ultra 'Mustang' Model 5? (??)"}, /* CANCELED */ - -// {"GenuineIntel",F?,3?, ?, ?, "Intel Pentium 4 'Prescott' (??)"}, //.09 -// {"GenuineIntel",F?,3?, ?, ?, "Intel Xeon 4 'Nocona' (??)"}, //.09 -// {"GenuineIntel",F?,4?, ?, ?, "Intel Pentium 4 'Tyler' (??)"}, -// {"GenuineIntel",F?,4?, ?, ?, "Intel Pentium 4 'Tejas' (??)"}, -// {"GenuineIntel",F?,4?, ?, ?, "Intel Xeon 4 'Potomac' (??)"}, - -//GI Nehalem Pentium 5 - - -// {"GenuineIntel", ?,?, ?, ?, "Intel Mobillium 'Banias' (??)"}, -// {"GenuineIntel", ?,?, ?, ?, "Intel Mobillium 'Dothan' (??)"}, -// {"GenuineIntel", ?,?, ?, ?, "Intel Mobillium 'Morem' (??)"}, /* Next GEN!!!! */ -// {"GenuineIntel", ?,?, ?, ?, "Intel Mobillium 'Gilo' (??)"}, /* Next GEN!!!! */ -// Intel's truly mobile processor. Intel says this is a completly new processor. Sources say it's just -// a rework of the PIII or P4. I don't believe this, beacause it has SSE2 (not in PIII) and is faster -// than the P4. I guess they just shortened the enormous 20 stage P4 pipeline a bit, which is too long -// to be used effecivly. More backup is provided for the fact that the Pentium 5 will be based upon -// this chip. And another thing many sources will tell you this chip will be called 'Intel Banias', -// didn't Intel call the Pentium III, Intel Katmai for a very long time. With this in mind it wouldn't -// even surprise me if this processor is goin to be called Pentium 5. Sorry but I have to go one now -// I'm brainstorming. The mobile part of it might not even be used for mobile computers, but for -// desktops and servers as well, because cooling has become almost impossible today. If speeds are -// going to get even higher the next couple of years, the processor cores will just melt. Because -// AMD's processors get even hotter and isn't working on a similar project Intel might even regain -// it's market monopoly (wheter this is good or bad, I don't know?) -// {"GenuineIntel",F?,?, ?, ?, "Intel Pentium 5 'Nehalem' (??)"}, -// This is just a rumor. It's supposed to come out in 2006, run at 6Ghz and have a bus speed of -// 1.5Ghz. It COULD be using the Intel Banias core. Suggesting the Banias is a Pentium 5 and that it -// IS completely new. IF you read the note above this could also be the Pentium 6 or something. -// {"GenuineIntel", 7, 6, 4, 0, "Intel Itanium 'Merced' (C0)"}, //0007000604 -// {"GenuineIntel", 7, 7, 4, 0, "Intel Itanium 'Merced' (C1)"}, //0007000704 -// {"GenuineIntel", 7, 7, 4, 0, "Intel Itanium 'Merced' (C2)"}, //0007000804 -// {"GenuineIntel", 0x10, 0, ?, 0, "Intel Itanium 2 'McKinley' (B3)"}, //001F000704 -// {"GenuineIntel",A?, ?, ?, ?, ???, "Intel Itanium 2 'Madison' (??)"}, -// {"GenuineIntel",A?, ?, ?, ?, ???, "Intel Itanium 2 'Deerfield' (??)"},XXX -// {"GenuineIntel",A?, ?, ?, ?, ???, "Intel Itanium 2 'Montecito' (??)"} -// {"GenuineIntel",A?, ?, ?, ?, ???, "Intel Itanium 2 'Shavano' (??)"}, -// {"GenuineIntel",A?, ?, ?, ?, ???, "Intel Itanium 2? 'Yosemite' (??)"}, -// {"GenuineIntel",A?, ?, ?, ?, ???, "Intel Itanium 2? 'Tanglewood' (??)"}, - -// {"AuthenticAMD", ?, ?, ?, ?, "AMD Athlon XP64 / Hammer 'Clawhammer' (??)"}, -// {"AuthenticAMD", ?, ?, ?, ?, "AMD Athlon XP64 / Hammer 'San Diego' (??)"}, -// {"AuthenticAMD", ?, ?, ?, ?, "AMD Athlon XP64 / Hammer Mobile 'Odessa' (??)"}, -// {"AuthenticAMD", ?, ?, ?, ?, "AMD Opteron 'Sledgehammer' (??)"}, -// {"AuthenticAMD", ?, ?, ?, ?, "AMD Opteron 'Athens' (??)"}, -// {"CentaurHauls", 0x05, 0x08, 0x01, 0x00, false, "IDT WinChip 2"}, -// {"CentaurHauls", 6, 0xA, ?, 0, "IDT WinChip 4"}, //PROBABLY DOESN'T EXIST! -> Is a VIA C3!!! - - /** Intel 8086 / 8088 (Includes model manufactured by AMD, Harris, Siemens, Hitachi) ************/ - - //I belive there an alroithm to identify the diff between HMOS and CMOS models - {"GenuineIntel", 1, 0, 0, 0, false, "Intel 8088"}, - {"GenuineIntel", 1, 0, 0, 1, false, "Intel 8086"}, - {"GenuineIntel", 1, 0, 0, 2, false, "Intel 80C88"}, - {"GenuineIntel", 1, 0, 0, 3, false, "Intel 80C86"}, - {"GenuineIntel", 1, 0, 0, 4, false, "Intel 80188"}, //XL/EA/EB/EC AMD/Siemens - {"GenuineIntel", 1, 0, 0, 5, false, "Intel 80186"}, //XL/EA/EB/EC AMD/Siemens - {"GenuineIntel", 1, 0, 0, 6, false, "NEC V20"}, //V20H/V25/V25 Plus/V25 Softwae Guard/V40/V40H//V45 - {"GenuineIntel", 1, 0, 0, 7, false, "NEC V30"}, //V30H/V35/V35 Plus/V35 Softwae Guard/V50/V50H//V55 - //Intel 80886??? - - {"GenuineIntel", 2, 0, 0, 0, false, "Intel 80286"},//amd/harris/siemens/fujitsu/kruger - - - /** Intel 386 ***********************************************************************************/ - - - //The 386 use a very different format: Family (8-bits!) + Revision (8-bits! Model+Stepping) - //Not to myself: The high four bits of the family should coume in the extra field - //These chips were also munufactured by AMD!!! They are affected by the POPAD bug???? - //Old (sigma-pi) i386 have 32-bit multipy bug - //C&T 38600DX do not have POPAD bug. IBM 386SLC unknwon - //AMD 386DX & DXL hav Intel microcode - //AMD 386DXLV & SXLV hav UMOV??? - //Nx586 has no AC has 386 instr set - - //Erly modles (A stepping) as Famuly: 0, Revision: ??? (In Intel Docs! Support the 'Bit Instrucs') - //0300 - // * Intel i386DX : F0 - {"GenuineIntel", 3, 0, 3, 0, false, "Intel i386DX (B0/B1/B2/B3/B4/B5/B6/B7/B8/B9/B10)"}, - {"GenuineIntel", 3, 0, 4, 0, false, "Intel i386DX (C???)"}, // Stepping not confiremed - {"GenuineIntel", 3, 0, 5, 0, false, "Intel i386DX (D0)"}, - {"GenuineIntel", 3, 0, 8, 0, false, "Intel i386DX (D1/D2/E0/E1/F0)"}, //E0/E1/F0 coulld also be 9!!! - - //The family 23 could also simply be 3 (I don't know were the 2 stands for???) Officialy not part - //Difference between DX and SX perhaps (I hope so) - // * Intel i386CX/SXSA : A2 / B - // * Intel i386EX : A0 / B1 / B2 - {"GenuineIntel",23, 0, 4, 0, false, "Intel i386SX (A0)"}, - {"GenuineIntel",23, 0, 5, 0, false, "Intel i386SX (B)"}, - {"GenuineIntel",23, 0, 8, 0, false, "Intel i386SX (C/D/E)"}, - {"GenuineIntel",23, 0, 8, 0, false, "Intel i386CXSA/B (A) / i386EX (A) / i386SXSA (?)"}, //A || B - {"GenuineIntel",23, 0, 9, 0, false, "Intel i386SX (?)"}, //EMBEDDED (CX/FX - {"GenuineIntel",23, 0, 9, 0, false, "Intel i386EX (A0/B1/C1)"}, - - //Dito for 33 (376 perhaps) - {"GenuineIntel",33, 0, 5, 0, false, "Intel i376 (A0)"}, //Never used in PC because they only work in PM - {"GenuineIntel",33, 0, 8, 0, false, "Intel i376 (B)"}, //... - - //And againt for 43 (386SL) - //have a signatur register @ 30e - //step level A0: 0x4300, - //step level A1: 0x4300, - //step level A2: 0x4301, - //step level A3: 0x4302, - //step level B0: 0x4310, - //step level B1: 0x4311. -// {"GenuineIntel",43, 0, 5, ?, false, "Intel i386SL (B)"}, -// {"GenuineIntel",43, 0, 5, ?, false, "Intel i386SL (A0/A1/A2/A3)"}, //Not sure about this -// {"GenuineIntel",43, 1, 0, 0, false, "Intel i386SL (A0/A1/A2/A3)"}, -// {"GenuineIntel",43, 1, 1, 0, false, "Intel i386SL (B0/B1)"}, - - //RapidCADs are not so familiar to me, where they ever used in PCs??? - {"GenuineIntel", 3, 4, 0, 0, false, "Intel RapidCAD (A)"}, - {"GenuineIntel", 3, 4, 1, 0, false, "Intel RapidCAD (B)"}, - - - /** Intel 486 ***********************************************************************************/ - - //According to Intel only SL Enhanced and WB Enhanced processors support CPUID - - {"GenuineIntel", 4, 0, 0, 0, false, "Intel i486DX (A0/A1)"}, - {"GenuineIntel", 4, 0, 1, 0, false, "Intel i486DX (B2/B3/B4/B5/B6)"}, - {"GenuineIntel", 4, 0, 2, 0, false, "Intel i486DX (C0)"}, - {"GenuineIntel", 4, 0, 3, 0, false, "Intel i486DX (C1)"}, - {"GenuineIntel", 4, 0, 4, 0, false, "Intel i486DX (D0)"}, -// {"GenuineIntel", 4, 0, ?, 0, false, "Intel i486DX"}, - - {"GenuineIntel", 4, 1, 0, 0, false, "Intel i486DX (cA2/cA3)"}, - {"GenuineIntel", 4, 1, 1, 0, false, "Intel i486DX (cB0/cB1)"}, - {"GenuineIntel", 4, 1, 3, 0, false, "Intel i486DX (cC0)"}, - {"GenuineIntel", 4, 1, 4, 0, false, "Intel i486DX (aA0/aA1)"}, //SL Enhanced - {"GenuineIntel", 4, 1, 5, 0, false, "Intel i486DX (aB0)"}, //SL Enhanced -// {"GenuineIntel", 4, 1, ?, 0, false, "Intel i486DX"}, - - {"GenuineIntel", 4, 2, 0, 0, false, "Intel i486SX / i487SX (A0)"}, //Should 487 be model 3 - {"GenuineIntel", 4, 2, 1, 0, false, "Intel i487SX (B0)"}, //Should 487 be model 3 - {"GenuineIntel", 4, 2, 2, 0, false, "Intel i486SX (B0)"}, - {"GenuineIntel", 4, 2, 3, 0, false, "Intel i486SX (bBx)"}, //SL Enhanced and... CPUID - {"GenuineIntel", 4, 2, 4, 0, false, "Intel i486SX (gAx)"}, - {"GenuineIntel", 4, 2, 7, 0, false, "Intel i486SX (cA0)"}, - {"GenuineIntel", 4, 2, 8, 0, false, "Intel i486SX (cB0)"}, - {"GenuineIntel", 4, 2, 0xA, 0, false, "Intel i486SX (aA0/aA1)"}, //SL Enhanced - {"GenuineIntel", 4, 2, 0xB, 0, false, "Intel i486SX (aB0/aC0)"}, //SL Enhanced - {"GenuineIntel", 4, 2, 0xE, 0, false, "Intel i486SX (E)"}, //SL Enhanced??? Grzegorz -// {"GenuineIntel", 4, 2, ?, 0, false, "Intel i486SX"}, - -// {"GenuineIntel", 4, 3, ?, 0, false, "Intel i486DX2 / i486DX2 OverDrive / i487"}, - {"GenuineIntel", 4, 3, 2, 0, false, "Intel i486DX2 (A0/A1/A2)"}, - {"GenuineIntel", 4, 3, 3, 0, false, "Intel i486DX2 (B1)"}, - {"GenuineIntel", 4, 3, 4, 0, false, "Intel i486DX2 (aA0/aA1)"}, //SL Enhanced - {"GenuineIntel", 4, 3, 5, 0, false, "Intel i486DX2 (aB0/aC0)"}, //SL Enhanced - {"GenuineIntel", 4, 3, 6, 0, false, "Intel i486DX2"}, //Possibly as WB in WT Mode - - {"GenuineIntel", 4, 4, 0, 0, false, "Intel i486SL (A)"}, - {"GenuineIntel", 4, 4, 1, 0, false, "Intel i486SL (?)"}, - {"GenuineIntel", 4, 4, 3, 0, false, "Intel i486SL (?)"}, //In Intel Docs, saupoosed to support CPUID -// {"GenuineIntel", 4, 4, ?, 0, false, "Intel i486SL"}, - -// {"GenuineIntel", 4, 5, ?, 0, false, "Intel i486SX2"}, - {"GenuineIntel", 4, 5, 0xB, 0, false, "Intel i486SX2 (aC0)"}, //SL Enhanced - - {"GenuineIntel", 4, 7, 0, 0, false, "Intel i486DX2-WB (A)"}, - {"GenuineIntel", 4, 7, 3, 0, false, "Intel i486DX2-WB (?)"}, //In Intel Docs, saupoosed to support CPUID -// {"GenuineIntel", 4, 7, ?, 0, false, "Intel i486DX2-WB"}, - - {"GenuineIntel", 4, 8, 0, 0, false, "Intel i486DX4 (A)"}, - {"GenuineIntel", 4, 8, 0, 1, false, "Intel i486DX4 OverDrive (A)"}, - {"GenuineIntel", 4, 8, 3, 0, false, "Intel i486DX4 (A)"}, //Possibly as WB in WT Mode, Support CPUID -// {"GenuineIntel", 4, 8, ?, 0, false, "Intel i486DX4 / i486DX4 OverDrive"}, - - {"GenuineIntel", 4, 9, 0, 0, false, "Intel i486DX4-WB (A)"}, //(Do not exist according to Intel CPUID Inf) -// {"GenuineIntel", 4, 9, ?, 0, false, "Intel i486DX4-WB"}, - - - /** AMD *****************************************************************************************/ - - {"AuthenticAMD", 4, 1, 2, 0, false, "AMD 486DX"}, - {"AuthenticAMD", 4, 3, 2, 0, false, "AMD 486DX/2"}, //DX4 (WT2x) toooo && DXL2 / DX4NV8T - {"AuthenticAMD", 4, 3, 4, 0, false, "AMD 486DX/2"}, //DX4 (WT2x) toooo && DXL2 / DX4SV8B -// {"AuthenticAMD", 4, 7, ?, 0, false, "AMD 486DX/2-WB"}, //DX4 (WB2x) - {"AuthenticAMD", 4, 7, 4, 0, false, "AMD SV8B (WT)"}, -// {"AuthenticAMD", 4, 8, ?, 0, false, "AMD 486DX/4"}, //5x86 toooo - {"AuthenticAMD", 4, 8, 4, 0, false, "AMD 486DX/4"}, //3xWT - {"AuthenticAMD", 4, 9, 4, 0, false, "AMD 486DX/4-WB"}, //3xWB - {"AuthenticAMD", 4, 0xE, 4, 0, false, "AMD Am5x86-WT"}, //AMD Enhanced 486 - {"AuthenticAMD", 4, 0xF, 4, 0, false, "AMD Am5x86-WB (4)"}, //AMD Enhanced 486 - - //cores: 5.0 / 5.0 (MMX) / 5.1 / 5.2 - {"AuthenticAMD", 5, 0, 0, 0, false, "AMD K5 SSA/5 (E)"}, //??? Stepping Name - {"AuthenticAMD", 5, 0, 1, 0, false, "AMD K5 SSA/5 (F)"}, //??? Stepping Name -// {"AuthenticAMD", 5, 0, ?, 0, false, "AMD K5 SSA/5 (?)"}, //??? Stepping Name -// {"AuthenticAMD", 5, 1, ?, 0, false, "AMD K5 5k86 Model 1 (?)"}, //??? Stepping Name - {"AuthenticAMD", 5, 1, 1, 0, false, "AMD K5 5k86 Model 1 (?)"}, //??? Stepping Name - {"AuthenticAMD", 5, 1, 2, 0, false, "AMD K5 5k86 Model 1 (?)"}, //??? Stepping Name - {"AuthenticAMD", 5, 1, 4, 0, false, "AMD K5 5k86 Model 1 (?)"}, //CLKMUL=1.5 -// {"AuthenticAMD", 5, 2, ?, 0, false, "AMD K5 5k86 Model 1 (?)"}, //??? Stepping Name - {"AuthenticAMD", 5, 2, 4, 0, false, "AMD K5 5k86 Model 2 (?)"}, //CLKMUL=1.75 -// {"AuthenticAMD", 5, 3, ?, 0, false, "AMD K5 5k86 Model 3 (?)"}, //??? Stepping Name (NOT RELEASED) - {"AuthenticAMD", 5, 3, 4, 0, false, "AMD K5 5k86 Model 1 (?)"}, //CLKMUL=2.0 - - - //Missing: MobileS (= k6-7!!!) / K6-2+ n/ K6-III+ - {"AuthenticAMD", 5, 6, 1, 0, false, "AMD-K6 Model 6 (B)"}, - {"AuthenticAMD", 5, 6, 2, 0, false, "AMD-K6 Model 6 (C)"}, - {"AuthenticAMD", 5, 7, 0, 0, false, "AMD-K6 Model 7 'Little Foot' (A)"}, - {"AuthenticAMD", 5, 8, 0, 0, false, "AMD-K6-2 Model 8 'Chomper' (A0)"}, //doesnt CXT stnd fr Chomber XT -// {"AuthenticAMD", 5, 8, 8, 0, false, "AMD-K6-2 Model 8 'Chomper' (AC)"}, //In Recognition < CXT - {"AuthenticAMD", 5, 8, 0xC, 0, false, "AMD-K6-2 Model 8 'Chomper' (AC)"}, //CXT Core (Write COmbining) I believe YES!!! avvording to Chase - {"AuthenticAMD", 5, 9, 1, 0, false, "AMD-K6-III 'Sharptooth' Model 9 (B)"}, -// {"AuthenticAMD", 5, 0xD, ?, 0, false, "AMD-K6-2+ / K6-III+ 'Sharptooth' (?)"}, //Not doced by AMD (3DNow!+) - -//* {"AuthenticAMD", 6, 0, ?, 0, "AMD K7 [ES]"}, //UNDOCUMENTED!?! - - - /* Cyrix **************************************************************************************/ - - //My sources are unreliable at best for these suckers, so I list them all - //Also I belive the names aren't entire ly correct, confused codename/ actualt name and extensions - - {"CyrixInstead", 0, 0, 5, 0, false, "Cyrix M5 Cx486S/D"}, //No CPUID I believe (is family correct?) - {"CyrixInstead", 0, 0, 6, 0, false, "Cyrix M6 Cx486DX"}, //... - {"CyrixInstead", 0, 0, 7, 0, false, "Cyrix M7 Cx486DX2"}, //... - {"CyrixInstead", 0, 0, 8, 0, false, "Cyrix M8 Cx486DX4"}, - //... - - {"CyrixInstead", 4, 1, 0, 0, false, "Cyrix 4x86SLC"}, -// {"CyrixInstead", 4, 2, ?, 0, false, "Cyrix 5x86"}, - {"CyrixInstead", 4, 2, 9, 0, false, "Cyrix 5x86 (Rev 1-)"}, //Bus *2 - {"CyrixInstead", 4, 2, 0xB, 0, false, "Cyrix 5x86 (Rev 1-)"}, //Bus *2 - {"CyrixInstead", 4, 2, 0xD, 0, false, "Cyrix 5x86 (Rev 1-)"}, //Bus *3 - {"CyrixInstead", 4, 2, 0xF, 0, false, "Cyrix 5x86 (Rev 1-)"}, //Bus *3 -// {"CyrixInstead", 4, 4, ?, 0, false, "Cyrix MediaGX"}, - {"CyrixInstead", 4, 9, 0, 0, false, "Cyrix 5x86 (Rev 2+)"}, -// {"CyrixInstead", 4, 9, ?, 0, false, "Cyrix 5x86"}, - - -// IBM ID=15h Top (65 KB JPG) and Bottom (104 KB JPG) -// IBM ID=17h Top (71 KB JPG) and Bottom (110 KB JPG) -// Cyrix ID=17h Top (63 KB JPG) and Bottom (102 KB JPG) -// IBM ID=22h Top (82 KB JPG) and Bottom (99 KB JPG) -// {"CyrixInstead", 5, 0, ?, 0, false, "Cyrix M1 (6x86)"}, //Grzegorz - {"CyrixInstead", 5, 2, 0, 0, false, "Cyrix M1 (6x86)"}, //Early Models (L / non-L versions???? (LV too)) -// {"CyrixInstead", 5, 2, ?, 0, false, "Cyrix M1 (6x86)"}, //Early Models (L / non-L versions???? (LV too)) - {"CyrixInstead", 5, 3, 0, 0, false, "Cyrix M1 (6x86)"}, //1.0x Bus Ratio - {"CyrixInstead", 5, 3, 1, 0, false, "Cyrix M1 (6x86)"}, //2.0x Bus Ratio - {"CyrixInstead", 5, 3, 2, 0, false, "Cyrix M1 (6x86)"}, //1.0x Bus Ratio - {"CyrixInstead", 5, 3, 3, 0, false, "Cyrix M1 (6x86)"}, //2.0x Bus Ratio - {"CyrixInstead", 5, 3, 4, 0, false, "Cyrix M1 (6x86)"}, //3.0x Bus Ratio - {"CyrixInstead", 5, 3, 5, 0, false, "Cyrix M1 (6x86)"}, //4.0x Bus Ratio - {"CyrixInstead", 5, 3, 6, 0, false, "Cyrix M1 (6x86)"}, //3.0x Bus Ratio - {"CyrixInstead", 5, 3, 7, 0, false, "Cyrix M1 (6x86)"}, //4.0x Bus Ratio -// {"CyrixInstead", 5, 4, ?, 0, false, "Cyrix MediaGX MMX"}, - - -// ID=02h Top (73 KB JPG) and Bottom (100 KB JPG) -// ID=04h Top (79 KB JPG) and Bottom (106 KB JPG) -// ID=08h Top (66 KB JPG) and Bottom (101 KB JPG) -// ID=53 07 - {"CyrixInstead", 6, 0, 0, 0, false, "Cyrix MII (6x86MX)"}, -// {"CyrixInstead", 6, 0, ?, 0, "Cyrix MII (6x86MX)"}, - - //These guys are actualy a Cyrix M2 with minor enhancemets (3DNow! / better FPU), but who cares, - //they were never taken into procuvtion. Although VIA C3 probalby stands for Cyrix M3 and not, - //Centaur WinChip 3. THey got a WinChip 4 core. Josua was nOT released! Start with samual and Samual 2 then Ezra and Ezra-T - // {"CyrixInstead", 6, 5, 1, 0, false, "VIA Cyrix III 'Joshua'"}, //2.0x Bus Ratio - - //Other names heard: Cyrix M-III 'Mojave' (Chase, so reliable never produced!) - // Cayenne / Gobi / Jalapeno - // Cayenne, then Gobi, then Joshua - - //THE VIA Series!!!!! - //New models : C4 'Nehemia' Has SSE instead of #dnOW! newer modles will be Esther - // CZA is a P4 clone - - /************************************************************************************************/ - - - - - -// I'm not sure about the CNs -// {"RiseRiseRise", 5, 0, ?, 0, "Rise mP6 iDragon '6401?' (Model 0)"}, //0.25 -// {"RiseRiseRise", 5, 0, 4, 0, "Rise mP6 iDragon '6401?' (Model 0)"}, //0.25 -// {"RiseRiseRise", 5, 1, ?, 0, "Rise mP6 iDragon 'Kirin?' (Model 1)"}, -// {"RiseRiseRise", 5, 2, ?, 0, "Rise mP6 iDragon 'Lynx?' (Model 2)"}, //0.18 -// {"RiseRiseRise", 5, 8, ?, 0, "Rise mP6 iDragon II"}, -// {"RiseRiseRise", 5, 9, ?, 0, "Rise mP6 iDragon II"}, -// Rise Tiger = MMX+SSE Unknown Nmae - - -#endif /* 0 */ - -typedef struct __CPU___PROCINFORMATION__ -{ - bool pCertified; - char *pName; - - uint32_t vFamily; - uint32_t vModel; - uint32_t vStepping; - uint32_t vType; - uint32_t vBrand; - char vVendor[13]; - char *vName; - - bool iFloatingPoint; - bool iTranscedental; - bool iCompareExchange64; - bool iConditionalMove; - bool iCLFLUSH; - bool iMMX; - bool iSSE; - bool iSSE2; - bool iSSE3; - bool iMonitor; - bool iFastSystemCall; - bool iFXSR; - bool fVirtualModeExtensions; - bool fDebuggingExtensions; - bool fPageSizeExtensions; - bool fTimeStampCounter; - bool fModelSpecificRegisters; - bool fPhysicalAddressExtension; - bool fMachineCheckException; - bool fLocalAPIC; - bool fMemoryTypeRangeRegisters; - bool fPageGlobalEnable; - bool fMachineCheckArchitecture; - bool fPageAttributeTable; - bool fPageSizeExtension; - bool fProcessorSerialNumber; - bool fDebugStore; - bool fACPI; - bool fSelfSnoop; - bool fHyperThreading; - bool fThermalMonitor; - bool fIA64; - bool fSignalBreakOnFERR; - bool fQualifiedDebugStore; - bool fThermalMonitor2; - bool fContextID; - - uint32_t cLineSize; - uint32_t cL1CodeCacheSize; - uint32_t cL1CodeCacheAssociativity; - uint32_t cL1CodeCacheLineSize; - uint32_t cL1CodeCacheLinesPerTag; - uint32_t cL1DataCacheSize; - uint32_t cL1DataCacheAssociativity; - uint32_t cL1DataCacheLineSize; - uint32_t cL1DataCacheLinesPerTag; - uint32_t cL1UnifiedCacheSize; - uint32_t cL1UnifiedCacheAssociativity; - uint32_t cL1UnifiedCacheLineSize; - uint32_t cL1UnifiedCacheLinesPerTag; - uint32_t cL1CodeTLB4KEntries; - uint32_t cL1CodeTLB2MEntries; - uint32_t cL1DataTLB2MEntries; - uint32_t cL1CodeTLB4MEntries; - uint32_t cL1DataTLB4KEntries; - uint32_t cL1DataTLB4MEntries; - uint32_t cL2UnifiedCacheSize; - uint32_t cL2UnifiedCacheAssociativity; - uint32_t cL2UnifiedCacheLineSize; - uint32_t cL2UnifiedCacheLinesPerTag; - uint32_t cL2CodeTLB4KEntries; - uint32_t cL2CodeTLB2MEntries; - uint32_t cL2CodeTLB4MEntries; - uint32_t cL2DataTLB4KEntries; - uint32_t cL2DataTLB2MEntries; - uint32_t cL2DataTLB4MEntries; - uint32_t cL2UnifiedTLB4KEntries; - uint32_t cL2UnifiedTLB2MEntries; - uint32_t cL2UnifiedTLB4MEntries; - uint32_t cL3UnifiedCacheSize; - uint32_t cL3UnifiedCacheAssociativity; - uint32_t cL3UnifiedCacheLineSize; - uint32_t cL3UnifiedCacheLinesPerTag; - - int32_t cL1CodeTLB4KAssociativity; - int32_t cL1CodeTLB2MAssociativity; - int32_t cL1CodeTLB4MAssociativity; - int32_t cL1DataTLB4KAssociativity; - int32_t cL1DataTLB2MAssocitivity; - int32_t cL1DataTLB4MAssociativity; - int32_t cL2CodeTLB4KAssociativity; - int32_t cL2CodeTLB2MAssociativity; - int32_t cL2CodeTLB4MAssociativity; - int32_t cL2DataTLB4KAssociativity; - int32_t cL2DataTLB2MAssociativity; - int32_t cL2DataTLB4MAssociativity; - int32_t cL2UnifiedTLB4KAssociativity; - int32_t cL2UnifiedTLB2MAssociativity; - int32_t cL2UnifiedTLB4MAssociativity; - - bool cTraceCachePresent; - - uint32_t cTraceCacheMicroOps; - uint32_t cTraceCacheAssociativity; - uint32_t uOnChipFPU; - uint32_t uLogicalProcessorCount; - uint32_t uAPICID; - - bool rFeature10; - bool rFeature20; - bool rFeature33; - bool rFeature34; - bool rFeature37; - bool rFeature38; - bool rFeature39; - bool rFeature41; - bool rFeature42; - bool rFeature43; - bool rFeature44; - bool rFeature45; - bool rFeature46; - bool rFeature47; - bool rFeature48; - bool rFeature49; - bool rFeature50; - bool rFeature51; - bool rFeature52; - bool rFeature53; - bool rFeature54; - bool rFeature55; - bool rFeature56; - bool rFeature57; - bool rFeature58; - bool rFeature59; - bool rFeature60; - bool rFeature61; - bool rFeature62; - bool rFeature63; - -} prcInformation; - -void prcInit(void); -void prcIdentify(uint64_t processor, prcInformation* information); -void prcCPUID(uint64_t processor, uint32_t function, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d); -void IdentifyIntelCache(prcInformation* information, int descriptor); -void IdentifyProcessor(prcInformation* information, int Extra); - -typedef union __CPU___PROCINFORMATIONDATA__ -{ - unsigned int d; - unsigned short w[2]; - unsigned char b[4]; -} prcIdentificationData; - -void printf(const char *fmt, ...); - -void init_cpu(void) -{ - prcInformation information; - prcIdentify(0, &information); - //logStatus(logSuccess); - //logSubItem("Processor #0", information.pName); - //logSubItem("MMX", information.iMMX ? "Yes" : "No"); - printf("Proccessor: %s MMX %s", information.pName, information.iMMX ? "Yes" : "No"); -} - -void prcIdentify(uint64_t processor, prcInformation* information) -{ - uint32_t a, b, c, d; - uint32_t highestStandard, highestExtended; - int i, n, Extra; - - /*** 0x00000000 - Vendor **********************/ - prcCPUID(processor, 0x00000000, &a, &b, &c, &d); - - highestStandard = a; - - *((uint32_t*)(information->vVendor + 0)) = b; - *((uint32_t*)(information->vVendor + 4)) = d; - *((uint32_t*)(information->vVendor + 8)) = c; - information->vVendor[12] = '\0'; - - - /*** 0x00000001 - Version and Features ********/ - prcCPUID(processor, 0x00000001, &a, &b, &c, &d); - - information->vStepping = (a & 0x0000000F) >> 0; - information->vModel = (a & 0x000000F0) >> 4; - information->vFamily = (a & 0x00000F00) >> 8; - information->vType = (a & 0x00003000) >> 12; - - if(information->vModel == 0xF) information->vModel += (a & 0x000F0000) >> 16; - if(information->vFamily == 0xF) information->vFamily += (a & 0x0FF00000) >> 20; - - information->uOnChipFPU = (d >> 0) & 0x00000001; - information->fVirtualModeExtensions = (d >> 1) & 0x00000001; - information->fDebuggingExtensions = (d >> 2) & 0x00000001; - information->fPageSizeExtension = (d >> 3) & 0x00000001; - information->fTimeStampCounter = (d >> 4) & 0x00000001; - information->fModelSpecificRegisters = (d >> 5) & 0x00000001; - information->fPhysicalAddressExtension = (d >> 6) & 0x00000001; - information->fMachineCheckException = (d >> 7) & 0x00000001; - information->iCompareExchange64 = (d >> 8) & 0x00000001; - information->fLocalAPIC = (d >> 9) & 0x00000001; - information->rFeature10 = (d >> 10) & 0x00000001; - information->iFastSystemCall = (d >> 11) & 0x00000001; - information->fMemoryTypeRangeRegisters = (d >> 12) & 0x00000001; - information->fPageGlobalEnable = (d >> 13) & 0x00000001; - information->fMachineCheckArchitecture = (d >> 14) & 0x00000001; - information->iConditionalMove = (d >> 15) & 0x00000001; - information->fPageAttributeTable = (d >> 16) & 0x00000001; - information->fPageSizeExtension = (d >> 17) & 0x00000001; - information->fProcessorSerialNumber = (d >> 18) & 0x00000001; - information->iCLFLUSH = (d >> 19) & 0x00000001; - information->rFeature20 = (d >> 20) & 0x00000001; - information->fDebugStore = (d >> 21) & 0x00000001; - information->fACPI = (d >> 22) & 0x00000001; - information->iMMX = (d >> 23) & 0x00000001; - information->iFXSR = (d >> 24) & 0x00000001; - information->iSSE = (d >> 25) & 0x00000001; - information->iSSE2 = (d >> 26) & 0x00000001; - information->fSelfSnoop = (d >> 27) & 0x00000001; - information->fHyperThreading = (d >> 28) & 0x00000001; - information->fThermalMonitor = (d >> 29) & 0x00000001; - information->fIA64 = (d >> 30) & 0x00000001; - information->fSignalBreakOnFERR = (d >> 31) & 0x00000001; - - information->iSSE3 = (c >> 0) & 0x00000001; - information->rFeature33 = (c >> 1) & 0x00000001; - information->rFeature34 = (c >> 2) & 0x00000001; - information->iMonitor = (c >> 3) & 0x00000001; - information->fQualifiedDebugStore = (c >> 4) & 0x00000001; - information->rFeature37 = (c >> 5) & 0x00000001; - information->rFeature38 = (c >> 6) & 0x00000001; - information->rFeature39 = (c >> 7) & 0x00000001; - information->fThermalMonitor2 = (c >> 8) & 0x00000001; - information->rFeature41 = (c >> 9) & 0x00000001; - information->fContextID = (c >> 10) & 0x00000001; - information->rFeature43 = (c >> 11) & 0x00000001; - information->rFeature44 = (c >> 12) & 0x00000001; - information->rFeature45 = (c >> 13) & 0x00000001; - information->rFeature46 = (c >> 14) & 0x00000001; - information->rFeature47 = (c >> 15) & 0x00000001; - information->rFeature48 = (c >> 16) & 0x00000001; - information->rFeature49 = (c >> 17) & 0x00000001; - information->rFeature50 = (c >> 18) & 0x00000001; - information->rFeature51 = (c >> 19) & 0x00000001; - information->rFeature52 = (c >> 20) & 0x00000001; - information->rFeature53 = (c >> 21) & 0x00000001; - information->rFeature54 = (c >> 22) & 0x00000001; - information->rFeature55 = (c >> 23) & 0x00000001; - information->rFeature56 = (c >> 24) & 0x00000001; - information->rFeature57 = (c >> 25) & 0x00000001; - information->rFeature58 = (c >> 26) & 0x00000001; - information->rFeature59 = (c >> 27) & 0x00000001; - information->rFeature60 = (c >> 28) & 0x00000001; - information->rFeature61 = (c >> 29) & 0x00000001; - information->rFeature62 = (c >> 30) & 0x00000001; - information->rFeature63 = (c >> 31) & 0x00000001; - - information->vBrand = (b & 0x000000FF) >> 0; - if(information->iCLFLUSH) - information->cLineSize = (b & 0x0000FF00) >> 8; - if(information->fHyperThreading) - information->uLogicalProcessorCount = (b & 0x00FF0000) >> 16; - if(information->vFamily >= 0xF) - information->uAPICID = (b & 0xFF000000) >> 24; - - /*** 0x00000002 - Cache Descriptors ***********/ - n = 1; - - for(i = 0; i < n; i++) - { - prcCPUID(processor, 0x00000002, &a, &b, &c, &d); - - n = a & 0x000000FF; - - if(!(a & 0x80000000)) - { - IdentifyIntelCache(information, (a >> 8) & 0x000000FF); - IdentifyIntelCache(information, (a >> 16) & 0x000000FF); - IdentifyIntelCache(information, (a >> 24) & 0x000000FF); - } - - if(!(b & 0x80000000)) - { - IdentifyIntelCache(information, (b >> 0) & 0x000000FF); - IdentifyIntelCache(information, (b >> 8) & 0x000000FF); - IdentifyIntelCache(information, (b >> 16) & 0x000000FF); - IdentifyIntelCache(information, (b >> 24) & 0x000000FF); - } - - if(!(c & 0x80000000)) - { - IdentifyIntelCache(information, (c >> 0) & 0x000000FF); - IdentifyIntelCache(information, (c >> 8) & 0x000000FF); - IdentifyIntelCache(information, (c >> 16) & 0x000000FF); - IdentifyIntelCache(information, (c >> 24) & 0x000000FF); - } - - if(!(d & 0x80000000)) - { - IdentifyIntelCache(information, (d >> 0) & 0x000000FF); - IdentifyIntelCache(information, (d >> 8) & 0x000000FF); - IdentifyIntelCache(information, (d >> 16) & 0x000000FF); - IdentifyIntelCache(information, (d >> 24) & 0x000000FF); - } - } - - /*** 0x00000003 - Serial Number ***************/ - - /*** 0x00000004 - Cache Parameters ************/ - - /*** 0x00000005 - Monitor *********************/ - - /** - * THE EXTRA NUMBER - * Type - * Pentium II + III Cache - * Pentium III + 4 Brand ID - * Athlon Multi Processing / Cache - */ - - Extra = information->vType; - - if(!strcmp(information->vVendor, "GenuineIntel") - && information->vFamily == 6 - && information->vModel >= 3 - && information->vModel <= 7) - { - Extra = information->cL2UnifiedCacheSize; - } - - if(!strcmp(information->vVendor, "GenuineIntel") - && information->vFamily == 6 - && information->vModel >= 8) - { - Extra = information->vBrand; - } - - if(!strcmp(information->vVendor, "GenuineIntel") - && information->vFamily == 0xF) - { - Extra = information->vBrand; - } - - if(!strcmp(information->vVendor, "AuthenticAMD") - && information->vFamily == 6) - { - Extra = 0; - } - - IdentifyProcessor(information, Extra); -} - -void prcCPUID(uint64_t processor, uint32_t function, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) -{ - asm - ( - "cpuid" - : "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d) - : "a" (function) - ); -} - -void IdentifyIntelCache(prcInformation* information, int descriptor) -{ - switch(descriptor) - { - case 0x00: - return; - case 0x40: - return; - case 0x01: - information->cL1CodeTLB4KEntries = 32; - information->cL1CodeTLB4KAssociativity = 4; - return; - case 0x02: - information->cL1CodeTLB4MEntries = 2; - information->cL1CodeTLB4MAssociativity = -1; - return; - case 0x03: - information->cL1DataTLB4KEntries = 64; - information->cL1DataTLB4KAssociativity = 4; - return; - case 0x04: - information->cL1DataTLB4MEntries = 8; - information->cL1DataTLB4MAssociativity = 4; - return; - case 0x06: - information->cL1CodeCacheSize = 8; - information->cL1CodeCacheAssociativity = 4; - information->cL1CodeCacheLineSize = 32; - information->cL1CodeCacheLinesPerTag = -1; - return; - case 0x08: - information->cL1CodeCacheSize = 16; - information->cL1CodeCacheAssociativity = 4; - information->cL1CodeCacheLineSize = 32; - information->cL1CodeCacheLinesPerTag = -1; - return; - case 0x0A: - information->cL1DataCacheSize = 8; - information->cL1DataCacheAssociativity = 2; - information->cL1DataCacheLineSize = 32; - information->cL1DataCacheLinesPerTag = -1; - return; - case 0x0C: - information->cL1DataCacheSize = 16; - information->cL1DataCacheAssociativity = 4; - information->cL1DataCacheLineSize = 32; - information->cL1DataCacheLinesPerTag = -1; - return; - case 0x22: - information->cL3UnifiedCacheSize = 512; - information->cL3UnifiedCacheAssociativity = 4; - information->cL3UnifiedCacheLineSize = 64; - information->cL3UnifiedCacheLinesPerTag = -1; - return; - case 0x23: - information->cL3UnifiedCacheSize = 1024; - information->cL3UnifiedCacheAssociativity = 8; - information->cL3UnifiedCacheLineSize = 64; - information->cL3UnifiedCacheLinesPerTag = -1; - return; - case 0x25: - information->cL3UnifiedCacheSize = 2048; - information->cL3UnifiedCacheAssociativity = 8; - information->cL3UnifiedCacheLineSize = 64; - information->cL3UnifiedCacheLinesPerTag = -1; - return; - case 0x29: - information->cL3UnifiedCacheSize = 4096; - information->cL3UnifiedCacheAssociativity = 8; - information->cL3UnifiedCacheLineSize = 64; - information->cL3UnifiedCacheLinesPerTag = -1; - return; - case 0x39: - information->cL2UnifiedCacheSize = 128; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x3B: - information->cL2UnifiedCacheSize = 128; - information->cL2UnifiedCacheAssociativity = 2; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x3C: - information->cL2UnifiedCacheSize = 256; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x41: - information->cL2UnifiedCacheSize = 128; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x42: - information->cL2UnifiedCacheSize = 256; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x43: - information->cL2UnifiedCacheSize = 512; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x44: - information->cL2UnifiedCacheSize = 1024; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x45: - information->cL2UnifiedCacheSize = 2048; - information->cL2UnifiedCacheAssociativity = 4; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x50: - information->cL1CodeTLB4KEntries = 64; - information->cL1CodeTLB4KAssociativity = -1; - information->cL1CodeTLB2MEntries = 64; - information->cL1CodeTLB2MAssociativity = -1; - information->cL1CodeTLB4MEntries = 64; - information->cL1CodeTLB4MAssociativity = -1; - return; - case 0x51: - information->cL1CodeTLB4KEntries = 128; - information->cL1CodeTLB4KAssociativity = -1; - information->cL1CodeTLB2MEntries = 128; - information->cL1CodeTLB2MAssociativity = -1; - information->cL1CodeTLB4MEntries = 128; - information->cL1CodeTLB4MAssociativity = -1; - return; - case 0x52: - information->cL1CodeTLB4KEntries = 256; - information->cL1CodeTLB4KAssociativity = -1; - information->cL1CodeTLB2MEntries = 256; - information->cL1CodeTLB2MAssociativity = -1; - information->cL1CodeTLB4MEntries = 256; - information->cL1CodeTLB4MAssociativity = -1; - return; - case 0x5B: - information->cL1DataTLB4KEntries = 64; - information->cL1DataTLB4KAssociativity = -1; - information->cL1DataTLB4MEntries = 64; - information->cL1DataTLB4MAssociativity = -1; - return; - case 0x5C: - information->cL1DataTLB4KEntries = 128; - information->cL1DataTLB4KAssociativity = -1; - information->cL1DataTLB4MEntries = 128; - information->cL1DataTLB4MAssociativity = -1; - return; - case 0x5D: - information->cL1DataTLB4KEntries = 256; - information->cL1DataTLB4KAssociativity = -1; - information->cL1DataTLB4MEntries = 256; - information->cL1DataTLB4MAssociativity = -1; - return; - case 0x66: - information->cL1DataCacheSize = 8; - information->cL1DataCacheAssociativity = 4; - information->cL1DataCacheLineSize = 64; - information->cL1DataCacheLinesPerTag = -1; - return; - case 0x67: - information->cL1DataCacheSize = 16; - information->cL1DataCacheAssociativity = 4; - information->cL1DataCacheLineSize = 64; - information->cL1DataCacheLinesPerTag = -1; - return; - case 0x68: - information->cL1DataCacheSize = 32; - information->cL1DataCacheAssociativity = 4; - information->cL1DataCacheLineSize = 64; - information->cL1DataCacheLinesPerTag = -1; - return; - case 0x70: - information->cTraceCacheMicroOps = 12; - information->cTraceCacheAssociativity = 8; - return; - case 0x71: - information->cTraceCacheMicroOps = 16; - information->cTraceCacheAssociativity = 8; - return; - case 0x72: - information->cTraceCacheMicroOps = 32; - information->cTraceCacheAssociativity = 8; - return; - case 0x77: - information->cL1CodeCacheSize = 16; - information->cL1CodeCacheAssociativity = 4; - information->cL1CodeCacheLineSize = 64; - information->cL1CodeCacheLinesPerTag = -1; - return; - case 0x79: - information->cL2UnifiedCacheSize = 128; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x7A: - information->cL2UnifiedCacheSize = 256; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x7B: - information->cL2UnifiedCacheSize = 512; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x7C: - information->cL2UnifiedCacheSize = 1024; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 64; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x7E: - information->cL2UnifiedCacheSize = 256; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 128; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x82: - information->cL2UnifiedCacheSize = 128; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x83: - information->cL2UnifiedCacheSize = 256; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x84: - information->cL2UnifiedCacheSize = 512; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x85: - information->cL2UnifiedCacheSize = 1024; - information->cL2UnifiedCacheAssociativity = 8; - information->cL2UnifiedCacheLineSize = 32; - information->cL2UnifiedCacheLinesPerTag = -1; - return; - case 0x8D: - information->cL3UnifiedCacheSize = 3072; - information->cL3UnifiedCacheAssociativity = 12; - information->cL3UnifiedCacheLineSize = 128; - information->cL3UnifiedCacheLinesPerTag = -1; - return; - } - - /*printf("Unknown Intel Cache Descriptor: %x\n", CacheDescriptor);*/ -} - -int AMDAssociativity(int Value) -{ - switch (Value) - { - case 0x00: return 0; - case 0x01: return 1; - case 0x02: return 2; - case 0x04: return 4; - case 0x06: return 8; - case 0x08: return 16; - case 0x0F: return -1; - } - - /*puts("Unknown AMD Cache Descriptor");*/ - return -1; -} - -void IdentifyProcessor(prcInformation* information, int Extra) -{ - int i; - - for(i = 0; i < (sizeof(ProcessorList) / sizeof(PROCLIST)); i++) - { - if(ProcessorList[i].id == 0x02000000 + (information->vFamily << 16) + (information->vModel << 8) + Extra) - { - information->pName = ProcessorList[i].name; - information->pCertified = ProcessorList[i].verified; - return; - } - } - - for(i = 0; i < (sizeof(ProcessorList) / sizeof(PROCLIST)); i++) - { - if(ProcessorList[i].id == 0x020000FF + (information->vFamily << 16) + (information->vModel << 8)) - { - information->pName = ProcessorList[i].name; - information->pCertified = ProcessorList[i].verified; - return; - } - } - - for(i = 0; i < (sizeof(ProcessorList) / sizeof(PROCLIST)); i++) - { - if(ProcessorList[i].id == 0x0200FFFF + (information->vFamily << 16)) - { - information->pName = ProcessorList[i].name; - information->pCertified = ProcessorList[i].verified; - return; - } - } - - for(i = 0; i < (sizeof(ProcessorList) / sizeof(PROCLIST)); i++) - { - if(ProcessorList[i].id == 0x02FFFFFF) - { - information->pName = ProcessorList[i].name; - information->pCertified = ProcessorList[i].verified; - return; - } - } - - information->pName = "Unknown Processor"; - information->pCertified = false; -} diff --git a/Dump/hybos/src/kernel/debug.c b/Dump/hybos/src/kernel/debug.c deleted file mode 100644 index c253857..0000000 --- a/Dump/hybos/src/kernel/debug.c +++ /dev/null @@ -1,54 +0,0 @@ -/*============================================================================ -DEBUG FUNCTIONS - -EXPORTS: -void dump_regs(regs_t *regs); -============================================================================*/ -#include "_krnl.h" - -/* IMPORTS -from MAIN.C */ -void printf(const char *fmt, ...); -/***************************************************************************** -*****************************************************************************/ -#define BPERL 16 /* byte/line for dump */ - -void dump(unsigned char *data, unsigned count) -{ - unsigned char byte1, byte2; - - while(count != 0) - { - for(byte1 = 0; byte1 < BPERL; byte1++) - { - if(count == 0) - break; - printf("%02X ", data[byte1]); - count--; - } - printf("\t"); - for(byte2 = 0; byte2 < byte1; byte2++) - { - if(data[byte2] < ' ') - printf("%c", '.'); - else - printf("%c", data[byte2]); - } - printf("\n"); - data += BPERL; - } -} -/***************************************************************************** -*****************************************************************************/ -void dump_regs(regs_t *regs) -{ - printf("EDI=%08X ESI=%08X EBP=%08X ESP=%08X\n", - regs->edi, regs->esi, regs->ebp, regs->esp); - printf("EBX=%08X EDX=%08X ECX=%08X EAX=%08X\n", - regs->ebx, regs->edx, regs->ecx, regs->eax); - printf(" DS=%08X ES=%08X FS=%08X GS=%08X\n", - regs->ds, regs->es, regs->fs, regs->gs); - printf("int=%08X err=%08X EIP=%08X CS=%08X\n", - regs->which_int, regs->err_code, regs->eip, regs->cs); - printf("uSP=%08X uSS=%08X\n", regs->user_esp, regs->user_ss); -} diff --git a/Dump/hybos/src/kernel/keyboard.c b/Dump/hybos/src/kernel/keyboard.c deleted file mode 100644 index 495f98a..0000000 --- a/Dump/hybos/src/kernel/keyboard.c +++ /dev/null @@ -1,585 +0,0 @@ -/** - * keyboard.c - * - * Main keyboard handling routines. - * - * Exports: - * keyboard_irq(); - * init_keyboard(); - * - * Imports: - * video.c console_t _vc[]; - * video.c select_vc(); - * video.c putch(); - * main.c printf(); - * main.c printk(); - */ - -//#include /* key scancode definitions */ -#include -#include /* outportb, inportb(), etc */ -#include -#include /* shell commands */ -#include "_krnl.h" /* MAX_VC */ -#include "bootlog.h" /* klog() */ - -#define KBD_BUF_SIZE 64 - -/** - * Imports - */ -extern console_t _vc[]; -void select_vc(unsigned which_vc); -void putch(unsigned c); -void printf(const char *fmt, ...); -void printk(int type, const char *fmt, ...); -void dumpheapk(void); -void testheap(void); - -unsigned get_current_vc(); - -static int rawkey, keys[128]; -static int numkeysbuffer; - -static char szInBuf[KBD_BUF_SIZE]; - -/** - * 0 if not set - * 1 if make code - * 2 if break code - */ -static int makebreak; - -/** - * reboot() - * - */ -static void reboot(void) -{ - unsigned temp; - - disable(); - - /** - * flush the keyboard controller - */ - do - { - temp = inportb(0x64); - if((temp & 0x01) != 0) - { - (void)inportb(0x60); - continue; - } - } while((temp & 0x02) != 0); - - /** - * now pulse the cpu reset line - */ - outportb(0x64, 0xFE); - - /** - * if that didn't work, just halt - */ - while(1); -} - -/** - * XXX - * - * I'm not even sure if we need the following functions yet, - * however they are here just in case. Leave them alone. - */ - -/** - * _write_kb() - * - */ -static void _write_kb(unsigned adr, unsigned d) -{ - unsigned long t; - unsigned s; - - for(t = 5000000L; t != 0; t--) - { - s = inportb(0x64); - - /** - * loop until 8042 input buffer is empty - */ - if((s & 0x02) == 0) - break; - } - - if(t != 0) - outportb(adr, d); -} - -/** - * _kb_wait() - * - */ -static inline void _kb_wait(void) -{ - int i; - - for(i = 0; i < 0x1000000; i++) - if((inportb(0x64) & 0x02) == 0) - return; - - printk(0, "Keyboard timeout\n"); -} - -/** - * _kb_send() - * - */ -static inline void _kb_send(unsigned char c) -{ - _kb_wait(); - outportb(c, 0x64); -} - -/** - * _translate_sc() - * - * Translates a scancode from the keyboard - */ -unsigned _translate_sc(unsigned k) -{ - unsigned c; - static unsigned altk; - unsigned donefirst = 0; - - if(k == KEY_BKSPACE) - { - if(numkeysbuffer - 1 < 0) - { - numkeysbuffer = 0; - return 0; - } - } - - switch(k) - { - case 0xE0: - altk = 1; c = 0; donefirst = 1; break; - case KEY_TILDA: /* ` or ~ */ - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 126 : 126; break; - case KEY_END: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 49; break; - case KEY_1: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 33 : 49; break; - case KEY_DOWN: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 50; break; - case KEY_2: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 64 : 50; break; - case KEY_PGDOWN: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 51; break; - case KEY_3: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 35 : 51; break; - case KEY_LEFT: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 52; break; - case KEY_4: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 36 : 52; break; - case KEYP_5: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 53; break; - case KEY_5: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 35 : 53; break; - case KEY_RIGHT: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 54; break; - case KEY_6: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 94 : 54; break; - case KEY_HOME: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 55; break; - case KEY_7: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 38 : 55; break; - case KEY_UP: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 56; break; - case KEYP_ASTERISK: c = 42; break; - case KEY_8: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 42 : 56; break; - case KEY_PGUP: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 57; break; - case KEY_9: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 40 : 57; break; - case KEY_INSERT: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 48; break; - case KEY_0: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 41 : 48; break; - case KEYP_MINUS: c = 45; break; - case KEY_MINUS: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 95 : 45; break; - case KEYP_PLUS: c = 43; break; - case KEY_PLUS: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 61 : 43; break; - case KEY_BKSLASH: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 124 : 92; break; - case KEY_Q: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 81 : 113; break; - case KEY_W: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 87 : 119; break; - case KEY_E: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 69 : 101; break; - case KEY_R: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 82 : 114; break; - case KEY_T: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 84 : 116; break; - case KEY_Y: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 89 : 121; break; - case KEY_U: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 85 : 117; break; - case KEY_I: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 73 : 105; break; - case KEY_O: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 79 : 111; break; - case KEY_P: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 80 : 112; break; - case KEY_LBRACKET: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 123 : 91; break; - case KEY_RBRACKET: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 125 : 93; break; - case KEY_ENTER: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 10 : 10; break; - case KEY_A: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 65 : 97; break; - case KEY_S: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 83 : 115; break; - case KEY_D: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 68 : 100; break; - case KEY_F: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 70 : 102; break; - case KEY_G: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 71 : 103; break; - case KEY_H: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 72 : 104; break; - case KEY_J: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 74 : 106; break; - case KEY_K: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 75 : 107; break; - case KEY_L: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 76 : 108; break; - case KEY_SEMICOLON: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 58 : 59; break; - case KEY_QUOTE: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 34 : 39; break; - case KEY_Z: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 90 : 122; break; - case KEY_X: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 88 : 120; break; - case KEY_C: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 67 : 99; break; - case KEY_V: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 86 : 118; break; - case KEY_B: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 66 : 98; break; - case KEY_N: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 78 : 110; break; - case KEY_M: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 77 : 109; break; - case KEY_COMMA: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 60 : 44; break; - case KEY_DEL: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 46; break; - case KEY_PERIOD: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 62 : 46; break; - case KEY_SLASH: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 63 : 47; break; - case KEY_SPACE: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 32 : 32; break; - case KEY_BKSPACE: c = '\b'; break; /* just for now */ - default: - c = 0; - } - - if(donefirst == 0) - altk = 0; - - if(keys[KEY_CAPS]) - { - if(keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) - { - if(c >= 'A' && c <= 'Z') - c += 32; - } - else - { - if(c >= 'a' && c <= 'z') - c -= 32; - } - } - - /** - * Simple shell for now - */ - if(c != 0 && c != '\n' && c != '\b') - { - if((numkeysbuffer - 1) == KBD_BUF_SIZE) - { - numkeysbuffer = 0; - szInBuf[0] = '\0'; - - szInBuf[numkeysbuffer] = c; - numkeysbuffer++; - } - else - { - szInBuf[numkeysbuffer] = c; - numkeysbuffer++; - } - } - else if(c == '\n') - { - printf("\n"); - /** - * Make it a real string - */ - szInBuf[numkeysbuffer] = '\0'; - - /** - * Process command - */ - processCommand(&szInBuf[0], numkeysbuffer - 1); - - /** - * Clear buffer - */ - numkeysbuffer = 0; - szInBuf[0] = '\0'; - - /** - * Print "line" - */ - printf("$ "); - - c = 0; - } - else if(c == '\b') - { - szInBuf[numkeysbuffer] = '\0'; - numkeysbuffer--; - printf("\b \b"); - - c = 0; - } - - return c; -} - -/** - * handle_meta_key() - * - * I'll pretty this up later - */ -void handle_meta_key(unsigned k) -{ - int i; - k = k; /* to shut gcc up */ - - /** - * Check for the infamous three finger salute - */ - if((keys[KEY_RCTRL] || keys[KEY_LCTRL]) && - (keys[KEY_RALT] || keys[KEY_LALT]) && - keys[KEY_DEL]) - { - /** - * FIXME - * - * This should call _send_signal() - */ - reboot(); - } - - /** - * Check for Alt + F1-F12 for virtual terminals - */ - for(i = 0; i < 10; i++) - { - if((keys[KEY_LALT] || keys[KEY_RALT]) && keys[i + KEY_F1]) - { - select_vc(i); - return; - } - } - - if((keys[KEY_LALT] || keys[KEY_RALT]) && keys[KEY_F11]) - { - select_vc(10); - return; - } - - if((keys[KEY_LALT] || keys[KEY_RALT]) && keys[KEY_F12]) - { - select_vc(11); - return; - } -} - -/** - * keyboard_irq() - * - * Called when a keyboard interrupt is generated. - */ -void keyboard_irq(void) -{ - register char a; - unsigned c; - unsigned short kbdstat; - - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - /** - * If it's less than 0x80 then it's definatelly - * a make code or a repeat code - */ - if(rawkey < 0x80) - { - /** - * We don't want to gunk up the numlock key - * because we will define it's state in the - * break code a bit later - */ - if((rawkey != KEYP_NUMLCK) && (rawkey != KEY_SCRLCK) && (rawkey != KEY_CAPS)) - keys[rawkey] = 1; - - keyDown(rawkey); - } - else /* rawkey >= 0x80 */ - { - if(rawkey == 0xE0) - { - /** - * It's either a make code, break code, or repeat code - */ - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - if(rawkey < 0x80) - { - /** - * Ok, it's a make code or repeat code for the numeric - * keypad (gray keys) - */ - - keys[rawkey] = 1; - - keyDown(rawkey); - } - else /* rawkey >= 0x80 */ - { - /** - * It's either a make code for the numeric keypad or - * a break code for the numeric keypad. - */ - if(rawkey == 0x2A) - { - /** - * Ok, we have a make code for the numeric keypad - * and NUMLOCK is on. The second byte is what we - * want since what we have so far is this: - * - * 0xE0 0x2A - */ - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - keys[rawkey] = 1; - - keyDown(rawkey); - } - else - { - /** - * It's a break code from the numeric keypad. - */ - keys[rawkey] = 0; - - keyUp(rawkey); - } - } - } - else /* rawkey != 0xE0 */ - { - /** - * It's a break code - * - * Make sure we toggle the numlock, scroll lock, and caps lock key. - */ - if(((rawkey - 0x80) == KEYP_NUMLCK) || - ((rawkey - 0x80) == KEY_SCRLCK) || - ((rawkey - 0x80) == KEY_CAPS)) - { - keys[rawkey - 0x80] = !keys[rawkey - 0x80]; - - kbdstat = 0; - if(keys[KEY_SCRLCK]) - kbdstat |= 1; - if(keys[KEYP_NUMLCK]) - kbdstat |= 2; - if(keys[KEY_CAPS]) - kbdstat |= 4; - - _write_kb(0x60, 0xED); - _write_kb(0x60, kbdstat); - outportb(0x20, 0x20); - - keyUp(rawkey); - return; - } - - keys[rawkey - 0x80] = 0; - - keyUp(rawkey); - } - } - - c = _translate_sc(rawkey); - - if(c != 0) - printf("%c", c); - else - { - /** - * We need to check for meta-key-crap here - */ - handle_meta_key(rawkey); - } - - //enable(); - outportb(0x20, 0x20); -} - -/** - * init_keyboard() - * - */ -void init_keyboard(void) -{ - static unsigned char buffers[KBD_BUF_SIZE * MAX_VC]; - - int i; - - //klog("init", "keyboard %2u buf, %2ub each", K_KLOG_PENDING, &_vc[0]); - for(i = 0; i < MAX_VC; i++) - { - _vc[i].keystrokes.data = buffers + KBD_BUF_SIZE * i; - _vc[i].keystrokes.size = KBD_BUF_SIZE; - } - - for(i = 0; i < 128; i++) - keys[i] = 0; - - makebreak = 0; - //klog(NULL, K_KLOG_SUCCESS, &_vc[0], NULL); - //kprintf("init_kbd: %u buffers, %u bytes each\n", - // MAX_VC, KBD_BUF_SIZE); - - //kprintf("[ Entering Runlevel 0 ].......................................................Ok"); - _vc[0].attrib = 8; - printf("[ "); - _vc[0].attrib = 15; - printf("init: keyboard %2u buf, %2ub each ", MAX_VC, KBD_BUF_SIZE); - _vc[0].attrib = 8; - printf("]..........................................."); - _vc[0].attrib = 2; - printf("Ok"); - _vc[0].attrib = 7; -} diff --git a/Dump/hybos/src/kernel/kstart.asm b/Dump/hybos/src/kernel/kstart.asm deleted file mode 100644 index 371e822..0000000 --- a/Dump/hybos/src/kernel/kstart.asm +++ /dev/null @@ -1,391 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; 32-bit kernel startup code -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -%include "asm.inc" - -SECTION .text -;SEGMENT _TEXT USE32 CLASS=CODE -;BITS 32 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; entry point -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -GLOBAL entry -entry: -; check if data segment linked, located, and loaded properly - mov eax,[ds_magic] - cmp eax,DS_MAGIC - je ds_ok - -; display a blinking white-on-blue 'D' and freeze - mov word [0B8000h],9F44h - jmp short $ -ds_ok: - -; stop using bootloader GDT, and load new GDT - lgdt [gdt_ptr] - - mov ax,LINEAR_DATA_SEL - mov ds,ax - mov es,ax - mov ss,ax - mov fs,ax - mov gs,ax - jmp LINEAR_CODE_SEL:sbat -sbat: - -; zero the C language BSS -; 'bss' and 'end' are defined in the linker script file -EXTERN bss, end - mov edi,bss - mov ecx,end - sub ecx,edi - xor eax,eax - rep stosb - - mov esp,stack - -; set up interrupt handlers, then load IDT register - mov ecx,(idt_end - idt) >> 3 ; number of exception handlers - mov edi,idt - mov esi,isr0 -do_idt: - mov eax,esi ; EAX=offset of entry point - mov [edi],ax ; set low 16 bits of gate offset - shr eax,16 - mov [edi + 6],ax ; set high 16 bits of gate offset - add edi,8 ; 8 bytes/interrupt gate - add esi,(isr1 - isr0) ; bytes/stub - loop do_idt - - lidt [idt_ptr] - -; GRUB 0.90 leaves the NT bit set in EFLAGS. The first IRET we attempt -; will cause a TSS-based task-switch, which will cause Exception 10. -; Let's prevent that: - push dword 2 - popf - -IMP main - call main ; call C code - jmp $ ; freeze - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; Multiboot header for GRUB bootloader. This must be in the first 8K -; of the kernel file. We use the aout kludge so it works with ELF, -; DJGPP COFF, Win32 PE, or other formats. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; these are in the linker script file -EXTERN code, bss, end - -ALIGN 4 -mboot: - dd MULTIBOOT_HEADER_MAGIC - dd MULTIBOOT_HEADER_FLAGS - dd MULTIBOOT_CHECKSUM -; aout kludge. These must be PHYSICAL addresses - dd mboot - dd code - dd bss - dd end - dd entry - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; interrupt/exception handlers -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -IMP fault - -; I shouldn't have to do this! -%macro PUSHB 1 - db 6Ah - db %1 -%endmacro - -%macro INTR 1 ; (byte offset from start of stub) -isr%1: - push byte 0 ; ( 0) fake error code - PUSHB %1 ; ( 2) exception number - push gs ; ( 4) push segment registers - push fs ; ( 6) - push es ; ( 8) - push ds ; ( 9) - pusha ; (10) push GP registers - mov ax,LINEAR_DATA_SEL ; (11) put known-good values... - mov ds,eax ; (15) ...in segment registers - mov es,eax ; (17) - mov fs,eax ; (19) - mov gs,eax ; (21) - mov eax,esp ; (23) - push eax ; (25) push pointer to regs_t -.1: -; setvect() changes the operand of the CALL instruction at run-time, -; so we need its location = 27 bytes from start of stub. We also want -; the CALL to use absolute addressing instead of EIP-relative, so: - mov eax,fault ; (26) - call eax ; (31) - jmp all_ints ; (33) -%endmacro ; (38) - -%macro INTR_EC 1 -isr%1: - nop ; error code already pushed - nop ; nop+nop=same length as push byte - PUSHB %1 ; ( 2) exception number - push gs ; ( 4) push segment registers - push fs ; ( 6) - push es ; ( 8) - push ds ; ( 9) - pusha ; (10) push GP registers - mov ax,LINEAR_DATA_SEL ; (11) put known-good values... - mov ds,eax ; (15) ...in segment registers - mov es,eax ; (17) - mov fs,eax ; (19) - mov gs,eax ; (21) - mov eax,esp ; (23) - push eax ; (25) push pointer to regs_t -.1: -; setvect() changes the operand of the CALL instruction at run-time, -; so we need its location = 27 bytes from start of stub. We also want -; the CALL to use absolute addressing instead of EIP-relative, so: - mov eax,fault ; (26) - call eax ; (31) - jmp all_ints ; (33) -%endmacro ; (38) - -; the vector within the stub (operand of the CALL instruction) -; is at (isr0.1 - isr0 + 1) - -all_ints: - pop eax - popa ; pop GP registers - pop ds ; pop segment registers - pop es - pop fs - pop gs - add esp,8 ; drop exception number and error code - iret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; name: getvect -; action: reads interrupt vector -; in: [EBP + 12] = vector number -; out: vector stored at address given by [EBP + 8] -; modifies: EAX, EDX -; minimum CPU: '386+ -; notes: C prototype: -; typedef struct -; { unsigned access_byte, eip; } vector_t; -; getvect(vector_t *v, unsigned vect_num); -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -EXP getvect - push ebp - mov ebp,esp - push esi - push ebx - mov esi,[ebp + 8] - -; get access byte from IDT[i] - xor ebx,ebx - mov bl,[ebp + 12] - shl ebx,3 - mov al,[idt + ebx + 5] - mov [esi + 0],eax - -; get handler address from stub - mov eax,isr1 - sub eax,isr0 ; assume stub size < 256 bytes - mul byte [ebp + 12] - mov ebx,eax - add ebx,isr0 - mov eax,[ebx + (isr0.1 - isr0 + 1)] - mov [esi + 4],eax - pop ebx - pop esi - pop ebp - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; name: setvect -; action: writes interrupt vector -; in: [EBP + 12] = vector number, -; vector stored at address given by [EBP + 8] -; out: (nothing) -; modifies: EAX, EDX -; minimum CPU: '386+ -; notes: C prototype: -; typedef struct -; { unsigned access_byte, eip; } vector_t; -; getvect(vector_t *v, unsigned vect_num); -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -EXP setvect - push ebp - mov ebp,esp - push esi - push ebx - mov esi,[ebp + 8] - -; store access byte in IDT[i] - mov eax,[esi + 0] - xor ebx,ebx - mov bl,[ebp + 12] - shl ebx,3 - mov [idt + ebx + 5],al - -; store handler address in stub - mov eax,isr1 - sub eax,isr0 ; assume stub size < 256 bytes - mul byte [ebp + 12] - mov ebx,eax - add ebx,isr0 - mov eax,[esi + 4] - mov [ebx + (isr0.1 - isr0 + 1)],eax - pop ebx - pop esi - pop ebp - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; interrupt/exception stubs -; *** CAUTION: these must be consecutive, and must all be the same size. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - INTR 0 ; zero divide (fault) - INTR 1 ; debug/single step - INTR 2 ; non-maskable interrupt (trap) - INTR 3 ; INT3 (trap) - INTR 4 ; INTO (trap) - INTR 5 ; BOUND (fault) - INTR 6 ; invalid opcode (fault) - INTR 7 ; coprocessor not available (fault) - INTR_EC 8 ; double fault (abort w/ error code) - INTR 9 ; coproc segment overrun (abort; 386/486SX only) - INTR_EC 0Ah ; bad TSS (fault w/ error code) - INTR_EC 0Bh ; segment not present (fault w/ error code) - INTR_EC 0Ch ; stack fault (fault w/ error code) - INTR_EC 0Dh ; GPF (fault w/ error code) - INTR_EC 0Eh ; page fault - INTR 0Fh ; reserved - INTR 10h ; FP exception/coprocessor error (trap) - INTR 11h ; alignment check (trap; 486+ only) - INTR 12h ; machine check (Pentium+ only) - INTR 13h - INTR 14h - INTR 15h - INTR 16h - INTR 17h - INTR 18h - INTR 19h - INTR 1Ah - INTR 1Bh - INTR 1Ch - INTR 1Dh - INTR 1Eh - INTR 1Fh - -; isr20 through isr2F are hardware interrupts. The 8259 programmable -; interrupt controller (PIC) chips must be reprogrammed to make these work. - INTR 20h ; IRQ 0/timer interrupt - INTR 21h ; IRQ 1/keyboard interrupt - INTR 22h - INTR 23h - INTR 24h - INTR 25h - INTR 26h ; IRQ 6/floppy interrupt - INTR 27h - INTR 28h ; IRQ 8/real-time clock interrupt - INTR 29h - INTR 2Ah - INTR 2Bh - INTR 2Ch - INTR 2Dh ; IRQ 13/math coprocessor interrupt - INTR 2Eh ; IRQ 14/primary ATA ("IDE") drive interrupt - INTR 2Fh ; IRQ 15/secondary ATA drive interrupt - -; syscall software interrupt - INTR 30h - -; the other 207 vectors are undefined - -%assign i 31h -%rep (0FFh - 30h) - - INTR i - -%assign i (i + 1) -%endrep - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -SECTION .data -;SEGMENT _DATA USE32 CLASS=DATA - -ds_magic: - dd DS_MAGIC - -gdt: -; NULL descriptor - dw 0 ; limit 15:0 - dw 0 ; base 15:0 - db 0 ; base 23:16 - db 0 ; type - db 0 ; limit 19:16, flags - db 0 ; base 31:24 - -; unused descriptor - dw 0 - dw 0 - db 0 - db 0 - db 0 - db 0 - -LINEAR_DATA_SEL equ $-gdt - dw 0FFFFh - dw 0 - db 0 - db 92h ; present, ring 0, data, expand-up, writable - db 0CFh ; page-granular (4 gig limit), 32-bit - db 0 - -LINEAR_CODE_SEL equ $-gdt - dw 0FFFFh - dw 0 - db 0 - db 9Ah ; present,ring 0,code,non-conforming,readable - db 0CFh ; page-granular (4 gig limit), 32-bit - db 0 -gdt_end: - -gdt_ptr: - dw gdt_end - gdt - 1 - dd gdt - -; 256 ring 0 interrupt gates - -idt: -%rep 256 - dw 0 ; offset 15:0 - dw LINEAR_CODE_SEL ; selector - db 0 ; (always 0 for interrupt gates) - db 8Eh ; present,ring 0,'386 interrupt gate - dw 0 ; offset 31:16 -%endrep -idt_end: - -idt_ptr: - dw idt_end - idt - 1 ; IDT limit - dd idt ; linear adr of IDT - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -SECTION .bss -;SEGMENT _BSS USE32 CLASS=BSS - - resd 1024 -stack: diff --git a/Dump/hybos/src/kernel/main.c b/Dump/hybos/src/kernel/main.c deleted file mode 100644 index 4965644..0000000 --- a/Dump/hybos/src/kernel/main.c +++ /dev/null @@ -1,728 +0,0 @@ -/** - * main.c - * - * Main code for HybOS. - * - * I spent a lot of time cleaning this damned thing up, so if you - * are even REMOTELY thinking of modifying it, you better make - * sure you follow the same design pattern as you see now. I am sick - * of cleaning up c-style comments because some dumbass is too fucking - * lazy to use the PROPER c89-style comments. This is C people, not C++. - * - * Exports: - * void printf(const char *fmt, ...); - * int main(void); - * - * Imports: - * kstart.asm getvect(); - * kstart.asm setvect(); - * video.c console_t _vc[]; - * video.c blink(); - * video.c init_video(); - * kbd.c keyboard_irq(); - * kbd.c kbd_hw_init(); - * kbd.c init_keyboard(); - * sched.c schedule(); - * sched.c init_tasks(); - * debug.c dump_regs(); - * - * FIXME: - * needs to be renamed to kernel.c - */ -#include /* va_list, va_start(), va_end() */ -/*#include */ /* NULL */ -#include /* NULL */ -#include /* disable() */ -#include <_printf.h> /* do_printf() */ -#include <_malloc.h> -#include -#include -#include -#include "_krnl.h" /* regs_t */ -#include "bootlog.h" /* klog() */ - -/** - * FIXME - * - * These externs and declares are a fucking mess and - * need to be ported to their own headers for portability - */ - -/** - * Imports - */ -void getvect(vector_t *v, unsigned vect_num); -void setvect(vector_t *v, unsigned vect_num); -extern console_t _vc[]; -void blink(void); -void putch(unsigned c); -void init_video(void); -void keyboard_irq(void); -//void kbd_hw_int(void); -void init_keyboard(void); -void schedule(void); -void init_tasks(void); -void dump_regs(regs_t *regs); - -void _mm_physical_init(void); -unsigned _mm_physical_alloc(void); -void _mm_physical_free(unsigned page); -void _mm_page_copy_byte(uint32_t dest, uint32_t src); -void _mm_page_copy_word(uint32_t dest, uint32_t src); -void _mm_page_copy_dword(uint32_t dest, uint32_t src); - -/*void init_cpu(void);*/ - -/** - * printf/kprintf helper - */ -static int kprintf_help(unsigned c, void **ptr) -{ - /** - * Leave this for now - */ - ptr = ptr; - - putch(c); - return 0; -} - -/** - * Format output and print it to stdout (vtty0) - * Just like on any other operating system - */ -/*void printf(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - (void)do_printf(fmt, args, kprintf_help, NULL); - va_end(args); -}*/ - -void kprintf(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - (void)do_printf(fmt, args, kprintf_help, NULL); - va_end(args); -} - -/** - * Format output and print it to stdout (vtty0) - * Just like on any other operating system - */ -void printk(const char *fmt, ...) -{ - va_list args; - - /** - * TODO - * - * Select vtty0 - */ - va_start(args, fmt); - (void)do_printf(fmt, args, kprintf_help, NULL); - va_end(args); -} - -/** - * Oh yeah, the fun function ;) - */ -void panic(const char *fmt, ...) -{ - va_list args; - - disable(); /* interrupts off */ - va_start(args, fmt); - _vc[0].attrib = 15; - printf("\n\npanic: "); - (void)do_printf(fmt, args, kprintf_help, NULL); - - printf("\n\nSystem halted."); - __asm__ __volatile__ ("hlt"); - - while(1) - /* freeze */; -} - -/** - * Called when a kernel fault is detected. This does not - * (normally) get called when something goes awry in - * user-space, therefore it is designed for kernel-space - */ -void fault(regs_t *regs) -{ - struct exception - { - char *message; - int signal; - int processor; - }; - - static const struct exception ex[] = - { - {"Divide error", SIGFPE, 86}, - {"Debug exception", SIGTRAP, 86}, - {"Nonmaskable interrupt (NMI)", SIGBUS, 86}, - {"Breakpoint (INT3)", SIGEMT, 86}, - {"Overflow (INTO)", SIGFPE, 186}, - {"Bounds check", SIGFPE, 186}, - {"Invalid opcode", SIGILL, 186}, - {"Coprocessor not available", SIGFPE, 186}, - {"Double fault", SIGBUS, 286}, - {"Coprocessor segment overrun", SIGSEGV, 286}, - {"Invalid TSS", SIGSEGV, 286}, - {"Segment not present", SIGSEGV, 286}, - {"Stack exception", SIGSEGV, 286}, - {"General Protection Fault", SIGSEGV, 286}, - {"Page fault", SIGSEGV, 386}, - {NULL, SIGILL, 0}, - {"Coprocessor error", SIGFPE, 386}, - {"Alignment check",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"IRQ0",0,0}, - {"IRQ1",0,0}, - {"IRQ2",0,0}, - {"IRQ3",0,0}, - {"IRQ4",0,0}, - {"IRQ5",0,0}, - {"IRQ6",0,0}, - {"IRQ7",0,0}, - {"IRQ8",0,0}, - {"IRQ9",0,0}, - {"IRQ10",0,0}, - {"IRQ11",0,0}, - {"IRQ12",0,0}, - {"IRQ13",0,0}, - {"IRQ14",0,0}, - {"IRQ15",0,0}, - {"syscall",0,0} - }; - - - switch(regs->which_int) - { - /** - * this handler installed at compile-time - * Keyboard handler is installed at run-time (see below) - */ - case 0x20: /* timer IRQ 0 */ - //blink(); - /** - * reset hardware interrupt at 8259 chip - */ - outportb(0x20, 0x20); - break; - default: - _vc[0].attrib = 15; - printf("\n\npanic: Exception 0x%08X", regs->which_int); - if(regs->which_int <= sizeof(ex) / sizeof(ex[0].message)) - printf(" (%s)", ex[regs->which_int].message); - printf("\n"); - dump_regs(regs); - printf("\n\nSystem halted."); - __asm__ __volatile__ ("hlt"); - break; - } -} - -/** - * ?? - */ -static void init_8259s(void) -{ - static const unsigned irq0_int = 0x20, irq8_int = 0x28; - - /** - * Initialization Control Word #1 (ICW1) - */ - outportb(0x20, 0x11); - outportb(0xA0, 0x11); - - /** - * ICW2: - * route IRQs 0-7 to INTs 20h-27h - */ - outportb(0x21, irq0_int); - - /** - * route IRQs 8-15 to INTs 28h-2Fh - */ - outportb(0xA1, irq8_int); - - /** - * ICW3 - */ - outportb(0x21, 0x04); - outportb(0xA1, 0x02); - - /** - * ICW4 - */ - outportb(0x21, 0x01); - outportb(0xA1, 0x01); - - /** - * enable IRQ0 (timer) and IRQ1 (keyboard) - */ - outportb(0x21, ~0x03); - outportb(0xA1, ~0x00); -} - -/** - * MinGW32 - */ -#ifdef __WIN32__ -#if __GNUC__<3 -#error Do not use MinGW GCC 2.x with NASM -#endif - int __main(void) { return 0; } - void _alloca(void) { } -#endif - -/** - * malloc, realloc, free, etc - */ -static char *g_heap_bot, *g_kbrk, *g_heap_top; -static void dump_heap(void) -{ - unsigned blks_used = 0, blks_free = 0; - size_t bytes_used = 0, bytes_free = 0; - malloc_t *m; - int total; - - kprintf("===============================================\n"); - for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) - { - printk("block %5p: %6u bytes %s\n", m, - m->size, m->used ? "used" : "free"); - if(m->used) - { - blks_used++; - bytes_used += m->size; - } - else - { - blks_free++; - bytes_free += m->size; - } - } - kprintf("blocks: %6u used, %6u free, %6u total\n", blks_used, - blks_free, blks_used + blks_free); - kprintf(" bytes: %6u used, %6u free, %6u total\n", bytes_used, - bytes_free, bytes_used + bytes_free); - kprintf("g_heap_bot=0x%p, g_kbrk=0x%p, g_heap_top=0x%p\n", - g_heap_bot, g_kbrk, g_heap_top); - total = (bytes_used + bytes_free) + - (blks_used + blks_free) * sizeof(malloc_t); - if(total != g_kbrk - g_heap_bot) - kprintf("*** some heap memory is not accounted for\n"); - kprintf("===============================================\n"); -} - -void dumpheapk(void) -{ - dump_heap(); -} - -/** - * POSIX sbrk() looks like this - * void *sbrk(int incr); - * - * Mine is a bit different so I can signal the calling function - * if more memory than desired was allocated (e.g. in a system with paging) - * If your kbrk()/sbrk() always allocates the amount of memory you ask for, - * this code can be easily changed. - * - * int brk( void *sbrk( void *kbrk( - * function void *adr); int delta); int *delta); - * ---------------------- ------------ ------------ ------------- - * POSIX? yes yes NO - * return value if error -1 -1 NULL - * get break value . sbrk(0) int x=0; kbrk(&x); - * set break value to X brk(X) sbrk(X - sbrk(0)) int x=X, y=0; kbrk(&x) - kbrk(&y); - * enlarge heap by N bytes . sbrk(+N) int x=N; kbrk(&x); - * shrink heap by N bytes . sbrk(-N) int x=-N; kbrk(&x); - * can you tell if you're - * given more memory - * than you wanted? no no yes - */ -static void *kbrk(int *delta) -{ - static char heap[HEAP_SIZE]; - char *new_brk, *old_brk; - - /** - * heap doesn't exist yet - */ - if(g_heap_bot == NULL) - { - g_heap_bot = g_kbrk = heap; - g_heap_top = g_heap_bot + HEAP_SIZE; - } - new_brk = g_kbrk + (*delta); - - /** - * too low: return NULL - */ - if(new_brk < g_heap_bot) - return NULL; - - /** - * too high: return NULL - */ - if(new_brk >= g_heap_top) - return NULL; - - /** - * success: adjust brk value... - */ - old_brk = g_kbrk; - g_kbrk = new_brk; - - /** - * ...return actual delta... (for this sbrk(), they are the same) - * (*delta) = (*delta); - * ...return old brk value - */ - return old_brk; -} - -/** - * malloc() and free() use g_heap_bot, but not g_kbrk nor g_heap_top - */ -void *kmalloc(size_t size) -{ - unsigned total_size; - malloc_t *m, *n; - int delta; - - if(size == 0) - return NULL; - total_size = size + sizeof(malloc_t); - - /** - * search heap for free block (FIRST FIT) - */ - m = (malloc_t *)g_heap_bot; - - /** - * g_heap_bot == 0 == NULL if heap does not yet exist - */ - if(m != NULL) - { - if(m->magic != MALLOC_MAGIC) - { - /*printf("*** kernel heap is corrupt in kmalloc()\n");*/ - panic("kernel heap is corrupt in malloc()"); - return NULL; - } - for(; m->next != NULL; m = m->next) - { - if(m->used) - continue; - - /** - * size == m->size is a perfect fit - */ - if(size == m->size) - m->used = 1; - else - { - /** - * otherwise, we need an extra sizeof(malloc_t) bytes for the header - * of a second, free block - */ - if(total_size > m->size) - continue; - - /** - * create a new, smaller free block after this one - */ - n = (malloc_t *)((char *)m + total_size); - n->size = m->size - total_size; - n->next = m->next; - n->magic = MALLOC_MAGIC; - n->used = 0; - - /** - * reduce the size of this block and mark it used - */ - m->size = size; - m->next = n; - m->used = 1; - } - return (char *)m + sizeof(malloc_t); - } - } - - /** - * use kbrk() to enlarge (or create!) heap - */ - delta = total_size; - n = kbrk(&delta); - - /** - * uh-oh - */ - if(n == NULL) - return NULL; - - if(m != NULL) - m->next = n; - - n->size = size; - n->magic = MALLOC_MAGIC; - n->used = 1; - - /** - * did kbrk() return the exact amount of memory we wanted? - * cast to make "gcc -Wall -W ..." shut the hell up - */ - if((int)total_size == delta) - n->next = NULL; - else - { - - /** - * it returned more than we wanted (it will never return less): - * create a new, free block - */ - m = (malloc_t *)((char *)n + total_size); - m->size = delta - total_size - sizeof(malloc_t); - m->next = NULL; - m->magic = MALLOC_MAGIC; - m->used = 0; - - n->next = m; - } - return (char *)n + sizeof(malloc_t); -} - -void kfree(void *blk) -{ - malloc_t *m, *n; - - /** - * get address of header - */ - m = (malloc_t *)((char *)blk - sizeof(malloc_t)); - if(m->magic != MALLOC_MAGIC) - { - /*printf("*** attempt to kfree() block at 0x%p with bad magic value\n", blk);*/ - panic("attempt to free() block at 0x%p with bad magic value", blk); - return; - } - - /** - * find this block in the heap - */ - n = (malloc_t *)g_heap_bot; - if(n->magic != MALLOC_MAGIC) - { - /*printf("*** kernel heap is corrupt in kfree()\n");*/ - panic("kernel heap is corrupt in free()"); - return; - } - for(; n != NULL; n = n->next) - { - if(n == m) - break; - } - - /** - * not found? bad pointer or no heap or something else? - */ - if(n == NULL) - { - /*printf("*** attempt to kfree() block at 0x%p that is not in the heap\n", blk);*/ - panic("attempt to free() block at 0x%p that is not in the heap", blk); - return; - } - - /** - * free the block - */ - m->used = 0; - - /** - * coalesce adjacent free blocks - * Hard to spell, hard to do - */ - for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) - { - while(!m->used && m->next != NULL && !m->next->used) - { - /** - * resize this block - */ - m->size += sizeof(malloc_t) + m->next->size; - - /** - * merge with next block - */ - m->next = m->next->next; - } - } -} - -void testheap(void) -{ - //int i; - //char *t; - //kprintf("before char *t = kmalloc((size_t *)25):\n"); - //dump_heap(); - //t = kmalloc(25); - //strcpy(t, "123456789012345678901234"); - //kprintf("after char *t = kmalloc((size_t *)25):\n"); - //dump_heap(); - //kfree(t); - //kprintf("after kfree(t):\n"); - //dump_heap(); - //kprintf("before char *t = kmalloc((size_t *)25):\n"); - - kprintf("Unable to run testheap -- kmalloc() is broken.\n"); -} - -void *krealloc(void *blk, size_t size) -{ - void *new_blk; - malloc_t *m; - - /** - * size == 0: free block - */ - if(size == 0) - { - if(blk != NULL) - kfree(blk); - new_blk = NULL; - } - else - { - /** - * allocate new block - */ - new_blk = kmalloc(size); - - /** - * if allocation OK, and if old block exists, copy old block to new - */ - if(new_blk != NULL && blk != NULL) - { - m = (malloc_t *)((char *)blk - sizeof(malloc_t)); - if(m->magic != MALLOC_MAGIC) - { - /*printf("*** attempt to krealloc() block at 0x%p with bad magic value\n", blk);*/ - panic("attempt to realloc() block at 0x%p with bad magic value", blk); - return NULL; - } - - /** - * copy minimum of old and new block sizes - */ - if(size > m->size) - size = m->size; - memcpy(new_blk, blk, size); - - /** - * free the old block - */ - kfree(blk); - } - } - return new_blk; -} - -void keyboardISR(void); - -int main(void) -{ - /** - * keyboard interrupt init - */ - vector_t v; - unsigned i; - - init_video(); - init_keyboard(); - init_8259s(); - - /** - * XXX: - * i know this is a very ugly way of doing this, - * however it is the only way it can be done for now. - * in the future, i will implement a kprintf function - * whose sole purpose will be writing boot messages. - * - * Also, the color codes need to be mapped to constants - * in order to make using them a hell of a lot easier. - */ - - klog("init", "Installing keyboard interrupt handler", K_KLOG_PENDING, &_vc[0]); - /* we don't save the old vector */ - v.eip = (unsigned)keyboard_irq; - v.access_byte = 0x8E; /* present, ring 0, '386 interrupt gate */ - setvect(&v, 0x21); - klog(NULL, NULL, K_KLOG_SUCCESS, &_vc[0]); - - /*init_tasks();*/ - - klog("init", "Enabling hardware interrupts", K_KLOG_PENDING, &_vc[0]); - enable(); - /*for(i = 0; i < 0xFFFFFFF; i++);*/ - klog(NULL, NULL, K_KLOG_SUCCESS, &_vc[0]); - - /** - * Initialize memory management - */ - /*_mm_init();*/ - - /** - * finished init, time for some gooey ;) - */ - printf(" _ _ _ _ ____ _____ ___ "); - printf(" ( )_( )( \\/ )( _ \\( _ )/ __) "); - printf(" ) _ ( \\ / ) _ < )(_)( \\__ \\ "); - printf(" (_) (_) (__) (____/(_____)(___/ \n"); - - printf(" Hybrid Operating System (HybOS) \n"); - - /** - * XXX: debug only - */ - printf("ALT + F1 - F8 for virtual terminals\n"); - printf("Three finger salute to restart\n"); - printf("More work needs to be done\n"); - printf("$ "); - - /** - * fork (kfork()) control over to a shell - */ - /*init_shell();*/ - - /** - * idle task/thread - */ - while(1) - { - schedule(); - } - - return 0; -} diff --git a/Dump/hybos/src/kernel/sched.c b/Dump/hybos/src/kernel/sched.c deleted file mode 100644 index ed1b60f..0000000 --- a/Dump/hybos/src/kernel/sched.c +++ /dev/null @@ -1,189 +0,0 @@ -/** - * schedule.c - * - * Task creation and scheduling - * - * Exports: - * task_t *_current_task; - * schedule(); - * init_tasks(); - * - * Imports: - * main.c printf(); - * video.c console_t _vc[]; - */ - -#include /* setjmp(), longjmp() */ -#include -#include "_krnl.h" /* console_t */ -#include "bootlog.h" /* klog() */ - -/** - * Imports - */ -void printf(const char *fmt, ...); -extern console_t _vc[]; -void task1(void); -void task2(void); -void task3(void); -void task4(void); - -#define MAX_TASK 16 -#define USER_STACK_SIZE 512 - -/** - * jmp_buf (E)IP and (E)SP register names for various environments - */ - -/** - * Tinylib (default) - * These should work for most compilers - The HybOS - * compiler (modified gcc) uses this as the default. - * Your mileage may vary. - */ -#define JMPBUF_IP eip -#define JMPBUF_SP esp -#define JMPBUF_FLAGS eflags - -#if 0 -/** - * TurboC - * - * These should work with all versions of TurboC's - * compiler. - */ -#define JMPBUF_IP j_ip -#define JMPBUF_SP j_sp -#define JMPBUF_FLAGS j_flag - -/** - * DJGPP - * - * These should work with the DJGPP compiler - */ -#define JMPBUF_IP __eip -#define JMPBUF_SP __esp -#define JMPBUF_FLAGS __eflags - -#define JMPBUF_IP __pc -#define JMPBUF_SP __sp -#define JMPBUF_FLAGS ???????? - -/** - * glibc5 - * - * I have no idea what the register name is - * for JMPBUF_FLAGS. Good luck. - */ -#define JMPBUF_IP eip -#define JMPBUF_SP esp -#define JMPBUF_FLAGS eflags -#endif /* 0 */ - -task_t *_curr_task; -static task_t _tasks[MAX_TASK]; - -/** - * schedule() - * - */ -void schedule(void) -{ - static unsigned current; - - /** - * If setjmp() returns non-zero it means that we came here through - * hyperspace from our call to longjmp() below, so just return - */ -/** UBU - if(setjmp(_curr_task->state) != 0) - return; -**/ - - /** - * Try to find the next runnable task - */ - do - { - current++; - if(current >= MAX_TASK) - current = 0; - _curr_task = _tasks + current; - } while(_curr_task->status != TS_RUNNABLE); - - /** - * Jump to the new task - */ - longjmp(_curr_task->state, 1); -} -/***************************************************************************** -*****************************************************************************/ -#define NUM_TASKS 0 - -/** - * init_tasks() - * - */ -void init_tasks(void) -{ - static unsigned char stacks[NUM_TASKS][USER_STACK_SIZE]; - /*static unsigned entry[NUM_TASKS] = - { - 0, (unsigned)task1, - (unsigned)task2, (unsigned)task3, - (unsigned)task4 - };*/ - static unsigned entry[NUM_TASKS]; - - unsigned adr, i; - - klog("init", "task handler", K_KLOG_PENDING, &_vc[0]); - - /** - * For user taskes, initialize the saved state - */ - for(i = 1; i < NUM_TASKS; i++) - { - (void)setjmp(_tasks[i].state); - - /** - * especially the stack pointer - */ - adr = (unsigned)(stacks[i] + USER_STACK_SIZE); - _tasks[i].state[0].JMPBUF_SP = adr; - - /** - * and program counter - */ - _tasks[i].state[0].JMPBUF_IP = entry[i]; - - /** - * enable interrupts (by setting EFLAGS value) - */ - _tasks[i].state[0].JMPBUF_FLAGS = 0x200; - - /** - * allocate a virtual console to this task - */ - _tasks[i].vc = _vc + i; - - /** - * and mark it as runnable - */ - _tasks[i].status = TS_RUNNABLE; - } - - /** - * mark task 0 runnable (idle task) - */ - _tasks[0].status = TS_RUNNABLE; - - /** - * set _curr_task so schedule() will save state - * of task 0 - */ - _curr_task = _tasks + 0; - - klog(NULL, NULL, K_KLOG_SUCCESS, &_vc[0]); -} - diff --git a/Dump/hybos/src/kernel/tasks.c b/Dump/hybos/src/kernel/tasks.c deleted file mode 100644 index 12f6ac3..0000000 --- a/Dump/hybos/src/kernel/tasks.c +++ /dev/null @@ -1,136 +0,0 @@ -/** - * tasks.c - * - * ?? - * - * Exports: - * task1() - * task2() - * task3() - * task4() - * - * Imports: - * video.c putch_help(); - * sched.c task_t *_curr_task; - */ - -#include "_krnl.h" - -/** - * Imports - */ -void putch_help(console_t *con, unsigned c); -extern task_t *_curr_task; -void schedule(void); - -/** - * write() - * - */ -static int write(const unsigned char *str, unsigned len) -{ - unsigned i; - - for(i = 0; i < len; i++) - { - putch_help(_curr_task->vc, *str); - str++; - } - return i; -} - -/** - * yield() - * - */ -static void yield(void) -{ - schedule(); -} - -#define WAIT 0xFFFFFL - -/** - * wait() - */ -static void wait(void) -{ - unsigned long wait; - - for(wait = WAIT; wait != 0; wait--) - /* nothing */; -} - -/** - * task1() - * - */ -void task1(void) -{ - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - while(1) - { - /* so we can process other events */ - yield(); - wait(); - } -} - -/** - * task2() - * - */ -void task2(void) -{ - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - while(1) - { - yield(); - wait(); - } -} - -/** - * task3() - * - */ -void task3(void) -{ - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - while(1) - { - yield(); - wait(); - } -} - -/** - * task4() - * - */ -void task4(void) -{ - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - while(1) - { - yield(); - wait(); - } -} - diff --git a/Dump/hybos/src/kernel/video.c b/Dump/hybos/src/kernel/video.c deleted file mode 100644 index b192ebc..0000000 --- a/Dump/hybos/src/kernel/video.c +++ /dev/null @@ -1,445 +0,0 @@ -/** - * video.c - * - * Text video routines - * - * Exports: - * blink(); - * select_vc() - * putch_help() - * putch() - * init_video(); - * - * Imports: - * main.c printf(); - */ - -/** - * TODO - * - * Fuck me with a blind melon...when the screen scrolls - * too much, it generates a panic of type invalid opcode. - */ - -#include /* memcpy(), memsetw() */ -#include /* isdigit() */ -#include /* outportb(), inportb() */ -#include -#include "_krnl.h" /* MAX_VC, console_t */ - -/** - * Imports - */ -void printf(const char *fmt, ...); - -#define VGA_MISC_READ 0x3CC - -console_t _vc[MAX_VC]; -static unsigned _num_vcs; -static console_t *_curr_vc; - -static unsigned short *_vga_fb_adr; -static unsigned _crtc_io_adr, _vc_width, _vc_height; - -unsigned curr_vtty; - -/** - * blink() - * - */ -void blink(void) -{ - (*(unsigned char *)_vga_fb_adr)++; -} - -/** - * get_current_vc() - * - */ -unsigned get_current_vc() -{ - return curr_vtty; -} - -/** - * scroll() - * - */ -static void scroll(console_t *con) -{ - unsigned short *fb_adr; - unsigned blank, temp; - - blank = 0x20 | ((unsigned)con->attrib << 8); - fb_adr = con->fb_adr; - - /** - * scroll up - */ - if(con->csr_y >= _vc_height) - { - temp = con->csr_y - _vc_height + 1; - memcpy(fb_adr, fb_adr + temp * _vc_width, - (_vc_height - temp) * _vc_width * 2); - - /** - * blank bottom line of screen - */ - memsetw(fb_adr + (_vc_height - temp) * _vc_width, - blank, _vc_width); - con->csr_y = _vc_height - 1; - } - - //for(i = 0; i < 0x1000000; i++) ; -} - -/** - * set_attrib() - * - */ -static void set_attrib(console_t *con, unsigned att) -{ - static const unsigned ansi_to_vga[] = - { - 0, 4, 2, 6, 1, 5, 3, 7 - }; - - unsigned new_att; - - new_att = con->attrib; - if(att == 0) - new_att &= ~0x08; /* bold off */ - else if(att == 1) - new_att |= 0x08; /* bold on */ - else if(att >= 30 && att <= 37) - { - att = ansi_to_vga[att - 30]; - new_att = (new_att & ~0x07) | att;/* fg color */ - } - else if(att >= 40 && att <= 47) - { - att = ansi_to_vga[att - 40] << 4; - new_att = (new_att & ~0x70) | att;/* bg color */ - } - con->attrib = new_att; -} - -/** - * move_csr() - * - */ -static void move_csr(void) -{ - unsigned temp; - - temp = (_curr_vc->csr_y * _vc_width + _curr_vc->csr_x) + - (_curr_vc->fb_adr - _vga_fb_adr); - outportb(_crtc_io_adr + 0, 14); - outportb(_crtc_io_adr + 1, temp >> 8); - outportb(_crtc_io_adr + 0, 15); - outportb(_crtc_io_adr + 1, temp); -} - - -/** - * select_vc() - * - */ -void select_vc(unsigned which_vc) -{ - unsigned i; - - if(which_vc >= _num_vcs) - return; - _curr_vc = _vc + which_vc; - i = _curr_vc->fb_adr - _vga_fb_adr; - outportb(_crtc_io_adr + 0, 12); - outportb(_crtc_io_adr + 1, i >> 8); - outportb(_crtc_io_adr + 0, 13); - outportb(_crtc_io_adr + 1, i); - - curr_vtty = which_vc; - - move_csr(); -} - -/** - * putch_help() - * - */ -void putch_help(console_t *con, unsigned c) -{ - unsigned short *fb_adr; - unsigned att; - - att = (unsigned)con->attrib << 8; - fb_adr = con->fb_adr; - - /** - * state machine to handle escape sequences - * - * ESC - */ - if(con->esc == 1) - { - if(c == '[') - { - con->esc++; - con->esc1 = 0; - return; - } - /* else fall-through: zero esc and print c */ - } - - /** - * ESC[ - */ - else if(con->esc == 2) - { - if(isdigit(c)) - { - con->esc1 = con->esc1 * 10 + c - '0'; - return; - } - else if(c == ';') - { - con->esc++; - con->esc2 = 0; - return; - } - - /** - * ESC[2J (clear screen) - */ - else if(c == 'J') - { - if(con->esc1 == 2) - { - memsetw(fb_adr, ' ' | att, - _vc_height * _vc_width); - con->csr_x = con->csr_y = 0; - } - } - - /** - * ESC[num1m (set attribute num1) - */ - else if(c == 'm') - set_attrib(con, con->esc1); - con->esc = 0; /* anything else with one numeric arg */ - return; - } - - /** - * ESC[num1 - */ - else if(con->esc == 3) - { - if(isdigit(c)) - { - con->esc2 = con->esc2 * 10 + c - '0'; - return; - } - else if(c == ';') - { - con->esc++; /* ESC[num1;num2; */ - con->esc3 = 0; - return; - } - - /** - * ESC[num1;num2H (move cursor to num1,num2) - */ - else if(c == 'H') - { - if(con->esc2 < _vc_width) - con->csr_x = con->esc2; - if(con->esc1 < _vc_height) - con->csr_y = con->esc1; - } - - /** - * ESC[num1;num2m (set attributes num1,num2) - */ - else if(c == 'm') - { - set_attrib(con, con->esc1); - set_attrib(con, con->esc2); - } - con->esc = 0; - return; - } - /** - * ESC[num1;num2;num3 - */ - else if(con->esc == 4) - { - if(isdigit(c)) - { - con->esc3 = con->esc3 * 10 + c - '0'; - return; - } - /** - * ESC[num1;num2;num3m (set attributes num1,num2,num3) - */ - else if(c == 'm') - { - set_attrib(con, con->esc1); - set_attrib(con, con->esc2); - set_attrib(con, con->esc3); - } - con->esc = 0; - return; - } - con->esc = 0; - - /** - * escape character - */ - if(c == 0x1B) - { - con->esc = 1; - return; - } - /** - * backspace - */ - if(c == 0x08) - { - if(con->csr_x != 0) - con->csr_x--; - } - /** - * tab - */ - else if(c == 0x09) - con->csr_x = (con->csr_x + 8) & ~(8 - 1); - /** - * carriage return - */ - else if(c == '\r') /* 0x0D */ - con->csr_x = 0; - /** - * line feed - */ -/* else if(c == '\n') *//* 0x0A */ -/* con->csr_y++;*/ - /** - * CR/LF - */ - else if(c == '\n') /* ### - 0x0A again */ - { - con->csr_x = 0; - con->csr_y++; - } - /** - * printable ASCII - */ - else if(c >= ' ') - { - unsigned short *where; - - where = fb_adr + (con->csr_y * _vc_width + con->csr_x); - *where = (c | att); - con->csr_x++; - } - if(con->csr_x >= _vc_width) - { - con->csr_x = 0; - con->csr_y++; - } - scroll(con); - - /** - * move cursor only if the VC we're writing is the current VC - */ - if(_curr_vc == con) - move_csr(); -} - -/** - * putch() - * - */ -void putch(unsigned c) -{ -/* all kernel messages to VC #0 */ -// putch_help(_vc + 0, c); -/* all kernel messages to current VC */ - putch_help(_curr_vc, c); -} - -/** - * init_video() - * - */ -void init_video(void) -{ - unsigned i; - - /** - * check for monochrome or color VGA emulation - */ - if((inportb(VGA_MISC_READ) & 0x01) != 0) - { - _vga_fb_adr = (unsigned short *)0xB8000L; - _crtc_io_adr = 0x3D4; - } - else - { - _vga_fb_adr = (unsigned short *)0xB0000L; - _crtc_io_adr = 0x3B4; - } - - /** - * read current screen size from BIOS data segment (addresses 400-4FF) - */ - _vc_width = *(unsigned short *)0x44A; - _vc_height = *(unsigned char *)0x484 + 1; - - /** - * figure out how many VCs we can have with 32K of display memory. - * Use INTEGER division to round down. - */ - _num_vcs = 32768L / (_vc_width * _vc_height * 2); - if(_num_vcs > MAX_VC) - _num_vcs = MAX_VC; - - /** - * init VCs, with a different foreground color for each - */ - for(i = 0; i < _num_vcs; i++) - { - _curr_vc = _vc + i; - //_curr_vc->attrib = i + 1; - - /* terminal foreground color */ - _curr_vc->attrib = 7; - _curr_vc->fb_adr = _vga_fb_adr + - _vc_width * _vc_height * i; - - /** - * ESC[2J clears the screen - */ - //kprintf("\x1B[2J this is VC#%u (of 0-%u)\n", - // i, _num_vcs - 1); - printf("\x1B[2J"); - - if(i != 0) - printf("$ "); - } - select_vc(0); - curr_vtty = 0; - - _curr_vc->attrib = 8; - printf("[ "); - _curr_vc->attrib = 15; - printf("init: video %5s emulation, %2ux%2u, framebuffer at 0x%1X ", - (_crtc_io_adr == 0x3D4) ? "color" : "mono", - _vc_width, _vc_height, _vga_fb_adr); - _curr_vc->attrib = 8; - printf("]................"); - _curr_vc->attrib = 2; - printf("Ok"); - _curr_vc->attrib = 7; -} diff --git a/Dump/hybos/src/keymaps/us-std.h b/Dump/hybos/src/keymaps/us-std.h deleted file mode 100644 index 2ee2ccf..0000000 --- a/Dump/hybos/src/keymaps/us-std.h +++ /dev/null @@ -1,136 +0,0 @@ -/* Keymap for US MF-2 keyboard. */ -#include - -uint16_t keymap[NR_SCAN_CODES * MAP_COLS] = { - -/* scan-code !Shift Shift Alt1 Alt2 Alt+Sh Ctrl */ -/* ==================================================================== */ -/* 00 - none */ 0, 0, 0, 0, 0, 0, -/* 01 - ESC */ C('['), C('['), CA('['),CA('['),CA('['),C('['), -/* 02 - '1' */ '1', '!', A('1'), A('1'), A('!'), C('A'), -/* 03 - '2' */ '2', '@', A('2'), A('2'), A('@'), C('@'), -/* 04 - '3' */ '3', '#', A('3'), A('3'), A('#'), C('C'), -/* 05 - '4' */ '4', '$', A('4'), A('4'), A('$'), C('D'), -/* 06 - '5' */ '5', '%', A('5'), A('5'), A('%'), C('E'), -/* 07 - '6' */ '6', '^', A('6'), A('6'), A('^'), C('^'), -/* 08 - '7' */ '7', '&', A('7'), A('7'), A('&'), C('G'), -/* 09 - '8' */ '8', '*', A('8'), A('8'), A('*'), C('H'), -/* 10 - '9' */ '9', '(', A('9'), A('9'), A('('), C('I'), -/* 11 - '0' */ '0', ')', A('0'), A('0'), A(')'), C('@'), -/* 12 - '-' */ '-', '_', A('-'), A('-'), A('_'), C('_'), -/* 13 - '=' */ '=', '+', A('='), A('='), A('+'), C('@'), -/* 14 - BS */ C('H'), C('H'), CA('H'),CA('H'),CA('H'),0177, -/* 15 - TAB */ C('I'), C('I'), CA('I'),CA('I'),CA('I'),C('I'), -/* 16 - 'q' */ L('q'), 'Q', A('q'), A('q'), A('Q'), C('Q'), -/* 17 - 'w' */ L('w'), 'W', A('w'), A('w'), A('W'), C('W'), -/* 18 - 'e' */ L('e'), 'E', A('e'), A('e'), A('E'), C('E'), -/* 19 - 'r' */ L('r'), 'R', A('r'), A('r'), A('R'), C('R'), -/* 20 - 't' */ L('t'), 'T', A('t'), A('t'), A('T'), C('T'), -/* 21 - 'y' */ L('y'), 'Y', A('y'), A('y'), A('Y'), C('Y'), -/* 22 - 'u' */ L('u'), 'U', A('u'), A('u'), A('U'), C('U'), -/* 23 - 'i' */ L('i'), 'I', A('i'), A('i'), A('I'), C('I'), -/* 24 - 'o' */ L('o'), 'O', A('o'), A('o'), A('O'), C('O'), -/* 25 - 'p' */ L('p'), 'P', A('p'), A('p'), A('P'), C('P'), -/* 26 - '[' */ '[', '{', A('['), A('['), A('{'), C('['), -/* 27 - ']' */ ']', '}', A(']'), A(']'), A('}'), C(']'), -/* 28 - CR/LF */ C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J'), -/* 29 - Ctrl */ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, -/* 30 - 'a' */ L('a'), 'A', A('a'), A('a'), A('A'), C('A'), -/* 31 - 's' */ L('s'), 'S', A('s'), A('s'), A('S'), C('S'), -/* 32 - 'd' */ L('d'), 'D', A('d'), A('d'), A('D'), C('D'), -/* 33 - 'f' */ L('f'), 'F', A('f'), A('f'), A('F'), C('F'), -/* 34 - 'g' */ L('g'), 'G', A('g'), A('g'), A('G'), C('G'), -/* 35 - 'h' */ L('h'), 'H', A('h'), A('h'), A('H'), C('H'), -/* 36 - 'j' */ L('j'), 'J', A('j'), A('j'), A('J'), C('J'), -/* 37 - 'k' */ L('k'), 'K', A('k'), A('k'), A('K'), C('K'), -/* 38 - 'l' */ L('l'), 'L', A('l'), A('l'), A('L'), C('L'), -/* 39 - ';' */ ';', ':', A(';'), A(';'), A(':'), C('@'), -/* 40 - '\'' */ '\'', '"', A('\''),A('\''),A('"'), C('@'), -/* 41 - '`' */ '`', '~', A('`'), A('`'), A('~'), C('@'), -/* 42 - l. SHIFT*/ SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, -/* 43 - '\\' */ '\\', '|', A('\\'),A('\\'),A('|'), C('\\'), -/* 44 - 'z' */ L('z'), 'Z', A('z'), A('z'), A('Z'), C('Z'), -/* 45 - 'x' */ L('x'), 'X', A('x'), A('x'), A('X'), C('X'), -/* 46 - 'c' */ L('c'), 'C', A('c'), A('c'), A('C'), C('C'), -/* 47 - 'v' */ L('v'), 'V', A('v'), A('v'), A('V'), C('V'), -/* 48 - 'b' */ L('b'), 'B', A('b'), A('b'), A('B'), C('B'), -/* 49 - 'n' */ L('n'), 'N', A('n'), A('n'), A('N'), C('N'), -/* 50 - 'm' */ L('m'), 'M', A('m'), A('m'), A('M'), C('M'), -/* 51 - ',' */ ',', '<', A(','), A(','), A('<'), C('@'), -/* 52 - '.' */ '.', '>', A('.'), A('.'), A('>'), C('@'), -/* 53 - '/' */ '/', '?', A('/'), A('/'), A('?'), C('@'), -/* 54 - r. SHIFT*/ SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, -/* 55 - '*' */ '*', '*', A('*'), A('*'), A('*'), C('@'), -/* 56 - ALT */ ALT, ALT, ALT, ALT, ALT, ALT, -/* 57 - ' ' */ ' ', ' ', A(' '), A(' '), A(' '), C('@'), -/* 58 - CapsLck */ CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, CALOCK, -/* 59 - F1 */ F1, SF1, AF1, AF1, ASF1, CF1, -/* 60 - F2 */ F2, SF2, AF2, AF2, ASF2, CF2, -/* 61 - F3 */ F3, SF3, AF3, AF3, ASF3, CF3, -/* 62 - F4 */ F4, SF4, AF4, AF4, ASF4, CF4, -/* 63 - F5 */ F5, SF5, AF5, AF5, ASF5, CF5, -/* 64 - F6 */ F6, SF6, AF6, AF6, ASF6, CF6, -/* 65 - F7 */ F7, SF7, AF7, AF7, ASF7, CF7, -/* 66 - F8 */ F8, SF8, AF8, AF8, ASF8, CF8, -/* 67 - F9 */ F9, SF9, AF9, AF9, ASF9, CF9, -/* 68 - F10 */ F10, SF10, AF10, AF10, ASF10, CF10, -/* 69 - NumLock */ NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, -/* 70 - ScrLock */ SLOCK, SLOCK, SLOCK, SLOCK, SLOCK, SLOCK, -/* 71 - Home */ HOME, '7', AHOME, AHOME, A('7'), CHOME, -/* 72 - CurUp */ UP, '8', AUP, AUP, A('8'), CUP, -/* 73 - PgUp */ PGUP, '9', APGUP, APGUP, A('9'), CPGUP, -/* 74 - '-' */ NMIN, '-', ANMIN, ANMIN, A('-'), CNMIN, -/* 75 - Left */ LEFT, '4', ALEFT, ALEFT, A('4'), CLEFT, -/* 76 - MID */ MID, '5', AMID, AMID, A('5'), CMID, -/* 77 - Right */ RIGHT, '6', ARIGHT, ARIGHT, A('6'), CRIGHT, -/* 78 - '+' */ PLUS, '+', APLUS, APLUS, A('+'), CPLUS, -/* 79 - End */ END, '1', AEND, AEND, A('1'), CEND, -/* 80 - Down */ DOWN, '2', ADOWN, ADOWN, A('2'), CDOWN, -/* 81 - PgDown */ PGDN, '3', APGDN, APGDN, A('3'), CPGDN, -/* 82 - Insert */ INSRT, '0', AINSRT, AINSRT, A('0'), CINSRT, -/* 83 - Delete */ 0177, '.', A(0177),A(0177),A('.'), 0177, -/* 84 - Enter */ C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J'), -/* 85 - ??? */ 0, 0, 0, 0, 0, 0, -/* 86 - ??? */ '<', '>', A('<'), A('|'), A('>'), C('@'), -/* 87 - F11 */ F11, SF11, AF11, AF11, ASF11, CF11, -/* 88 - F12 */ F12, SF12, AF12, AF12, ASF12, CF12, -/* 89 - ??? */ 0, 0, 0, 0, 0, 0, -/* 90 - ??? */ 0, 0, 0, 0, 0, 0, -/* 91 - ??? */ 0, 0, 0, 0, 0, 0, -/* 92 - ??? */ 0, 0, 0, 0, 0, 0, -/* 93 - ??? */ 0, 0, 0, 0, 0, 0, -/* 94 - ??? */ 0, 0, 0, 0, 0, 0, -/* 95 - ??? */ 0, 0, 0, 0, 0, 0, -/* 96 - EXT_KEY */ EXTKEY, EXTKEY, EXTKEY, EXTKEY, EXTKEY, EXTKEY, -/* 97 - ??? */ 0, 0, 0, 0, 0, 0, -/* 98 - ??? */ 0, 0, 0, 0, 0, 0, -/* 99 - ??? */ 0, 0, 0, 0, 0, 0, -/*100 - ??? */ 0, 0, 0, 0, 0, 0, -/*101 - ??? */ 0, 0, 0, 0, 0, 0, -/*102 - ??? */ 0, 0, 0, 0, 0, 0, -/*103 - ??? */ 0, 0, 0, 0, 0, 0, -/*104 - ??? */ 0, 0, 0, 0, 0, 0, -/*105 - ??? */ 0, 0, 0, 0, 0, 0, -/*106 - ??? */ 0, 0, 0, 0, 0, 0, -/*107 - ??? */ 0, 0, 0, 0, 0, 0, -/*108 - ??? */ 0, 0, 0, 0, 0, 0, -/*109 - ??? */ 0, 0, 0, 0, 0, 0, -/*110 - ??? */ 0, 0, 0, 0, 0, 0, -/*111 - ??? */ 0, 0, 0, 0, 0, 0, -/*112 - ??? */ 0, 0, 0, 0, 0, 0, -/*113 - ??? */ 0, 0, 0, 0, 0, 0, -/*114 - ??? */ 0, 0, 0, 0, 0, 0, -/*115 - ??? */ 0, 0, 0, 0, 0, 0, -/*116 - ??? */ 0, 0, 0, 0, 0, 0, -/*117 - ??? */ 0, 0, 0, 0, 0, 0, -/*118 - ??? */ 0, 0, 0, 0, 0, 0, -/*119 - ??? */ 0, 0, 0, 0, 0, 0, -/*120 - ??? */ 0, 0, 0, 0, 0, 0, -/*121 - ??? */ 0, 0, 0, 0, 0, 0, -/*122 - ??? */ 0, 0, 0, 0, 0, 0, -/*123 - ??? */ 0, 0, 0, 0, 0, 0, -/*124 - ??? */ 0, 0, 0, 0, 0, 0, -/*125 - ??? */ 0, 0, 0, 0, 0, 0, -/*126 - ??? */ 0, 0, 0, 0, 0, 0, -/*127 - ??? */ 0, 0, 0, 0, 0, 0 -}; diff --git a/Dump/hybos/src/krnl1m.ld b/Dump/hybos/src/krnl1m.ld deleted file mode 100644 index 8f957cb..0000000 --- a/Dump/hybos/src/krnl1m.ld +++ /dev/null @@ -1,55 +0,0 @@ -/* let the linker use its 'native' format (ELF/COFF/PE) -OUTPUT_FORMAT("coff-go32") */ -/* no leading underscore for symbols handled in asm: */ -ENTRY(entry) -LS_Phys = 0x100000; /* 1 meg = load (physical) address */ -LS_Virt = 0x100000; /* 1 meg = virtual address */ -/*LS_Phys = 0x300000;*/ /* 3 meg = load (physical) address */ -/*LS_Virt = 0x300000;*/ /* 3 meg = virtual address */ - -SECTIONS -{ - .text LS_Virt : AT(LS_Phys) - { - LS_Code = .; -/* symbols to mark start of code segment */ - code = .; _code = .; -/* kernel code */ - *(.text) -/* .rodata is the ELF constant data section */ - *(.rodata*) - . = ALIGN(4096); - } - .data : AT(LS_Phys + (LS_Data - LS_Code)) - { - LS_Data = .; -/* symbols to mark start of data segment */ - data = .; _data = .; -/* kernel data */ -/* OLD: . = ALIGN(4096) */ - *(.data) - . = ALIGN(4096); - } - .bss : AT(LS_Phys + (LS_Bss - LS_Code)) - { - LS_Bss = .; -/* symbols to mark start of BSS segment */ - bss = .; _bss = .; -/* kernel BSS */ - *(.bss) - *(COMMON) /* "common" variables */ - . = ALIGN(4096); - } -/* bug in MinGW? I get a bad executable file unless these -sections are here... */ - .stab : - { - *(.stab) - } - .stabstr : - { - *(.stabstr) - } -/* symbols to mark end of kernel */ - end = .; _end = .; -} diff --git a/Dump/hybos/src/mm/Makefile b/Dump/hybos/src/mm/Makefile deleted file mode 100644 index d0329f1..0000000 --- a/Dump/hybos/src/mm/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.SUFFIXES: .asm - -# defines -MAKEFILE =Makefile -MAKEDEP =$(MAKEFILE) -INCDIR =../../include -LDSCRIPT =../../krnl1m.ld -NASM =nasm -f win32 -dUNDERBARS=1 -i$(INCDIR)/ -CC =gcc -g -Wall -W -O2 -nostdinc -fno-builtin -I$(INCDIR) -LD =ld -g -T $(LDSCRIPT) -nostdlib -LIBC =../../lib/libc.a - -OBJS =memory.o - -OBJS_DEP =*.o - -OBJ_DIR =objects - -# targets -all: $(OBJS) $(MAKEDEP) - -clean: - del ..\$(OBJ_DIR)\memory.o - -# implicit rules -.asm.o: - $(NASM) -o../$(OBJ_DIR)/$@ $< - -.c.o: - $(CC) -c -o../$(OBJ_DIR)/$@ $< - -# dependencies -memory.o: memory.c $(MAKEDEP) - diff --git a/Dump/hybos/src/mm/memory.c b/Dump/hybos/src/mm/memory.c deleted file mode 100644 index 921531d..0000000 --- a/Dump/hybos/src/mm/memory.c +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include "../kernel/bootlog.h" - -extern console_t _vc[]; - -unsigned *buffer; -unsigned *bufferIterator; - -#define PAGESIZE 4096 - -char ts[4096*3]; -char td[4096*3]; - -void _mm_physical_init(void); -unsigned _mm_physical_alloc(void); -void _mm_physical_free(unsigned page); -void _mm_page_copy_byte(uint32_t dest, uint32_t src); -void _mm_page_copy_word(uint32_t dest, uint32_t src); -void _mm_page_copy_dword(uint32_t dest, uint32_t src); -void _mm_virtual_init(void); - -void _mm_init(void) -{ - klog("init", "Initializing memory management", K_KLOG_PENDING, &_vc[0]); - _mm_physical_init(); - _mm_virtual_init(); - klog((void *)0, (void *)0, K_KLOG_SUCCESS, &_vc[0]); -} - -void _mm_physical_init(void) -{ - unsigned i; - unsigned size = 16 * 1024 * 1024; - - size /= PAGESIZE; - size++; - size /= 32; - - buffer = (unsigned *)0x40000; - bufferIterator = (unsigned *)0x40000; - - for(i = 0; i < 72; i++) - buffer[i] = 0xFFFFFFFF; - - for(i = 72; i < size; i++) - buffer[i] = 0x00000000; -} - -unsigned _mm_physical_alloc(void) -{ - unsigned mask = 0x00000001; - unsigned bit = 0; - - /** - * Search for a free space - */ - while(*bufferIterator == 0xFFFFFFFF) - bufferIterator++; - - /** - * Search for a bit that indicates a free page - */ - while(*bufferIterator & mask) - { - mask <<= 1; - bit++; - } - - *bufferIterator |= mask; - - return 32 * (bufferIterator - buffer) + bit; -} - -void _mm_physical_free(unsigned page) -{ - buffer[page >> 5] &= ~(1 << (page & 0x1F)); /* confused yet?!? */ -} - -void _mm_virtual_init(void) -{ -} - -void _mm_page_copy_byte(uint32_t dest, uint32_t src) -{ - __asm__ __volatile__ - ( - "cld;" - "rep; movsb;" - : - : "c" (1024*1024), "D" (dest), "S" (src) - : "memory" - ); -} - -void _mm_page_copy_word(uint32_t dest, uint32_t src) -{ - __asm__ __volatile__ - ( - "cld;" - "rep; movsw;" - : - : "c" (512*1024), "D" (dest), "S" (src) - : "memory" - ); -} - -void _mm_page_copy_dword(uint32_t dest, uint32_t src) -{ - __asm__ __volatile__ - ( - "cld;" - "rep; movsl;" - : - : "c" (256*1024), "D" (dest), "S" (src) - : "memory" - ); -} - diff --git a/Dump/hybos/src/objects/kernel.dis b/Dump/hybos/src/objects/kernel.dis deleted file mode 100644 index 0152ca3..0000000 --- a/Dump/hybos/src/objects/kernel.dis +++ /dev/null @@ -1,12860 +0,0 @@ - -../../boot/kernel.bin: file format elf32-i386-freebsd - -Disassembly of section .text: - -00100000 : -#include "_krnl.h" -#include "bootlog.h" - -void klog(char *proc, char *entry, KLOGRESULT result, console_t *vtty0) -{ - 100000: 55 push %ebp - 100001: 89 e5 mov %esp,%ebp - 100003: 57 push %edi - 100004: 56 push %esi - 100005: 53 push %ebx - 100006: 83 ec 0c sub $0xc,%esp - 100009: 8b 45 10 mov 0x10(%ebp),%eax - 10000c: 8b 5d 14 mov 0x14(%ebp),%ebx - unsigned oldattrib; - int i = 0; - 10000f: 31 f6 xor %esi,%esi - int offset = 69; /* -4 for the "[ ]" part, -2 for the ": " part, -1 for space at end, and -4 for the status */ - char status[4]; - va_list args; - - args = args; - status[0] = '\0'; - - /** - * Save our old color attributes - */ - oldattrib = vtty0->attrib; - - if(result == K_KLOG_SUCCESS) - 100011: 85 c0 test %eax,%eax - 100013: c7 45 f0 45 00 00 00 movl $0x45,0xfffffff0(%ebp) - 10001a: 8b 7b 18 mov 0x18(%ebx),%edi - 10001d: 0f 84 d5 00 00 00 je 1000f8 - { - /** - * Successfull initialization of something. - * Write "..Ok" then leave - */ - vtty0->attrib = 8; - printf("\b\b\b\b.."); - vtty0->attrib = 2; - printf("Ok\n"); - vtty0->attrib = oldattrib; - - return; - } - else if(result == K_KLOG_FAILURE) - 100023: 83 f8 02 cmp $0x2,%eax - 100026: 0f 84 b8 00 00 00 je 1000e4 - { - /** - * Unsuccessfull initialization of something. - * Write "Fail" then leave - */ - vtty0->attrib = 4; - printf("\b\b\b\bFail\n"); - vtty0->attrib = oldattrib; - - return; - } - - /** - * FIXME - * - * Should "wrap" the line instead - */ - if(strlen(entry) + 8 > 80) - 10002c: 83 ec 0c sub $0xc,%esp - 10002f: ff 75 0c pushl 0xc(%ebp) - 100032: e8 21 51 00 00 call 105158 - 100037: 83 c0 08 add $0x8,%eax - 10003a: 83 c4 10 add $0x10,%esp - 10003d: 83 f8 50 cmp $0x50,%eax - 100040: 76 0a jbe 10004c - return; - - vtty0->attrib = 8; - printf("[ "); - vtty0->attrib = 15; - printf("%s: %s", proc, entry); - vtty0->attrib = 8; - printf(" ]"); - - offset -= strlen(proc); - offset -= strlen(entry); - - for(i = 0; i < offset; i++) - printf("."); - - vtty0->attrib = 8; - printf("Wait"); - - vtty0->attrib = oldattrib; -} - 100042: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 100045: 5b pop %ebx - 100046: 5e pop %esi - 100047: 5f pop %edi - 100048: c9 leave - 100049: c3 ret - 10004a: 89 f6 mov %esi,%esi - 10004c: 83 ec 0c sub $0xc,%esp - 10004f: c7 43 18 08 00 00 00 movl $0x8,0x18(%ebx) - 100056: 68 b6 51 10 00 push $0x1051b6 - 10005b: e8 74 50 00 00 call 1050d4 - 100060: 83 c4 0c add $0xc,%esp - 100063: c7 43 18 0f 00 00 00 movl $0xf,0x18(%ebx) - 10006a: ff 75 0c pushl 0xc(%ebp) - 10006d: ff 75 08 pushl 0x8(%ebp) - 100070: 68 b9 51 10 00 push $0x1051b9 - 100075: e8 5a 50 00 00 call 1050d4 - 10007a: c7 43 18 08 00 00 00 movl $0x8,0x18(%ebx) - 100081: c7 04 24 c0 51 10 00 movl $0x1051c0,(%esp,1) - 100088: e8 47 50 00 00 call 1050d4 - 10008d: 5a pop %edx - 10008e: ff 75 08 pushl 0x8(%ebp) - 100091: e8 c2 50 00 00 call 105158 - 100096: 29 45 f0 sub %eax,0xfffffff0(%ebp) - 100099: 58 pop %eax - 10009a: ff 75 0c pushl 0xc(%ebp) - 10009d: e8 b6 50 00 00 call 105158 - 1000a2: 29 45 f0 sub %eax,0xfffffff0(%ebp) - 1000a5: 83 c4 10 add $0x10,%esp - 1000a8: 3b 75 f0 cmp 0xfffffff0(%ebp),%esi - 1000ab: 7d 16 jge 1000c3 - 1000ad: 8b 75 f0 mov 0xfffffff0(%ebp),%esi - 1000b0: 83 ec 0c sub $0xc,%esp - 1000b3: 68 1a 63 10 00 push $0x10631a - 1000b8: e8 17 50 00 00 call 1050d4 - 1000bd: 83 c4 10 add $0x10,%esp - 1000c0: 4e dec %esi - 1000c1: 75 ed jne 1000b0 - 1000c3: 83 ec 0c sub $0xc,%esp - 1000c6: c7 43 18 08 00 00 00 movl $0x8,0x18(%ebx) - 1000cd: 68 c3 51 10 00 push $0x1051c3 - 1000d2: 89 f6 mov %esi,%esi - 1000d4: e8 fb 4f 00 00 call 1050d4 - 1000d9: 89 7b 18 mov %edi,0x18(%ebx) - 1000dc: e9 61 ff ff ff jmp 100042 - 1000e1: 8d 76 00 lea 0x0(%esi),%esi - 1000e4: 83 ec 0c sub $0xc,%esp - 1000e7: c7 43 18 04 00 00 00 movl $0x4,0x18(%ebx) - 1000ee: 68 c8 51 10 00 push $0x1051c8 - 1000f3: eb df jmp 1000d4 - 1000f5: 8d 76 00 lea 0x0(%esi),%esi - 1000f8: 83 ec 0c sub $0xc,%esp - 1000fb: c7 43 18 08 00 00 00 movl $0x8,0x18(%ebx) - 100102: 68 d2 51 10 00 push $0x1051d2 - 100107: e8 c8 4f 00 00 call 1050d4 - 10010c: c7 43 18 02 00 00 00 movl $0x2,0x18(%ebx) - 100113: c7 04 24 d9 51 10 00 movl $0x1051d9,(%esp,1) - 10011a: eb b8 jmp 1000d4 - -0010011c : -*****************************************************************************/ -#define BPERL 16 /* byte/line for dump */ - -void dump(unsigned char *data, unsigned count) -{ - 10011c: 55 push %ebp - 10011d: 89 e5 mov %esp,%ebp - 10011f: 57 push %edi - 100120: 56 push %esi - 100121: 53 push %ebx - 100122: 83 ec 0c sub $0xc,%esp - 100125: 8b 75 0c mov 0xc(%ebp),%esi - unsigned char byte1, byte2; - - while(count != 0) - 100128: 85 f6 test %esi,%esi - 10012a: 0f 84 86 00 00 00 je 1001b6 - { - for(byte1 = 0; byte1 < BPERL; byte1++) - 100130: 31 ff xor %edi,%edi - 100132: 8b 5d 08 mov 0x8(%ebp),%ebx - 100135: 8d 76 00 lea 0x0(%esi),%esi - { - if(count == 0) - 100138: 85 f6 test %esi,%esi - 10013a: 74 1d je 100159 - break; - printf("%02X ", data[byte1]); - 10013c: 83 ec 08 sub $0x8,%esp - 10013f: 0f b6 03 movzbl (%ebx),%eax - 100142: 50 push %eax - 100143: 68 dd 51 10 00 push $0x1051dd - 100148: 47 inc %edi - 100149: e8 86 4f 00 00 call 1050d4 - 10014e: 89 f8 mov %edi,%eax - count--; - 100150: 4e dec %esi - 100151: 83 c4 10 add $0x10,%esp - 100154: 43 inc %ebx - 100155: 3c 0f cmp $0xf,%al - 100157: 76 df jbe 100138 - } - printf("\t"); - 100159: 83 ec 0c sub $0xc,%esp - 10015c: 68 e3 51 10 00 push $0x1051e3 - 100161: e8 6e 4f 00 00 call 1050d4 - for(byte2 = 0; byte2 < byte1; byte2++) - 100166: 31 db xor %ebx,%ebx - 100168: 89 fa mov %edi,%edx - 10016a: 83 c4 10 add $0x10,%esp - 10016d: 38 d3 cmp %dl,%bl - 10016f: 73 29 jae 10019a - 100171: 8d 76 00 lea 0x0(%esi),%esi - { - if(data[byte2] < ' ') - 100174: 0f b6 c3 movzbl %bl,%eax - 100177: 8b 55 08 mov 0x8(%ebp),%edx - 10017a: 8a 04 10 mov (%eax,%edx,1),%al - 10017d: 3c 1f cmp $0x1f,%al - 10017f: 77 3f ja 1001c0 - printf("%c", '.'); - 100181: 83 ec 08 sub $0x8,%esp - 100184: 6a 2e push $0x2e - 100186: 68 e5 51 10 00 push $0x1051e5 - 10018b: e8 44 4f 00 00 call 1050d4 - 100190: 43 inc %ebx - 100191: 89 f8 mov %edi,%eax - else - printf("%c", data[byte2]); - 100193: 83 c4 10 add $0x10,%esp - 100196: 38 c3 cmp %al,%bl - 100198: 72 da jb 100174 - } - printf("\n"); - 10019a: 83 ec 0c sub $0xc,%esp - 10019d: 68 f8 5a 10 00 push $0x105af8 - 1001a2: e8 2d 4f 00 00 call 1050d4 - data += BPERL; - 1001a7: 83 45 08 10 addl $0x10,0x8(%ebp) - 1001ab: 83 c4 10 add $0x10,%esp - 1001ae: 85 f6 test %esi,%esi - 1001b0: 0f 85 7a ff ff ff jne 100130 - } -} - 1001b6: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 1001b9: 5b pop %ebx - 1001ba: 5e pop %esi - 1001bb: 5f pop %edi - 1001bc: c9 leave - 1001bd: c3 ret - 1001be: 89 f6 mov %esi,%esi - 1001c0: 83 ec 08 sub $0x8,%esp - 1001c3: 0f b6 c0 movzbl %al,%eax - 1001c6: 50 push %eax - 1001c7: eb bd jmp 100186 - 1001c9: 8d 76 00 lea 0x0(%esi),%esi - -001001cc : -/***************************************************************************** -*****************************************************************************/ -void dump_regs(regs_t *regs) -{ - 1001cc: 55 push %ebp - 1001cd: 89 e5 mov %esp,%ebp - 1001cf: 53 push %ebx - 1001d0: 83 ec 10 sub $0x10,%esp - 1001d3: 8b 5d 08 mov 0x8(%ebp),%ebx - printf("EDI=%08X ESI=%08X EBP=%08X ESP=%08X\n", - 1001d6: ff 73 0c pushl 0xc(%ebx) - 1001d9: ff 73 08 pushl 0x8(%ebx) - 1001dc: ff 73 04 pushl 0x4(%ebx) - 1001df: ff 33 pushl (%ebx) - 1001e1: 68 00 52 10 00 push $0x105200 - 1001e6: e8 e9 4e 00 00 call 1050d4 - regs->edi, regs->esi, regs->ebp, regs->esp); - printf("EBX=%08X EDX=%08X ECX=%08X EAX=%08X\n", - 1001eb: 83 c4 14 add $0x14,%esp - 1001ee: ff 73 1c pushl 0x1c(%ebx) - 1001f1: ff 73 18 pushl 0x18(%ebx) - 1001f4: ff 73 14 pushl 0x14(%ebx) - 1001f7: ff 73 10 pushl 0x10(%ebx) - 1001fa: 68 40 52 10 00 push $0x105240 - 1001ff: e8 d0 4e 00 00 call 1050d4 - regs->ebx, regs->edx, regs->ecx, regs->eax); - printf(" DS=%08X ES=%08X FS=%08X GS=%08X\n", - 100204: 83 c4 14 add $0x14,%esp - 100207: ff 73 2c pushl 0x2c(%ebx) - 10020a: ff 73 28 pushl 0x28(%ebx) - 10020d: ff 73 24 pushl 0x24(%ebx) - 100210: ff 73 20 pushl 0x20(%ebx) - 100213: 68 80 52 10 00 push $0x105280 - 100218: e8 b7 4e 00 00 call 1050d4 - regs->ds, regs->es, regs->fs, regs->gs); - printf("int=%08X err=%08X EIP=%08X CS=%08X\n", - 10021d: 83 c4 14 add $0x14,%esp - 100220: ff 73 3c pushl 0x3c(%ebx) - 100223: ff 73 38 pushl 0x38(%ebx) - 100226: ff 73 34 pushl 0x34(%ebx) - 100229: ff 73 30 pushl 0x30(%ebx) - 10022c: 68 c0 52 10 00 push $0x1052c0 - 100231: e8 9e 4e 00 00 call 1050d4 - regs->which_int, regs->err_code, regs->eip, regs->cs); - printf("uSP=%08X uSS=%08X\n", regs->user_esp, regs->user_ss); - 100236: 83 c4 1c add $0x1c,%esp - 100239: ff 73 48 pushl 0x48(%ebx) - 10023c: ff 73 44 pushl 0x44(%ebx) - 10023f: 68 e8 51 10 00 push $0x1051e8 - 100244: e8 8b 4e 00 00 call 1050d4 -} - 100249: 8b 5d fc mov 0xfffffffc(%ebp),%ebx - 10024c: c9 leave - 10024d: c3 ret - ... - -00100250 : - * - * @return void - */ -void keyDown(unsigned key) -{ - 100250: 55 push %ebp - 100251: 89 e5 mov %esp,%ebp - key = key; /* to shut gcc up */ -} - 100253: c9 leave - 100254: c3 ret - 100255: 8d 76 00 lea 0x0(%esi),%esi - -00100258 : - -/** - * keyUp() - * - * This function is called when a key is released. - * - * @param unsigned Which key was released. See keyboard.h - * - * @return void - */ -void keyUp(unsigned key) -{ - 100258: 55 push %ebp - 100259: 89 e5 mov %esp,%ebp - key = key; /* to shut gcc up */ -} - 10025b: c9 leave - 10025c: c3 ret - 10025d: 8d 76 00 lea 0x0(%esi),%esi - -00100260 : - -void initCommands(void) -{ - 100260: 55 push %ebp - 100261: 89 e5 mov %esp,%ebp - 100263: 83 ec 10 sub $0x10,%esp - eshCommands[0].minparams = 0; - eshCommands[0].maxparams = 0; - strcpy(eshCommands[0].command, "dumpheap\0"); - 100266: 68 00 53 10 00 push $0x105300 - 10026b: 68 48 3a 18 00 push $0x183a48 - 100270: c7 05 40 3a 18 00 00 movl $0x0,0x183a40 - 100277: 00 00 00 - 10027a: c7 05 44 3a 18 00 00 movl $0x0,0x183a44 - 100281: 00 00 00 - 100284: e8 b3 4e 00 00 call 10513c - strcpy(eshCommands[0].params[0], "-h\0"); - 100289: 58 pop %eax - 10028a: 5a pop %edx - 10028b: 68 0a 53 10 00 push $0x10530a - 100290: 68 48 3c 18 00 push $0x183c48 - 100295: e8 a2 4e 00 00 call 10513c - strcpy(eshCommands[0].description, "Print listing of heap usage and status.\0"); - 10029a: 59 pop %ecx - 10029b: 58 pop %eax - 10029c: 68 20 53 10 00 push $0x105320 - 1002a1: 68 48 64 18 00 push $0x186448 - 1002a6: e8 91 4e 00 00 call 10513c - - eshCommands[1].minparams = 1; - eshCommands[1].maxparams = MAX_PARAMS; - strcpy(eshCommands[1].params[0], "-h\0"); - 1002ab: 58 pop %eax - 1002ac: 5a pop %edx - 1002ad: 68 0a 53 10 00 push $0x10530a - 1002b2: 68 50 68 18 00 push $0x186850 - 1002b7: c7 05 48 66 18 00 01 movl $0x1,0x186648 - 1002be: 00 00 00 - 1002c1: c7 05 4c 66 18 00 14 movl $0x14,0x18664c - 1002c8: 00 00 00 - 1002cb: e8 6c 4e 00 00 call 10513c - strcpy(eshCommands[1].command, "echo\0"); - 1002d0: 59 pop %ecx - 1002d1: 58 pop %eax - 1002d2: 68 49 53 10 00 push $0x105349 - 1002d7: 68 50 66 18 00 push $0x186650 - 1002dc: e8 5b 4e 00 00 call 10513c - strcpy(eshCommands[1].description, "Echo a line of text to the terminal.\0"); - 1002e1: 58 pop %eax - 1002e2: 5a pop %edx - 1002e3: 68 60 53 10 00 push $0x105360 - 1002e8: 68 50 90 18 00 push $0x189050 - 1002ed: e8 4a 4e 00 00 call 10513c - - /*this will be called with either "help" or "help command" */ - eshCommands[2].minparams = 0; - eshCommands[2].maxparams = 1; - strcpy(eshCommands[2].params[0], "-h\0"); - 1002f2: 59 pop %ecx - 1002f3: 58 pop %eax - 1002f4: 68 0a 53 10 00 push $0x10530a - 1002f9: 68 58 94 18 00 push $0x189458 - 1002fe: c7 05 50 92 18 00 00 movl $0x0,0x189250 - 100305: 00 00 00 - 100308: c7 05 54 92 18 00 01 movl $0x1,0x189254 - 10030f: 00 00 00 - 100312: e8 25 4e 00 00 call 10513c - strcpy(eshCommands[2].command, "help\0"); - 100317: 58 pop %eax - 100318: 5a pop %edx - 100319: 68 86 53 10 00 push $0x105386 - 10031e: 68 58 92 18 00 push $0x189258 - 100323: e8 14 4e 00 00 call 10513c - strcpy(eshCommands[2].description, "Displays general help menu or help on specific command.\0"); - 100328: 59 pop %ecx - 100329: 58 pop %eax - 10032a: 68 a0 53 10 00 push $0x1053a0 - 10032f: 68 58 bc 18 00 push $0x18bc58 - 100334: e8 03 4e 00 00 call 10513c - - /* -r|-h [time] */ - eshCommands[3].minparams = 1; - eshCommands[3].maxparams = 2; - strcpy(eshCommands[3].command, "shutdown\0"); - 100339: 58 pop %eax - 10033a: 5a pop %edx - 10033b: 68 d9 53 10 00 push $0x1053d9 - 100340: 68 60 be 18 00 push $0x18be60 - 100345: c7 05 58 be 18 00 01 movl $0x1,0x18be58 - 10034c: 00 00 00 - 10034f: c7 05 5c be 18 00 02 movl $0x2,0x18be5c - 100356: 00 00 00 - 100359: e8 de 4d 00 00 call 10513c - strcpy(eshCommands[3].params[0], "-r\0"); - 10035e: 59 pop %ecx - 10035f: 58 pop %eax - 100360: 68 e3 53 10 00 push $0x1053e3 - 100365: 68 60 c0 18 00 push $0x18c060 - 10036a: e8 cd 4d 00 00 call 10513c - strcpy(eshCommands[3].params[1], "-h\0"); - 10036f: 58 pop %eax - 100370: 5a pop %edx - 100371: 68 0a 53 10 00 push $0x10530a - 100376: 68 60 c2 18 00 push $0x18c260 - 10037b: e8 bc 4d 00 00 call 10513c - strcpy(eshCommands[3].params[2], "NOW\0"); - 100380: 59 pop %ecx - 100381: 58 pop %eax - 100382: 68 e7 53 10 00 push $0x1053e7 - 100387: 68 60 c4 18 00 push $0x18c460 - 10038c: e8 ab 4d 00 00 call 10513c - strcpy(eshCommands[3].description, "Halt or restart the system.\0"); - 100391: 58 pop %eax - 100392: 5a pop %edx - 100393: 68 ec 53 10 00 push $0x1053ec - 100398: 68 60 e8 18 00 push $0x18e860 - 10039d: e8 9a 4d 00 00 call 10513c - - /* clear screen */ - eshCommands[4].minparams = 0; - eshCommands[4].maxparams = 0; - strcpy(eshCommands[4].params[0], "-h\0"); - 1003a2: 59 pop %ecx - 1003a3: 58 pop %eax - 1003a4: 68 0a 53 10 00 push $0x10530a - 1003a9: 68 68 ec 18 00 push $0x18ec68 - 1003ae: c7 05 60 ea 18 00 00 movl $0x0,0x18ea60 - 1003b5: 00 00 00 - 1003b8: c7 05 64 ea 18 00 00 movl $0x0,0x18ea64 - 1003bf: 00 00 00 - 1003c2: e8 75 4d 00 00 call 10513c - strcpy(eshCommands[4].command, "cls\0"); - 1003c7: 58 pop %eax - 1003c8: 5a pop %edx - 1003c9: 68 09 54 10 00 push $0x105409 - 1003ce: 68 68 ea 18 00 push $0x18ea68 - 1003d3: e8 64 4d 00 00 call 10513c - strcpy(eshCommands[4].description, "Clears the terminal of all output.\0"); - 1003d8: 59 pop %ecx - 1003d9: 58 pop %eax - 1003da: 68 20 54 10 00 push $0x105420 - 1003df: 68 68 14 19 00 push $0x191468 - 1003e4: e8 53 4d 00 00 call 10513c - - /* print working directory */ - eshCommands[5].minparams = 0; - eshCommands[5].maxparams = 0; - strcpy(eshCommands[5].params[0], "-h\0"); - 1003e9: 58 pop %eax - 1003ea: 5a pop %edx - 1003eb: 68 0a 53 10 00 push $0x10530a - 1003f0: 68 70 18 19 00 push $0x191870 - 1003f5: c7 05 68 16 19 00 00 movl $0x0,0x191668 - 1003fc: 00 00 00 - 1003ff: c7 05 6c 16 19 00 00 movl $0x0,0x19166c - 100406: 00 00 00 - 100409: e8 2e 4d 00 00 call 10513c - strcpy(eshCommands[5].command, "pwd\0"); - 10040e: 59 pop %ecx - 10040f: 58 pop %eax - 100410: 68 44 54 10 00 push $0x105444 - 100415: 68 70 16 19 00 push $0x191670 - 10041a: e8 1d 4d 00 00 call 10513c - strcpy(eshCommands[5].description, "Prints the current working directory.\0"); - 10041f: 58 pop %eax - 100420: 5a pop %edx - 100421: 68 60 54 10 00 push $0x105460 - 100426: 68 70 40 19 00 push $0x194070 - 10042b: e8 0c 4d 00 00 call 10513c -} - 100430: c9 leave - 100431: c3 ret - 100432: 89 f6 mov %esi,%esi - -00100434 : - -/** - * mapCommand() - * - * Used internally by esh to map a command to it's zero-based - * index of commands. - * - * @param char * the entire line of the command - * - * @return int index of command entry if found, otherwise -1 - */ -int mapCommand(char *cmd) -{ - 100434: 55 push %ebp - 100435: 89 e5 mov %esp,%ebp - 100437: 57 push %edi - 100438: 56 push %esi - 100439: 53 push %ebx - 10043a: 81 ec 0c 02 00 00 sub $0x20c,%esp - 100440: 8b 75 08 mov 0x8(%ebp),%esi - int i; /* for our loops */ - int params; /* number of parameters found for the command */ - int previdx; /* previous index */ - char cmdName[MAX_LEN]; /* name of the command */ - - i = 0; - 100443: 31 db xor %ebx,%ebx - 100445: 8d 76 00 lea 0x0(%esi),%esi - previdx = 0; - params = 0; - - /** - * Loop while cmd[i] is not a space - */ - i = 0; - for(i = 0; i < (int)strlen(cmd); i++) - 100448: 83 ec 0c sub $0xc,%esp - 10044b: 56 push %esi - 10044c: e8 07 4d 00 00 call 105158 - 100451: 83 c4 10 add $0x10,%esp - 100454: 39 c3 cmp %eax,%ebx - 100456: 7d 09 jge 100461 - { - if(cmd[i] == ' ') - 100458: 80 3c 33 20 cmpb $0x20,(%ebx,%esi,1) - 10045c: 74 03 je 100461 - 10045e: 43 inc %ebx - 10045f: eb e7 jmp 100448 - break; - } - - strncpy(cmdName, cmd, i); - 100461: 51 push %ecx - 100462: 53 push %ebx - 100463: 56 push %esi - 100464: 8d bd e8 fd ff ff lea 0xfffffde8(%ebp),%edi - 10046a: 57 push %edi - 10046b: e8 04 4d 00 00 call 105174 - cmdName[i] = '\0'; - - for(i = 0; i < COMMAND_COUNT; i++) - 100470: be 48 3a 18 00 mov $0x183a48,%esi - 100475: c6 84 2b e8 fd ff ff movb $0x0,0xfffffde8(%ebx,%ebp,1) - 10047c: 00 - 10047d: 83 c4 10 add $0x10,%esp - 100480: 31 db xor %ebx,%ebx - 100482: 89 f6 mov %esi,%esi - { - if(!strcmp(eshCommands[i].command, cmdName)) - 100484: 83 ec 08 sub $0x8,%esp - 100487: 57 push %edi - 100488: 56 push %esi - 100489: e8 62 4c 00 00 call 1050f0 - 10048e: 83 c4 10 add $0x10,%esp - 100491: 85 c0 test %eax,%eax - 100493: 89 da mov %ebx,%edx - 100495: 74 11 je 1004a8 - 100497: 43 inc %ebx - 100498: 81 c6 08 2c 00 00 add $0x2c08,%esi - 10049e: 83 fb 05 cmp $0x5,%ebx - 1004a1: 7e e1 jle 100484 - return i; - } - - return -1; - 1004a3: ba ff ff ff ff mov $0xffffffff,%edx -} - 1004a8: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 1004ab: 5b pop %ebx - 1004ac: 5e pop %esi - 1004ad: 89 d0 mov %edx,%eax - 1004af: 5f pop %edi - 1004b0: c9 leave - 1004b1: c3 ret - 1004b2: 89 f6 mov %esi,%esi - -001004b4 : - -/** - * isParam() - * - * Determines if the supplied parameter is valid for the - * given command. - * - * @param int index of command - * @param char * command string - * - * @return bool true if parameter is valid, false otherwise - */ -bool isParam(int argc, char *argv) -{ - 1004b4: 55 push %ebp - 1004b5: 89 e5 mov %esp,%ebp - 1004b7: 57 push %edi - 1004b8: 56 push %esi - 1004b9: 53 push %ebx - 1004ba: 83 ec 0c sub $0xc,%esp - 1004bd: 8b 55 08 mov 0x8(%ebp),%edx - int i; - - for(i = 0; i < MAX_PARAMS; i++) - 1004c0: 8d 04 92 lea (%edx,%edx,4),%eax - 1004c3: 8d 04 42 lea (%edx,%eax,2),%eax - 1004c6: c1 e0 07 shl $0x7,%eax - 1004c9: 01 d0 add %edx,%eax - 1004cb: 8b 7d 0c mov 0xc(%ebp),%edi - 1004ce: 31 f6 xor %esi,%esi - 1004d0: 8d 1c c5 48 3c 18 00 lea 0x183c48(,%eax,8),%ebx - 1004d7: 90 nop - { - if(!strcmp(eshCommands[argc].params[i], argv)) - 1004d8: 83 ec 08 sub $0x8,%esp - 1004db: 57 push %edi - 1004dc: 53 push %ebx - 1004dd: e8 0e 4c 00 00 call 1050f0 - 1004e2: 83 c4 10 add $0x10,%esp - 1004e5: 85 c0 test %eax,%eax - 1004e7: ba 01 00 00 00 mov $0x1,%edx - 1004ec: 74 0e je 1004fc - 1004ee: 46 inc %esi - 1004ef: 81 c3 00 02 00 00 add $0x200,%ebx - 1004f5: 83 fe 13 cmp $0x13,%esi - 1004f8: 7e de jle 1004d8 - return true; - } - - return false; - 1004fa: 31 d2 xor %edx,%edx -} - 1004fc: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 1004ff: 5b pop %ebx - 100500: 5e pop %esi - 100501: 89 d0 mov %edx,%eax - 100503: 5f pop %edi - 100504: c9 leave - 100505: c3 ret - 100506: 89 f6 mov %esi,%esi - -00100508 : - -/** - * mapParams() - * - * Maps each parameter to the pars struct - * - * @param char * Buffer from the command line - * @param struct Parameter structure - * - * @return int Number of command line parameters (arguments) parsed - */ -int mapParams(char *buf, ESHCURRCOMMAND *pars) -{ - 100508: 55 push %ebp - 100509: 89 e5 mov %esp,%ebp - 10050b: 57 push %edi - 10050c: 56 push %esi - 10050d: 53 push %ebx - 10050e: 83 ec 18 sub $0x18,%esp - 100511: 8b 7d 08 mov 0x8(%ebp),%edi - int i; /* for our loops */ - int previdx; /* previous index */ - int idx; /* current index */ - int j; /* loops */ - - i = 0; - j = 0; - previdx = 0; - pars->count = 0; - 100514: 8b 45 0c mov 0xc(%ebp),%eax - 100517: c7 00 00 00 00 00 movl $0x0,(%eax) - - previdx = mapCommand(buf); - 10051d: 57 push %edi - 10051e: e8 11 ff ff ff call 100434 - 100523: 89 c2 mov %eax,%edx - 100525: 31 f6 xor %esi,%esi - - if(previdx == -1) - 100527: 83 c4 10 add $0x10,%esp - 10052a: 31 c0 xor %eax,%eax - 10052c: 83 fa ff cmp $0xffffffff,%edx - 10052f: 0f 84 0d 01 00 00 je 100642 - return 0; - - strcpy(pars->param[0], eshCommands[previdx].command); - 100535: 8d 04 92 lea (%edx,%edx,4),%eax - 100538: 8d 04 42 lea (%edx,%eax,2),%eax - 10053b: c1 e0 07 shl $0x7,%eax - 10053e: 01 d0 add %edx,%eax - 100540: 83 ec 08 sub $0x8,%esp - 100543: 8d 04 c5 48 3a 18 00 lea 0x183a48(,%eax,8),%eax - 10054a: 50 push %eax - 10054b: 8b 45 0c mov 0xc(%ebp),%eax - 10054e: 83 c0 04 add $0x4,%eax - 100551: 50 push %eax - 100552: e8 e5 4b 00 00 call 10513c - j++; - pars->count++; - 100557: 8b 55 0c mov 0xc(%ebp),%edx - 10055a: ff 02 incl (%edx) - - i = 0; - idx = 0; - - for(i = 0; i < (int)strlen(buf); i++) - 10055c: 83 c4 10 add $0x10,%esp - 10055f: 81 c2 00 02 00 00 add $0x200,%edx - 100565: c7 45 ec 01 00 00 00 movl $0x1,0xffffffec(%ebp) - 10056c: 89 55 e8 mov %edx,0xffffffe8(%ebp) - 10056f: 90 nop - 100570: 83 ec 0c sub $0xc,%esp - 100573: 57 push %edi - 100574: e8 df 4b 00 00 call 105158 - 100579: 83 c4 10 add $0x10,%esp - 10057c: 39 c6 cmp %eax,%esi - 10057e: 0f 8d b9 00 00 00 jge 10063d - { - /* we have encountered a seperator */ - if(buf[i] == ' ') - 100584: 80 3c 3e 20 cmpb $0x20,(%esi,%edi,1) - 100588: 74 06 je 100590 - 10058a: 46 inc %esi - 10058b: eb e3 jmp 100570 - 10058d: 8d 76 00 lea 0x0(%esi),%esi - { - if(j > MAX_PARAMS) - 100590: 83 7d ec 14 cmpl $0x14,0xffffffec(%ebp) - 100594: 0f 8f a3 00 00 00 jg 10063d - break; - - i++; /* skip one space */ - 10059a: 46 inc %esi - - idx = i; - 10059b: 89 75 f0 mov %esi,0xfffffff0(%ebp) - - if(buf[i] == '"') - 10059e: 8a 04 3e mov (%esi,%edi,1),%al - 1005a1: 3c 22 cmp $0x22,%al - 1005a3: 74 57 je 1005fc - 1005a5: 8d 76 00 lea 0x0(%esi),%esi - 1005a8: 3c 20 cmp $0x20,%al - 1005aa: 74 16 je 1005c2 - 1005ac: 83 ec 0c sub $0xc,%esp - 1005af: 57 push %edi - 1005b0: e8 a3 4b 00 00 call 105158 - 1005b5: 83 c4 10 add $0x10,%esp - 1005b8: 39 c6 cmp %eax,%esi - 1005ba: 74 06 je 1005c2 - { - i++; - idx++; - - while(buf[i] != '"' && i != (int)strlen(buf)) - i++; - - strncpy(pars->param[j], &buf[idx], (i - idx)); - pars->param[j][i - idx] = '\0'; - - idx = i; - j++; - pars->count++; - } - else - { - while(buf[i] != ' ' && i != (int)strlen(buf)) - i++; - 1005bc: 46 inc %esi - 1005bd: 8a 04 3e mov (%esi,%edi,1),%al - 1005c0: eb e6 jmp 1005a8 - - strncpy(pars->param[j], &buf[idx], i - idx); - 1005c2: 53 push %ebx - 1005c3: 89 f3 mov %esi,%ebx - 1005c5: 2b 5d f0 sub 0xfffffff0(%ebp),%ebx - 1005c8: 8b 55 f0 mov 0xfffffff0(%ebp),%edx - 1005cb: 53 push %ebx - 1005cc: 8d 04 3a lea (%edx,%edi,1),%eax - 1005cf: 50 push %eax - 1005d0: 8b 45 e8 mov 0xffffffe8(%ebp),%eax - 1005d3: 83 c0 04 add $0x4,%eax - 1005d6: 50 push %eax - 1005d7: e8 98 4b 00 00 call 105174 - pars->param[j][i - idx] = '\0'; - 1005dc: 8b 45 e8 mov 0xffffffe8(%ebp),%eax - 1005df: c6 44 03 04 00 movb $0x0,0x4(%ebx,%eax,1) - i = idx; - 1005e4: 8b 75 f0 mov 0xfffffff0(%ebp),%esi - j++; - 1005e7: 05 00 02 00 00 add $0x200,%eax - pars->count++; - 1005ec: 8b 55 0c mov 0xc(%ebp),%edx - 1005ef: ff 45 ec incl 0xffffffec(%ebp) - 1005f2: 89 45 e8 mov %eax,0xffffffe8(%ebp) - 1005f5: ff 02 incl (%edx) - 1005f7: 83 c4 10 add $0x10,%esp - 1005fa: eb 8e jmp 10058a - 1005fc: 46 inc %esi - 1005fd: ff 45 f0 incl 0xfffffff0(%ebp) - 100600: 80 3c 3e 22 cmpb $0x22,(%esi,%edi,1) - 100604: 74 13 je 100619 - 100606: 83 ec 0c sub $0xc,%esp - 100609: 57 push %edi - 10060a: e8 49 4b 00 00 call 105158 - 10060f: 83 c4 10 add $0x10,%esp - 100612: 39 c6 cmp %eax,%esi - 100614: 74 03 je 100619 - 100616: 46 inc %esi - 100617: eb e7 jmp 100600 - 100619: 89 f3 mov %esi,%ebx - 10061b: 2b 5d f0 sub 0xfffffff0(%ebp),%ebx - 10061e: 8b 55 f0 mov 0xfffffff0(%ebp),%edx - 100621: 50 push %eax - 100622: 53 push %ebx - 100623: 8d 04 3a lea (%edx,%edi,1),%eax - 100626: 50 push %eax - 100627: 8b 45 e8 mov 0xffffffe8(%ebp),%eax - 10062a: 83 c0 04 add $0x4,%eax - 10062d: 50 push %eax - 10062e: e8 41 4b 00 00 call 105174 - 100633: 8b 45 e8 mov 0xffffffe8(%ebp),%eax - 100636: c6 44 03 04 00 movb $0x0,0x4(%ebx,%eax,1) - 10063b: eb aa jmp 1005e7 - } - } - } - - return pars->count; - 10063d: 8b 55 0c mov 0xc(%ebp),%edx - 100640: 8b 02 mov (%edx),%eax -} - 100642: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 100645: 5b pop %ebx - 100646: 5e pop %esi - 100647: 5f pop %edi - 100648: c9 leave - 100649: c3 ret - 10064a: 89 f6 mov %esi,%esi - -0010064c : - -/** - * processCommand() - * - * This function is called when the user has pressed - * the ENTER key. - * - * @param char * The contents of the current buffer or NULL if empty - * @param int Size of the buffer (number of characters) - * - * @return void - */ -void processCommand(char *line, int count) -{ - 10064c: 55 push %ebp - 10064d: 89 e5 mov %esp,%ebp - 10064f: 57 push %edi - 100650: 56 push %esi - 100651: 53 push %ebx - 100652: 81 ec 1c 50 00 00 sub $0x501c,%esp - 100658: 8b 75 08 mov 0x8(%ebp),%esi - int i; - int cmd; /* stores the numeric index of the command */ - ESHCURRCOMMAND params; - - count = count; /* to shut gcc up */ - - /*for(i = 0; i < MAX_PARAMS; i++) - params.param[i][0] = '\0';*/ - params.param[0][0] = '\0'; - 10065b: c6 85 dc af ff ff 00 movb $0x0,0xffffafdc(%ebp) - - initCommands(); - 100662: e8 f9 fb ff ff call 100260 - - cmd = mapCommand(line); - 100667: 83 ec 0c sub $0xc,%esp - 10066a: 56 push %esi - 10066b: e8 c4 fd ff ff call 100434 - mapParams(line, ¶ms); - 100670: 5f pop %edi - 100671: 89 c3 mov %eax,%ebx - 100673: 8d bd d8 af ff ff lea 0xffffafd8(%ebp),%edi - 100679: 58 pop %eax - 10067a: 57 push %edi - 10067b: 56 push %esi - 10067c: e8 87 fe ff ff call 100508 - - switch(cmd) - 100681: 83 c4 10 add $0x10,%esp - 100684: 83 fb 01 cmp $0x1,%ebx - 100687: 0f 84 13 01 00 00 je 1007a0 - 10068d: 83 fb 01 cmp $0x1,%ebx - 100690: 0f 8e f6 00 00 00 jle 10078c - 100696: 83 fb 02 cmp $0x2,%ebx - 100699: 74 4a je 1006e5 - { - case 0: /* dumpheap */ - dumpheapk(); - //testheap(); - break; - case 1: /* echo */ - for(i = 1; i < params.count; i++) - printf("%s", params.param[i]); - - printf("\n"); - break; - case 2: /* help */ - if(params.count == 1) - { - printf("HybOS EShell Commands:\n"); - for(i = 0; i < COMMAND_COUNT; i++) - if(strlen(eshCommands[i].command) > 0) - printf("%10s %-s\n", eshCommands[i].command, eshCommands[i].description); - } - else - { - cmd = mapCommand(params.param[0]); - mapParams(params.param[1], ¶ms); - - //if(isParam(cmd, params.param[1])) - if(cmd != -1) - { - printf("Usage: %s %s\n", params.param[0], eshCommands[cmd].params[1]); - } - else - printf("esh: '%s' not found.\n", params.param[1]); - } - break; - default: - if(strlen(params.param[0]) > 0 && strcmp(params.param[0], "help")) - 10069b: 83 ec 0c sub $0xc,%esp - 10069e: 8d 9d dc af ff ff lea 0xffffafdc(%ebp),%ebx - 1006a4: 53 push %ebx - 1006a5: e8 ae 4a 00 00 call 105158 - 1006aa: 83 c4 10 add $0x10,%esp - 1006ad: 85 c0 test %eax,%eax - 1006af: 74 15 je 1006c6 - 1006b1: 83 ec 08 sub $0x8,%esp - 1006b4: 68 87 54 10 00 push $0x105487 - 1006b9: 53 push %ebx - 1006ba: e8 31 4a 00 00 call 1050f0 - 1006bf: 83 c4 10 add $0x10,%esp - 1006c2: 85 c0 test %eax,%eax - 1006c4: 75 19 jne 1006df - printf("esh: '%s' not found.\n", params.param[0]); - else - printf("esh: '%s' not found.\n", &line[0]); - 1006c6: 83 ec 08 sub $0x8,%esp - 1006c9: 56 push %esi - 1006ca: 68 8c 54 10 00 push $0x10548c - 1006cf: e8 00 4a 00 00 call 1050d4 - 1006d4: 83 c4 10 add $0x10,%esp - break; - } - - /*for(i = 0; i < params.count; i++) - printf("param[%i]: %s\n", i, params.param[i]);*/ - - //if(isParam(3, ¶ms.param[1])) - // printf("valid parameter\n"); - //else - // printf("invalid parameter\n"); - - return; - - if(!strcmp(line, "dumpheap")) - dumpheapk(); - else if(!strncmp(line, "echo", 4)) - printf("%s\n", line[4] == ' ' ? &line[5] : &line[4]); - else if(!strcmp(line, "help")) - { - printf("HybOS EShell Commands:\n"); - printf("dumpheap\tPrint listing of heap usage and status\n"); - printf("testheap\tTest the heap and print out results\n"); - printf("shutdown -r\tRestart the system.\n"); - printf("pwd\t\tPrint the current working directory.\n"); - } - else if(!strncmp(line, "shutdown", 8)) - { - if(strlen(line) > 9 && !strncmp(&line[9], "-r", 2)) - { - printf("\nSystem shutdown from vtty%u\n", get_current_vc()); - printf("Restarting..."); - //reboot(); - } - else - { - if((strlen(line) > 9) && (strlen(&line[9]) > 0)) - printf("shutdown: Invalid argument \"%s\".\n", &line[9]); - else - printf("Usage: shutdown -r\n"); - } - } - else if((strlen(line) > 0) && (!strcmp(line, "cls"))) - { - printf("\x1B[2J"); - } - else if((strlen(line) >= 8) && (!strcmp(line, "testheap"))) - { - //testheap(); - } - else if((strlen(line) > 0) && (!strcmp(line, "pwd"))) - printf("/\n"); - else if(strlen(line) > 0) - printf("eshell: \"%s\" not found.\n", line); -} - 1006d7: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 1006da: 5b pop %ebx - 1006db: 5e pop %esi - 1006dc: 5f pop %edi - 1006dd: c9 leave - 1006de: c3 ret - 1006df: 83 ec 08 sub $0x8,%esp - 1006e2: 53 push %ebx - 1006e3: eb e5 jmp 1006ca - 1006e5: 83 bd d8 af ff ff 01 cmpl $0x1,0xffffafd8(%ebp) - 1006ec: 74 4a je 100738 - 1006ee: 83 ec 0c sub $0xc,%esp - 1006f1: 8d 85 dc af ff ff lea 0xffffafdc(%ebp),%eax - 1006f7: 50 push %eax - 1006f8: e8 37 fd ff ff call 100434 - 1006fd: 89 c3 mov %eax,%ebx - 1006ff: 58 pop %eax - 100700: 5a pop %edx - 100701: 57 push %edi - 100702: 8d b5 dc b1 ff ff lea 0xffffb1dc(%ebp),%esi - 100708: 56 push %esi - 100709: e8 fa fd ff ff call 100508 - 10070e: 83 c4 10 add $0x10,%esp - 100711: 83 fb ff cmp $0xffffffff,%ebx - 100714: 74 b0 je 1006c6 - 100716: 50 push %eax - 100717: 8d 04 9b lea (%ebx,%ebx,4),%eax - 10071a: 8d 04 43 lea (%ebx,%eax,2),%eax - 10071d: c1 e0 07 shl $0x7,%eax - 100720: 01 d8 add %ebx,%eax - 100722: 8d 04 c5 48 3e 18 00 lea 0x183e48(,%eax,8),%eax - 100729: 50 push %eax - 10072a: 8d 85 dc af ff ff lea 0xffffafdc(%ebp),%eax - 100730: 50 push %eax - 100731: 68 a2 54 10 00 push $0x1054a2 - 100736: eb 97 jmp 1006cf - 100738: 83 ec 0c sub $0xc,%esp - 10073b: 68 b0 54 10 00 push $0x1054b0 - 100740: e8 8f 49 00 00 call 1050d4 - 100745: 31 ff xor %edi,%edi - 100747: 83 c4 10 add $0x10,%esp - 10074a: be 05 00 00 00 mov $0x5,%esi - 10074f: 90 nop - 100750: 83 ec 0c sub $0xc,%esp - 100753: 8d 9f 48 3a 18 00 lea 0x183a48(%edi),%ebx - 100759: 53 push %ebx - 10075a: e8 f9 49 00 00 call 105158 - 10075f: 83 c4 10 add $0x10,%esp - 100762: 85 c0 test %eax,%eax - 100764: 75 0e jne 100774 - 100766: 81 c7 08 2c 00 00 add $0x2c08,%edi - 10076c: 4e dec %esi - 10076d: 79 e1 jns 100750 - 10076f: e9 63 ff ff ff jmp 1006d7 - 100774: 8d 87 48 64 18 00 lea 0x186448(%edi),%eax - 10077a: 51 push %ecx - 10077b: 50 push %eax - 10077c: 53 push %ebx - 10077d: 68 c8 54 10 00 push $0x1054c8 - 100782: e8 4d 49 00 00 call 1050d4 - 100787: 83 c4 10 add $0x10,%esp - 10078a: eb da jmp 100766 - 10078c: 85 db test %ebx,%ebx - 10078e: 0f 85 07 ff ff ff jne 10069b - 100794: e8 83 38 00 00 call 10401c - 100799: e9 39 ff ff ff jmp 1006d7 - 10079e: 89 f6 mov %esi,%esi - 1007a0: 3b 9d d8 af ff ff cmp 0xffffafd8(%ebp),%ebx - 1007a6: be 01 00 00 00 mov $0x1,%esi - 1007ab: 7d 27 jge 1007d4 - 1007ad: 8d 9d dc b1 ff ff lea 0xffffb1dc(%ebp),%ebx - 1007b3: 90 nop - 1007b4: 83 ec 08 sub $0x8,%esp - 1007b7: 53 push %ebx - 1007b8: 68 bd 51 10 00 push $0x1051bd - 1007bd: 46 inc %esi - 1007be: e8 11 49 00 00 call 1050d4 - 1007c3: 81 c3 00 02 00 00 add $0x200,%ebx - 1007c9: 83 c4 10 add $0x10,%esp - 1007cc: 3b b5 d8 af ff ff cmp 0xffffafd8(%ebp),%esi - 1007d2: 7c e0 jl 1007b4 - 1007d4: 83 ec 0c sub $0xc,%esp - 1007d7: 68 f8 5a 10 00 push $0x105af8 - 1007dc: e9 ee fe ff ff jmp 1006cf - 1007e1: 00 00 add %al,(%eax) - ... - -001007e4 : - * reboot() - * - */ -static void reboot(void) -{ - 1007e4: 55 push %ebp - 1007e5: 89 e5 mov %esp,%ebp - 1007e7: 53 push %ebx - 1007e8: 50 push %eax - unsigned temp; - - disable(); - 1007e9: e8 da 44 00 00 call 104cc8 - - /** - * flush the keyboard controller - */ - do - { - temp = inportb(0x64); - 1007ee: 83 ec 0c sub $0xc,%esp - 1007f1: 6a 64 push $0x64 - 1007f3: e8 1c 48 00 00 call 105014 - if((temp & 0x01) != 0) - 1007f8: 83 c4 10 add $0x10,%esp - 1007fb: a8 01 test $0x1,%al - 1007fd: 89 c3 mov %eax,%ebx - 1007ff: 75 19 jne 10081a - { - (void)inportb(0x60); - continue; - } - } while((temp & 0x02) != 0); - 100801: 83 e3 02 and $0x2,%ebx - 100804: 75 e8 jne 1007ee - - /** - * now pulse the cpu reset line - */ - outportb(0x64, 0xFE); - 100806: 83 ec 08 sub $0x8,%esp - 100809: 68 fe 00 00 00 push $0xfe - 10080e: 6a 64 push $0x64 - 100810: e8 9f 48 00 00 call 1050b4 - - /** - * if that didn't work, just halt - */ - while(1); - 100815: 83 c4 10 add $0x10,%esp - 100818: eb fe jmp 100818 - 10081a: 83 ec 0c sub $0xc,%esp - 10081d: 6a 60 push $0x60 - 10081f: e8 f0 47 00 00 call 105014 - 100824: 83 c4 10 add $0x10,%esp - 100827: eb d8 jmp 100801 - 100829: 8d 76 00 lea 0x0(%esi),%esi - -0010082c <_write_kb>: -} - -/** - * XXX - * - * I'm not even sure if we need the following functions yet, - * however they are here just in case. Leave them alone. - */ - -/** - * _write_kb() - * - */ -static void _write_kb(unsigned adr, unsigned d) -{ - 10082c: 55 push %ebp - 10082d: 89 e5 mov %esp,%ebp - 10082f: 57 push %edi - 100830: 56 push %esi - 100831: 53 push %ebx - 100832: 83 ec 0c sub $0xc,%esp - 100835: 8b 7d 08 mov 0x8(%ebp),%edi - 100838: 8b 75 0c mov 0xc(%ebp),%esi - unsigned long t; - unsigned s; - - for(t = 5000000L; t != 0; t--) - 10083b: bb 40 4b 4c 00 mov $0x4c4b40,%ebx - { - s = inportb(0x64); - 100840: 83 ec 0c sub $0xc,%esp - 100843: 6a 64 push $0x64 - 100845: e8 ca 47 00 00 call 105014 - - /** - * loop until 8042 input buffer is empty - */ - if((s & 0x02) == 0) - 10084a: 83 c4 10 add $0x10,%esp - 10084d: a8 02 test $0x2,%al - 10084f: 74 0b je 10085c <_write_kb+0x30> - 100851: 4b dec %ebx - 100852: 75 ec jne 100840 <_write_kb+0x14> - break; - } - - if(t != 0) - outportb(adr, d); -} - 100854: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 100857: 5b pop %ebx - 100858: 5e pop %esi - 100859: 5f pop %edi - 10085a: c9 leave - 10085b: c3 ret - 10085c: 85 db test %ebx,%ebx - 10085e: 74 f4 je 100854 <_write_kb+0x28> - 100860: 89 75 0c mov %esi,0xc(%ebp) - 100863: 89 7d 08 mov %edi,0x8(%ebp) - 100866: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 100869: 5b pop %ebx - 10086a: 5e pop %esi - 10086b: 5f pop %edi - 10086c: c9 leave - 10086d: e9 42 48 00 00 jmp 1050b4 - 100872: 89 f6 mov %esi,%esi - -00100874 <_translate_sc>: - -/** - * _kb_wait() - * - */ -static inline void _kb_wait(void) -{ - int i; - - for(i = 0; i < 0x1000000; i++) - if((inportb(0x64) & 0x02) == 0) - return; - - printk(0, "Keyboard timeout\n"); -} - -/** - * _kb_send() - * - */ -static inline void _kb_send(unsigned char c) -{ - _kb_wait(); - outportb(c, 0x64); -} - -/** - * _translate_sc() - * - * Translates a scancode from the keyboard - */ -unsigned _translate_sc(unsigned k) -{ - 100874: 55 push %ebp - 100875: 89 e5 mov %esp,%ebp - 100877: 83 ec 08 sub $0x8,%esp - 10087a: 8b 45 08 mov 0x8(%ebp),%eax - unsigned c; - static unsigned altk; - unsigned donefirst = 0; - - if(k == KEY_BKSPACE) - 10087d: 83 f8 0e cmp $0xe,%eax - 100880: 0f 84 f2 09 00 00 je 101278 <_translate_sc+0xa04> - { - if(numkeysbuffer - 1 < 0) - { - numkeysbuffer = 0; - return 0; - } - } - - switch(k) - 100886: 3d e0 00 00 00 cmp $0xe0,%eax - 10088b: 0f 87 d3 09 00 00 ja 101264 <_translate_sc+0x9f0> - 100891: ff 24 85 dc 54 10 00 jmp *0x1054dc(,%eax,4) - { - case 0xE0: - altk = 1; c = 0; donefirst = 1; break; - 100898: 31 d2 xor %edx,%edx - 10089a: c7 05 00 80 10 00 01 movl $0x1,0x108000 - 1008a1: 00 00 00 - case KEY_TILDA: /* ` or ~ */ - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 126 : 126; break; - case KEY_END: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 49; break; - case KEY_1: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 33 : 49; break; - case KEY_DOWN: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 50; break; - case KEY_2: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 64 : 50; break; - case KEY_PGDOWN: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 51; break; - case KEY_3: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 35 : 51; break; - case KEY_LEFT: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 52; break; - case KEY_4: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 36 : 52; break; - case KEYP_5: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 53; break; - case KEY_5: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 35 : 53; break; - case KEY_RIGHT: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 54; break; - case KEY_6: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 94 : 54; break; - case KEY_HOME: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 55; break; - case KEY_7: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 38 : 55; break; - case KEY_UP: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 56; break; - case KEYP_ASTERISK: c = 42; break; - case KEY_8: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 42 : 56; break; - case KEY_PGUP: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 57; break; - case KEY_9: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 40 : 57; break; - case KEY_INSERT: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 48; break; - case KEY_0: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 41 : 48; break; - case KEYP_MINUS: c = 45; break; - case KEY_MINUS: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 95 : 45; break; - case KEYP_PLUS: c = 43; break; - case KEY_PLUS: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 61 : 43; break; - case KEY_BKSLASH: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 124 : 92; break; - case KEY_Q: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 81 : 113; break; - case KEY_W: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 87 : 119; break; - case KEY_E: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 69 : 101; break; - case KEY_R: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 82 : 114; break; - case KEY_T: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 84 : 116; break; - case KEY_Y: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 89 : 121; break; - case KEY_U: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 85 : 117; break; - case KEY_I: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 73 : 105; break; - case KEY_O: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 79 : 111; break; - case KEY_P: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 80 : 112; break; - case KEY_LBRACKET: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 123 : 91; break; - case KEY_RBRACKET: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 125 : 93; break; - case KEY_ENTER: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 10 : 10; break; - case KEY_A: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 65 : 97; break; - case KEY_S: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 83 : 115; break; - case KEY_D: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 68 : 100; break; - case KEY_F: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 70 : 102; break; - case KEY_G: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 71 : 103; break; - case KEY_H: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 72 : 104; break; - case KEY_J: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 74 : 106; break; - case KEY_K: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 75 : 107; break; - case KEY_L: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 76 : 108; break; - case KEY_SEMICOLON: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 58 : 59; break; - case KEY_QUOTE: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 34 : 39; break; - case KEY_Z: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 90 : 122; break; - case KEY_X: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 88 : 120; break; - case KEY_C: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 67 : 99; break; - case KEY_V: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 86 : 118; break; - case KEY_B: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 66 : 98; break; - case KEY_N: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 78 : 110; break; - case KEY_M: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 77 : 109; break; - case KEY_COMMA: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 60 : 44; break; - case KEY_DEL: c = 0; if(keys[KEYP_NUMLCK] && altk == 0) c = 46; break; - case KEY_PERIOD: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 62 : 46; break; - case KEY_SLASH: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 63 : 47; break; - case KEY_SPACE: - c = (keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) ? 32 : 32; break; - case KEY_BKSPACE: c = '\b'; break; /* just for now */ - default: - c = 0; - } - - if(donefirst == 0) - altk = 0; - - if(keys[KEY_CAPS]) - 1008a4: a1 28 84 10 00 mov 0x108428,%eax - 1008a9: 85 c0 test %eax,%eax - 1008ab: 74 23 je 1008d0 <_translate_sc+0x5c> - { - if(keys[KEY_LSHIFT] || keys[KEY_RSHIFT]) - 1008ad: a1 e8 83 10 00 mov 0x1083e8,%eax - 1008b2: 85 c0 test %eax,%eax - 1008b4: 75 0d jne 1008c3 <_translate_sc+0x4f> - 1008b6: a1 18 84 10 00 mov 0x108418,%eax - 1008bb: 85 c0 test %eax,%eax - 1008bd: 0f 84 bd 00 00 00 je 100980 <_translate_sc+0x10c> - { - if(c >= 'A' && c <= 'Z') - 1008c3: 8d 42 bf lea 0xffffffbf(%edx),%eax - 1008c6: 83 f8 19 cmp $0x19,%eax - 1008c9: 77 05 ja 1008d0 <_translate_sc+0x5c> - c += 32; - 1008cb: 83 c2 20 add $0x20,%edx - 1008ce: 89 f6 mov %esi,%esi - } - else - { - if(c >= 'a' && c <= 'z') - c -= 32; - } - } - - /** - * Simple shell for now - */ - if(c != 0 && c != '\n' && c != '\b') - 1008d0: 85 d2 test %edx,%edx - 1008d2: 74 38 je 10090c <_translate_sc+0x98> - 1008d4: 83 fa 0a cmp $0xa,%edx - 1008d7: 74 63 je 10093c <_translate_sc+0xc8> - 1008d9: 83 fa 08 cmp $0x8,%edx - 1008dc: 74 2e je 10090c <_translate_sc+0x98> - { - if((numkeysbuffer - 1) == KBD_BUF_SIZE) - 1008de: a1 40 85 10 00 mov 0x108540,%eax - 1008e3: 83 f8 41 cmp $0x41,%eax - 1008e6: 74 10 je 1008f8 <_translate_sc+0x84> - { - numkeysbuffer = 0; - szInBuf[0] = '\0'; - - szInBuf[numkeysbuffer] = c; - numkeysbuffer++; - } - else - { - szInBuf[numkeysbuffer] = c; - 1008e8: 88 90 60 85 10 00 mov %dl,0x108560(%eax) - numkeysbuffer++; - 1008ee: 40 inc %eax - 1008ef: a3 40 85 10 00 mov %eax,0x108540 - } - } - else if(c == '\n') - { - printf("\n"); - /** - * Make it a real string - */ - szInBuf[numkeysbuffer] = '\0'; - - /** - * Process command - */ - processCommand(&szInBuf[0], numkeysbuffer - 1); - - /** - * Clear buffer - */ - numkeysbuffer = 0; - szInBuf[0] = '\0'; - - /** - * Print "line" - */ - printf("$ "); - - c = 0; - } - else if(c == '\b') - { - szInBuf[numkeysbuffer] = '\0'; - numkeysbuffer--; - printf("\b \b"); - - c = 0; - } - - return c; - 1008f4: 89 d0 mov %edx,%eax -} - 1008f6: c9 leave - 1008f7: c3 ret - 1008f8: 88 15 60 85 10 00 mov %dl,0x108560 - 1008fe: c7 05 40 85 10 00 01 movl $0x1,0x108540 - 100905: 00 00 00 - 100908: eb ea jmp 1008f4 <_translate_sc+0x80> - 10090a: 89 f6 mov %esi,%esi - 10090c: 83 fa 0a cmp $0xa,%edx - 10090f: 74 2b je 10093c <_translate_sc+0xc8> - 100911: 83 fa 08 cmp $0x8,%edx - 100914: 75 de jne 1008f4 <_translate_sc+0x80> - 100916: a1 40 85 10 00 mov 0x108540,%eax - 10091b: c6 80 60 85 10 00 00 movb $0x0,0x108560(%eax) - 100922: 83 ec 0c sub $0xc,%esp - 100925: 48 dec %eax - 100926: a3 40 85 10 00 mov %eax,0x108540 - 10092b: 68 d2 54 10 00 push $0x1054d2 - 100930: e8 9f 47 00 00 call 1050d4 - 100935: 31 d2 xor %edx,%edx - 100937: 83 c4 10 add $0x10,%esp - 10093a: eb b8 jmp 1008f4 <_translate_sc+0x80> - 10093c: 83 ec 0c sub $0xc,%esp - 10093f: 68 f8 5a 10 00 push $0x105af8 - 100944: e8 8b 47 00 00 call 1050d4 - 100949: a1 40 85 10 00 mov 0x108540,%eax - 10094e: 5a pop %edx - 10094f: 59 pop %ecx - 100950: c6 80 60 85 10 00 00 movb $0x0,0x108560(%eax) - 100957: 48 dec %eax - 100958: 50 push %eax - 100959: 68 60 85 10 00 push $0x108560 - 10095e: e8 e9 fc ff ff call 10064c - 100963: c7 05 40 85 10 00 00 movl $0x0,0x108540 - 10096a: 00 00 00 - 10096d: c6 05 60 85 10 00 00 movb $0x0,0x108560 - 100974: c7 04 24 d6 54 10 00 movl $0x1054d6,(%esp,1) - 10097b: eb b3 jmp 100930 <_translate_sc+0xbc> - 10097d: 8d 76 00 lea 0x0(%esi),%esi - 100980: 8d 42 9f lea 0xffffff9f(%edx),%eax - 100983: 83 f8 19 cmp $0x19,%eax - 100986: 0f 87 44 ff ff ff ja 1008d0 <_translate_sc+0x5c> - 10098c: 83 ea 20 sub $0x20,%edx - 10098f: e9 3c ff ff ff jmp 1008d0 <_translate_sc+0x5c> - 100994: a1 e8 83 10 00 mov 0x1083e8,%eax - 100999: 85 c0 test %eax,%eax - 10099b: 75 09 jne 1009a6 <_translate_sc+0x132> - 10099d: a1 18 84 10 00 mov 0x108418,%eax - 1009a2: 85 c0 test %eax,%eax - 1009a4: 74 15 je 1009bb <_translate_sc+0x147> - 1009a6: ba 21 00 00 00 mov $0x21,%edx - 1009ab: 90 nop - 1009ac: c7 05 00 80 10 00 00 movl $0x0,0x108000 - 1009b3: 00 00 00 - 1009b6: e9 e9 fe ff ff jmp 1008a4 <_translate_sc+0x30> - 1009bb: ba 31 00 00 00 mov $0x31,%edx - 1009c0: eb ea jmp 1009ac <_translate_sc+0x138> - 1009c2: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 1009c8: 85 d2 test %edx,%edx - 1009ca: 75 09 jne 1009d5 <_translate_sc+0x161> - 1009cc: a1 18 84 10 00 mov 0x108418,%eax - 1009d1: 85 c0 test %eax,%eax - 1009d3: 74 07 je 1009dc <_translate_sc+0x168> - 1009d5: ba 40 00 00 00 mov $0x40,%edx - 1009da: eb d0 jmp 1009ac <_translate_sc+0x138> - 1009dc: ba 32 00 00 00 mov $0x32,%edx - 1009e1: eb c9 jmp 1009ac <_translate_sc+0x138> - 1009e3: a1 e8 83 10 00 mov 0x1083e8,%eax - 1009e8: 85 c0 test %eax,%eax - 1009ea: 75 09 jne 1009f5 <_translate_sc+0x181> - 1009ec: a1 18 84 10 00 mov 0x108418,%eax - 1009f1: 85 c0 test %eax,%eax - 1009f3: 74 07 je 1009fc <_translate_sc+0x188> - 1009f5: ba 23 00 00 00 mov $0x23,%edx - 1009fa: eb b0 jmp 1009ac <_translate_sc+0x138> - 1009fc: ba 33 00 00 00 mov $0x33,%edx - 100a01: eb a9 jmp 1009ac <_translate_sc+0x138> - 100a03: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100a09: 85 d2 test %edx,%edx - 100a0b: 75 09 jne 100a16 <_translate_sc+0x1a2> - 100a0d: a1 18 84 10 00 mov 0x108418,%eax - 100a12: 85 c0 test %eax,%eax - 100a14: 74 07 je 100a1d <_translate_sc+0x1a9> - 100a16: ba 24 00 00 00 mov $0x24,%edx - 100a1b: eb 8f jmp 1009ac <_translate_sc+0x138> - 100a1d: ba 34 00 00 00 mov $0x34,%edx - 100a22: eb 88 jmp 1009ac <_translate_sc+0x138> - 100a24: a1 e8 83 10 00 mov 0x1083e8,%eax - 100a29: 85 c0 test %eax,%eax - 100a2b: 75 09 jne 100a36 <_translate_sc+0x1c2> - 100a2d: a1 18 84 10 00 mov 0x108418,%eax - 100a32: 85 c0 test %eax,%eax - 100a34: 74 0a je 100a40 <_translate_sc+0x1cc> - 100a36: ba 23 00 00 00 mov $0x23,%edx - 100a3b: e9 6c ff ff ff jmp 1009ac <_translate_sc+0x138> - 100a40: ba 35 00 00 00 mov $0x35,%edx - 100a45: e9 62 ff ff ff jmp 1009ac <_translate_sc+0x138> - 100a4a: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100a50: 85 d2 test %edx,%edx - 100a52: 75 09 jne 100a5d <_translate_sc+0x1e9> - 100a54: a1 18 84 10 00 mov 0x108418,%eax - 100a59: 85 c0 test %eax,%eax - 100a5b: 74 0a je 100a67 <_translate_sc+0x1f3> - 100a5d: ba 5e 00 00 00 mov $0x5e,%edx - 100a62: e9 45 ff ff ff jmp 1009ac <_translate_sc+0x138> - 100a67: ba 36 00 00 00 mov $0x36,%edx - 100a6c: e9 3b ff ff ff jmp 1009ac <_translate_sc+0x138> - 100a71: a1 e8 83 10 00 mov 0x1083e8,%eax - 100a76: 85 c0 test %eax,%eax - 100a78: 75 09 jne 100a83 <_translate_sc+0x20f> - 100a7a: a1 18 84 10 00 mov 0x108418,%eax - 100a7f: 85 c0 test %eax,%eax - 100a81: 74 0a je 100a8d <_translate_sc+0x219> - 100a83: ba 26 00 00 00 mov $0x26,%edx - 100a88: e9 1f ff ff ff jmp 1009ac <_translate_sc+0x138> - 100a8d: ba 37 00 00 00 mov $0x37,%edx - 100a92: e9 15 ff ff ff jmp 1009ac <_translate_sc+0x138> - 100a97: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100a9d: 85 d2 test %edx,%edx - 100a9f: 75 09 jne 100aaa <_translate_sc+0x236> - 100aa1: a1 18 84 10 00 mov 0x108418,%eax - 100aa6: 85 c0 test %eax,%eax - 100aa8: 74 0a je 100ab4 <_translate_sc+0x240> - 100aaa: ba 2a 00 00 00 mov $0x2a,%edx - 100aaf: e9 f8 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100ab4: ba 38 00 00 00 mov $0x38,%edx - 100ab9: e9 ee fe ff ff jmp 1009ac <_translate_sc+0x138> - 100abe: a1 e8 83 10 00 mov 0x1083e8,%eax - 100ac3: 85 c0 test %eax,%eax - 100ac5: 75 09 jne 100ad0 <_translate_sc+0x25c> - 100ac7: a1 18 84 10 00 mov 0x108418,%eax - 100acc: 85 c0 test %eax,%eax - 100ace: 74 0a je 100ada <_translate_sc+0x266> - 100ad0: ba 28 00 00 00 mov $0x28,%edx - 100ad5: e9 d2 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100ada: ba 39 00 00 00 mov $0x39,%edx - 100adf: e9 c8 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100ae4: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100aea: 85 d2 test %edx,%edx - 100aec: 75 09 jne 100af7 <_translate_sc+0x283> - 100aee: a1 18 84 10 00 mov 0x108418,%eax - 100af3: 85 c0 test %eax,%eax - 100af5: 74 0a je 100b01 <_translate_sc+0x28d> - 100af7: ba 29 00 00 00 mov $0x29,%edx - 100afc: e9 ab fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b01: ba 30 00 00 00 mov $0x30,%edx - 100b06: e9 a1 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b0b: a1 e8 83 10 00 mov 0x1083e8,%eax - 100b10: 85 c0 test %eax,%eax - 100b12: 75 09 jne 100b1d <_translate_sc+0x2a9> - 100b14: a1 18 84 10 00 mov 0x108418,%eax - 100b19: 85 c0 test %eax,%eax - 100b1b: 74 0a je 100b27 <_translate_sc+0x2b3> - 100b1d: ba 5f 00 00 00 mov $0x5f,%edx - 100b22: e9 85 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b27: ba 2d 00 00 00 mov $0x2d,%edx - 100b2c: e9 7b fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b31: a1 e8 83 10 00 mov 0x1083e8,%eax - 100b36: 85 c0 test %eax,%eax - 100b38: 75 09 jne 100b43 <_translate_sc+0x2cf> - 100b3a: a1 18 84 10 00 mov 0x108418,%eax - 100b3f: 85 c0 test %eax,%eax - 100b41: 74 0a je 100b4d <_translate_sc+0x2d9> - 100b43: ba 3d 00 00 00 mov $0x3d,%edx - 100b48: e9 5f fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b4d: ba 2b 00 00 00 mov $0x2b,%edx - 100b52: e9 55 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b57: ba 08 00 00 00 mov $0x8,%edx - 100b5c: e9 4b fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b61: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100b67: 85 d2 test %edx,%edx - 100b69: 75 09 jne 100b74 <_translate_sc+0x300> - 100b6b: a1 18 84 10 00 mov 0x108418,%eax - 100b70: 85 c0 test %eax,%eax - 100b72: 74 0a je 100b7e <_translate_sc+0x30a> - 100b74: ba 51 00 00 00 mov $0x51,%edx - 100b79: e9 2e fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b7e: ba 71 00 00 00 mov $0x71,%edx - 100b83: e9 24 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100b88: a1 e8 83 10 00 mov 0x1083e8,%eax - 100b8d: 85 c0 test %eax,%eax - 100b8f: 75 09 jne 100b9a <_translate_sc+0x326> - 100b91: a1 18 84 10 00 mov 0x108418,%eax - 100b96: 85 c0 test %eax,%eax - 100b98: 74 0a je 100ba4 <_translate_sc+0x330> - 100b9a: ba 57 00 00 00 mov $0x57,%edx - 100b9f: e9 08 fe ff ff jmp 1009ac <_translate_sc+0x138> - 100ba4: ba 77 00 00 00 mov $0x77,%edx - 100ba9: e9 fe fd ff ff jmp 1009ac <_translate_sc+0x138> - 100bae: a1 e8 83 10 00 mov 0x1083e8,%eax - 100bb3: 85 c0 test %eax,%eax - 100bb5: 75 09 jne 100bc0 <_translate_sc+0x34c> - 100bb7: a1 18 84 10 00 mov 0x108418,%eax - 100bbc: 85 c0 test %eax,%eax - 100bbe: 74 0a je 100bca <_translate_sc+0x356> - 100bc0: ba 45 00 00 00 mov $0x45,%edx - 100bc5: e9 e2 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100bca: ba 65 00 00 00 mov $0x65,%edx - 100bcf: e9 d8 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100bd4: a1 e8 83 10 00 mov 0x1083e8,%eax - 100bd9: 85 c0 test %eax,%eax - 100bdb: 75 0a jne 100be7 <_translate_sc+0x373> - 100bdd: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100be3: 85 c9 test %ecx,%ecx - 100be5: 74 0a je 100bf1 <_translate_sc+0x37d> - 100be7: ba 52 00 00 00 mov $0x52,%edx - 100bec: e9 bb fd ff ff jmp 1009ac <_translate_sc+0x138> - 100bf1: ba 72 00 00 00 mov $0x72,%edx - 100bf6: e9 b1 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100bfb: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100c01: 85 d2 test %edx,%edx - 100c03: 75 09 jne 100c0e <_translate_sc+0x39a> - 100c05: a1 18 84 10 00 mov 0x108418,%eax - 100c0a: 85 c0 test %eax,%eax - 100c0c: 74 0a je 100c18 <_translate_sc+0x3a4> - 100c0e: ba 54 00 00 00 mov $0x54,%edx - 100c13: e9 94 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c18: ba 74 00 00 00 mov $0x74,%edx - 100c1d: e9 8a fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c22: a1 e8 83 10 00 mov 0x1083e8,%eax - 100c27: 85 c0 test %eax,%eax - 100c29: 75 09 jne 100c34 <_translate_sc+0x3c0> - 100c2b: a1 18 84 10 00 mov 0x108418,%eax - 100c30: 85 c0 test %eax,%eax - 100c32: 74 0a je 100c3e <_translate_sc+0x3ca> - 100c34: ba 59 00 00 00 mov $0x59,%edx - 100c39: e9 6e fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c3e: ba 79 00 00 00 mov $0x79,%edx - 100c43: e9 64 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c48: a1 e8 83 10 00 mov 0x1083e8,%eax - 100c4d: 85 c0 test %eax,%eax - 100c4f: 75 09 jne 100c5a <_translate_sc+0x3e6> - 100c51: a1 18 84 10 00 mov 0x108418,%eax - 100c56: 85 c0 test %eax,%eax - 100c58: 74 0a je 100c64 <_translate_sc+0x3f0> - 100c5a: ba 55 00 00 00 mov $0x55,%edx - 100c5f: e9 48 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c64: ba 75 00 00 00 mov $0x75,%edx - 100c69: e9 3e fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c6e: a1 e8 83 10 00 mov 0x1083e8,%eax - 100c73: 85 c0 test %eax,%eax - 100c75: 75 0a jne 100c81 <_translate_sc+0x40d> - 100c77: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100c7d: 85 c9 test %ecx,%ecx - 100c7f: 74 0a je 100c8b <_translate_sc+0x417> - 100c81: ba 49 00 00 00 mov $0x49,%edx - 100c86: e9 21 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c8b: ba 69 00 00 00 mov $0x69,%edx - 100c90: e9 17 fd ff ff jmp 1009ac <_translate_sc+0x138> - 100c95: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100c9b: 85 d2 test %edx,%edx - 100c9d: 75 09 jne 100ca8 <_translate_sc+0x434> - 100c9f: a1 18 84 10 00 mov 0x108418,%eax - 100ca4: 85 c0 test %eax,%eax - 100ca6: 74 0a je 100cb2 <_translate_sc+0x43e> - 100ca8: ba 4f 00 00 00 mov $0x4f,%edx - 100cad: e9 fa fc ff ff jmp 1009ac <_translate_sc+0x138> - 100cb2: ba 6f 00 00 00 mov $0x6f,%edx - 100cb7: e9 f0 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100cbc: a1 e8 83 10 00 mov 0x1083e8,%eax - 100cc1: 85 c0 test %eax,%eax - 100cc3: 75 09 jne 100cce <_translate_sc+0x45a> - 100cc5: a1 18 84 10 00 mov 0x108418,%eax - 100cca: 85 c0 test %eax,%eax - 100ccc: 74 0a je 100cd8 <_translate_sc+0x464> - 100cce: ba 50 00 00 00 mov $0x50,%edx - 100cd3: e9 d4 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100cd8: ba 70 00 00 00 mov $0x70,%edx - 100cdd: e9 ca fc ff ff jmp 1009ac <_translate_sc+0x138> - 100ce2: a1 e8 83 10 00 mov 0x1083e8,%eax - 100ce7: 85 c0 test %eax,%eax - 100ce9: 75 09 jne 100cf4 <_translate_sc+0x480> - 100ceb: a1 18 84 10 00 mov 0x108418,%eax - 100cf0: 85 c0 test %eax,%eax - 100cf2: 74 0a je 100cfe <_translate_sc+0x48a> - 100cf4: ba 7b 00 00 00 mov $0x7b,%edx - 100cf9: e9 ae fc ff ff jmp 1009ac <_translate_sc+0x138> - 100cfe: ba 5b 00 00 00 mov $0x5b,%edx - 100d03: e9 a4 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d08: a1 e8 83 10 00 mov 0x1083e8,%eax - 100d0d: 85 c0 test %eax,%eax - 100d0f: 75 0a jne 100d1b <_translate_sc+0x4a7> - 100d11: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100d17: 85 c9 test %ecx,%ecx - 100d19: 74 0a je 100d25 <_translate_sc+0x4b1> - 100d1b: ba 7d 00 00 00 mov $0x7d,%edx - 100d20: e9 87 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d25: ba 5d 00 00 00 mov $0x5d,%edx - 100d2a: e9 7d fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d2f: ba 0a 00 00 00 mov $0xa,%edx - 100d34: e9 73 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d39: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100d3f: 85 d2 test %edx,%edx - 100d41: 75 09 jne 100d4c <_translate_sc+0x4d8> - 100d43: a1 18 84 10 00 mov 0x108418,%eax - 100d48: 85 c0 test %eax,%eax - 100d4a: 74 0a je 100d56 <_translate_sc+0x4e2> - 100d4c: ba 41 00 00 00 mov $0x41,%edx - 100d51: e9 56 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d56: ba 61 00 00 00 mov $0x61,%edx - 100d5b: e9 4c fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d60: a1 e8 83 10 00 mov 0x1083e8,%eax - 100d65: 85 c0 test %eax,%eax - 100d67: 75 09 jne 100d72 <_translate_sc+0x4fe> - 100d69: a1 18 84 10 00 mov 0x108418,%eax - 100d6e: 85 c0 test %eax,%eax - 100d70: 74 0a je 100d7c <_translate_sc+0x508> - 100d72: ba 53 00 00 00 mov $0x53,%edx - 100d77: e9 30 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d7c: ba 73 00 00 00 mov $0x73,%edx - 100d81: e9 26 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100d86: a1 e8 83 10 00 mov 0x1083e8,%eax - 100d8b: 85 c0 test %eax,%eax - 100d8d: 75 09 jne 100d98 <_translate_sc+0x524> - 100d8f: a1 18 84 10 00 mov 0x108418,%eax - 100d94: 85 c0 test %eax,%eax - 100d96: 74 0a je 100da2 <_translate_sc+0x52e> - 100d98: ba 44 00 00 00 mov $0x44,%edx - 100d9d: e9 0a fc ff ff jmp 1009ac <_translate_sc+0x138> - 100da2: ba 64 00 00 00 mov $0x64,%edx - 100da7: e9 00 fc ff ff jmp 1009ac <_translate_sc+0x138> - 100dac: a1 e8 83 10 00 mov 0x1083e8,%eax - 100db1: 85 c0 test %eax,%eax - 100db3: 75 0a jne 100dbf <_translate_sc+0x54b> - 100db5: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100dbb: 85 c9 test %ecx,%ecx - 100dbd: 74 0a je 100dc9 <_translate_sc+0x555> - 100dbf: ba 46 00 00 00 mov $0x46,%edx - 100dc4: e9 e3 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100dc9: ba 66 00 00 00 mov $0x66,%edx - 100dce: e9 d9 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100dd3: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100dd9: 85 d2 test %edx,%edx - 100ddb: 75 09 jne 100de6 <_translate_sc+0x572> - 100ddd: a1 18 84 10 00 mov 0x108418,%eax - 100de2: 85 c0 test %eax,%eax - 100de4: 74 0a je 100df0 <_translate_sc+0x57c> - 100de6: ba 47 00 00 00 mov $0x47,%edx - 100deb: e9 bc fb ff ff jmp 1009ac <_translate_sc+0x138> - 100df0: ba 67 00 00 00 mov $0x67,%edx - 100df5: e9 b2 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100dfa: a1 e8 83 10 00 mov 0x1083e8,%eax - 100dff: 85 c0 test %eax,%eax - 100e01: 75 09 jne 100e0c <_translate_sc+0x598> - 100e03: a1 18 84 10 00 mov 0x108418,%eax - 100e08: 85 c0 test %eax,%eax - 100e0a: 74 0a je 100e16 <_translate_sc+0x5a2> - 100e0c: ba 48 00 00 00 mov $0x48,%edx - 100e11: e9 96 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e16: ba 68 00 00 00 mov $0x68,%edx - 100e1b: e9 8c fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e20: a1 e8 83 10 00 mov 0x1083e8,%eax - 100e25: 85 c0 test %eax,%eax - 100e27: 75 09 jne 100e32 <_translate_sc+0x5be> - 100e29: a1 18 84 10 00 mov 0x108418,%eax - 100e2e: 85 c0 test %eax,%eax - 100e30: 74 0a je 100e3c <_translate_sc+0x5c8> - 100e32: ba 4a 00 00 00 mov $0x4a,%edx - 100e37: e9 70 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e3c: ba 6a 00 00 00 mov $0x6a,%edx - 100e41: e9 66 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e46: a1 e8 83 10 00 mov 0x1083e8,%eax - 100e4b: 85 c0 test %eax,%eax - 100e4d: 75 0a jne 100e59 <_translate_sc+0x5e5> - 100e4f: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100e55: 85 c9 test %ecx,%ecx - 100e57: 74 0a je 100e63 <_translate_sc+0x5ef> - 100e59: ba 4b 00 00 00 mov $0x4b,%edx - 100e5e: e9 49 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e63: ba 6b 00 00 00 mov $0x6b,%edx - 100e68: e9 3f fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e6d: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100e73: 85 d2 test %edx,%edx - 100e75: 75 09 jne 100e80 <_translate_sc+0x60c> - 100e77: a1 18 84 10 00 mov 0x108418,%eax - 100e7c: 85 c0 test %eax,%eax - 100e7e: 74 0a je 100e8a <_translate_sc+0x616> - 100e80: ba 4c 00 00 00 mov $0x4c,%edx - 100e85: e9 22 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e8a: ba 6c 00 00 00 mov $0x6c,%edx - 100e8f: e9 18 fb ff ff jmp 1009ac <_translate_sc+0x138> - 100e94: a1 e8 83 10 00 mov 0x1083e8,%eax - 100e99: 85 c0 test %eax,%eax - 100e9b: 75 09 jne 100ea6 <_translate_sc+0x632> - 100e9d: a1 18 84 10 00 mov 0x108418,%eax - 100ea2: 85 c0 test %eax,%eax - 100ea4: 74 0a je 100eb0 <_translate_sc+0x63c> - 100ea6: ba 3a 00 00 00 mov $0x3a,%edx - 100eab: e9 fc fa ff ff jmp 1009ac <_translate_sc+0x138> - 100eb0: ba 3b 00 00 00 mov $0x3b,%edx - 100eb5: e9 f2 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100eba: a1 e8 83 10 00 mov 0x1083e8,%eax - 100ebf: 85 c0 test %eax,%eax - 100ec1: 75 09 jne 100ecc <_translate_sc+0x658> - 100ec3: a1 18 84 10 00 mov 0x108418,%eax - 100ec8: 85 c0 test %eax,%eax - 100eca: 74 0a je 100ed6 <_translate_sc+0x662> - 100ecc: ba 22 00 00 00 mov $0x22,%edx - 100ed1: e9 d6 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100ed6: ba 27 00 00 00 mov $0x27,%edx - 100edb: e9 cc fa ff ff jmp 1009ac <_translate_sc+0x138> - 100ee0: ba 7e 00 00 00 mov $0x7e,%edx - 100ee5: e9 c2 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100eea: a1 e8 83 10 00 mov 0x1083e8,%eax - 100eef: 85 c0 test %eax,%eax - 100ef1: 75 0a jne 100efd <_translate_sc+0x689> - 100ef3: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100ef9: 85 c9 test %ecx,%ecx - 100efb: 74 0a je 100f07 <_translate_sc+0x693> - 100efd: ba 7c 00 00 00 mov $0x7c,%edx - 100f02: e9 a5 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f07: ba 5c 00 00 00 mov $0x5c,%edx - 100f0c: e9 9b fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f11: a1 e8 83 10 00 mov 0x1083e8,%eax - 100f16: 85 c0 test %eax,%eax - 100f18: 75 0a jne 100f24 <_translate_sc+0x6b0> - 100f1a: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100f20: 85 c9 test %ecx,%ecx - 100f22: 74 0a je 100f2e <_translate_sc+0x6ba> - 100f24: ba 5a 00 00 00 mov $0x5a,%edx - 100f29: e9 7e fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f2e: ba 7a 00 00 00 mov $0x7a,%edx - 100f33: e9 74 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f38: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100f3e: 85 d2 test %edx,%edx - 100f40: 75 09 jne 100f4b <_translate_sc+0x6d7> - 100f42: a1 18 84 10 00 mov 0x108418,%eax - 100f47: 85 c0 test %eax,%eax - 100f49: 74 0a je 100f55 <_translate_sc+0x6e1> - 100f4b: ba 58 00 00 00 mov $0x58,%edx - 100f50: e9 57 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f55: ba 78 00 00 00 mov $0x78,%edx - 100f5a: e9 4d fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f5f: a1 e8 83 10 00 mov 0x1083e8,%eax - 100f64: 85 c0 test %eax,%eax - 100f66: 75 09 jne 100f71 <_translate_sc+0x6fd> - 100f68: a1 18 84 10 00 mov 0x108418,%eax - 100f6d: 85 c0 test %eax,%eax - 100f6f: 74 0a je 100f7b <_translate_sc+0x707> - 100f71: ba 43 00 00 00 mov $0x43,%edx - 100f76: e9 31 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f7b: ba 63 00 00 00 mov $0x63,%edx - 100f80: e9 27 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100f85: a1 e8 83 10 00 mov 0x1083e8,%eax - 100f8a: 85 c0 test %eax,%eax - 100f8c: 75 09 jne 100f97 <_translate_sc+0x723> - 100f8e: a1 18 84 10 00 mov 0x108418,%eax - 100f93: 85 c0 test %eax,%eax - 100f95: 74 0a je 100fa1 <_translate_sc+0x72d> - 100f97: ba 56 00 00 00 mov $0x56,%edx - 100f9c: e9 0b fa ff ff jmp 1009ac <_translate_sc+0x138> - 100fa1: ba 76 00 00 00 mov $0x76,%edx - 100fa6: e9 01 fa ff ff jmp 1009ac <_translate_sc+0x138> - 100fab: a1 e8 83 10 00 mov 0x1083e8,%eax - 100fb0: 85 c0 test %eax,%eax - 100fb2: 75 0a jne 100fbe <_translate_sc+0x74a> - 100fb4: 8b 0d 18 84 10 00 mov 0x108418,%ecx - 100fba: 85 c9 test %ecx,%ecx - 100fbc: 74 0a je 100fc8 <_translate_sc+0x754> - 100fbe: ba 42 00 00 00 mov $0x42,%edx - 100fc3: e9 e4 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 100fc8: ba 62 00 00 00 mov $0x62,%edx - 100fcd: e9 da f9 ff ff jmp 1009ac <_translate_sc+0x138> - 100fd2: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 100fd8: 85 d2 test %edx,%edx - 100fda: 75 09 jne 100fe5 <_translate_sc+0x771> - 100fdc: a1 18 84 10 00 mov 0x108418,%eax - 100fe1: 85 c0 test %eax,%eax - 100fe3: 74 0a je 100fef <_translate_sc+0x77b> - 100fe5: ba 4e 00 00 00 mov $0x4e,%edx - 100fea: e9 bd f9 ff ff jmp 1009ac <_translate_sc+0x138> - 100fef: ba 6e 00 00 00 mov $0x6e,%edx - 100ff4: e9 b3 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 100ff9: a1 e8 83 10 00 mov 0x1083e8,%eax - 100ffe: 85 c0 test %eax,%eax - 101000: 75 09 jne 10100b <_translate_sc+0x797> - 101002: a1 18 84 10 00 mov 0x108418,%eax - 101007: 85 c0 test %eax,%eax - 101009: 74 0a je 101015 <_translate_sc+0x7a1> - 10100b: ba 4d 00 00 00 mov $0x4d,%edx - 101010: e9 97 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 101015: ba 6d 00 00 00 mov $0x6d,%edx - 10101a: e9 8d f9 ff ff jmp 1009ac <_translate_sc+0x138> - 10101f: a1 e8 83 10 00 mov 0x1083e8,%eax - 101024: 85 c0 test %eax,%eax - 101026: 75 09 jne 101031 <_translate_sc+0x7bd> - 101028: a1 18 84 10 00 mov 0x108418,%eax - 10102d: 85 c0 test %eax,%eax - 10102f: 74 0a je 10103b <_translate_sc+0x7c7> - 101031: ba 3c 00 00 00 mov $0x3c,%edx - 101036: e9 71 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 10103b: ba 2c 00 00 00 mov $0x2c,%edx - 101040: e9 67 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 101045: 8b 15 e8 83 10 00 mov 0x1083e8,%edx - 10104b: 85 d2 test %edx,%edx - 10104d: 75 09 jne 101058 <_translate_sc+0x7e4> - 10104f: a1 18 84 10 00 mov 0x108418,%eax - 101054: 85 c0 test %eax,%eax - 101056: 74 0a je 101062 <_translate_sc+0x7ee> - 101058: ba 3e 00 00 00 mov $0x3e,%edx - 10105d: e9 4a f9 ff ff jmp 1009ac <_translate_sc+0x138> - 101062: ba 2e 00 00 00 mov $0x2e,%edx - 101067: e9 40 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 10106c: a1 e8 83 10 00 mov 0x1083e8,%eax - 101071: 85 c0 test %eax,%eax - 101073: 75 09 jne 10107e <_translate_sc+0x80a> - 101075: a1 18 84 10 00 mov 0x108418,%eax - 10107a: 85 c0 test %eax,%eax - 10107c: 74 0a je 101088 <_translate_sc+0x814> - 10107e: ba 3f 00 00 00 mov $0x3f,%edx - 101083: e9 24 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 101088: ba 2f 00 00 00 mov $0x2f,%edx - 10108d: e9 1a f9 ff ff jmp 1009ac <_translate_sc+0x138> - 101092: ba 2a 00 00 00 mov $0x2a,%edx - 101097: e9 10 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 10109c: ba 20 00 00 00 mov $0x20,%edx - 1010a1: e9 06 f9 ff ff jmp 1009ac <_translate_sc+0x138> - 1010a6: a1 54 84 10 00 mov 0x108454,%eax - 1010ab: 31 d2 xor %edx,%edx - 1010ad: 85 c0 test %eax,%eax - 1010af: 0f 84 f7 f8 ff ff je 1009ac <_translate_sc+0x138> - 1010b5: a1 00 80 10 00 mov 0x108000,%eax - 1010ba: 85 c0 test %eax,%eax - 1010bc: 0f 85 ea f8 ff ff jne 1009ac <_translate_sc+0x138> - 1010c2: ba 37 00 00 00 mov $0x37,%edx - 1010c7: e9 e0 f8 ff ff jmp 1009ac <_translate_sc+0x138> - 1010cc: a1 54 84 10 00 mov 0x108454,%eax - 1010d1: 31 d2 xor %edx,%edx - 1010d3: 85 c0 test %eax,%eax - 1010d5: 0f 84 d1 f8 ff ff je 1009ac <_translate_sc+0x138> - 1010db: 8b 0d 00 80 10 00 mov 0x108000,%ecx - 1010e1: 85 c9 test %ecx,%ecx - 1010e3: 0f 85 c3 f8 ff ff jne 1009ac <_translate_sc+0x138> - 1010e9: ba 38 00 00 00 mov $0x38,%edx - 1010ee: e9 b9 f8 ff ff jmp 1009ac <_translate_sc+0x138> - 1010f3: a1 54 84 10 00 mov 0x108454,%eax - 1010f8: 31 d2 xor %edx,%edx - 1010fa: 85 c0 test %eax,%eax - 1010fc: 0f 84 aa f8 ff ff je 1009ac <_translate_sc+0x138> - 101102: a1 00 80 10 00 mov 0x108000,%eax - 101107: 85 c0 test %eax,%eax - 101109: 0f 85 9d f8 ff ff jne 1009ac <_translate_sc+0x138> - 10110f: ba 39 00 00 00 mov $0x39,%edx - 101114: e9 93 f8 ff ff jmp 1009ac <_translate_sc+0x138> - 101119: ba 2d 00 00 00 mov $0x2d,%edx - 10111e: e9 89 f8 ff ff jmp 1009ac <_translate_sc+0x138> - 101123: a1 54 84 10 00 mov 0x108454,%eax - 101128: 31 d2 xor %edx,%edx - 10112a: 85 c0 test %eax,%eax - 10112c: 0f 84 7a f8 ff ff je 1009ac <_translate_sc+0x138> - 101132: 8b 0d 00 80 10 00 mov 0x108000,%ecx - 101138: 85 c9 test %ecx,%ecx - 10113a: 0f 85 6c f8 ff ff jne 1009ac <_translate_sc+0x138> - 101140: ba 34 00 00 00 mov $0x34,%edx - 101145: e9 62 f8 ff ff jmp 1009ac <_translate_sc+0x138> - 10114a: a1 54 84 10 00 mov 0x108454,%eax - 10114f: 31 d2 xor %edx,%edx - 101151: 85 c0 test %eax,%eax - 101153: 0f 84 53 f8 ff ff je 1009ac <_translate_sc+0x138> - 101159: a1 00 80 10 00 mov 0x108000,%eax - 10115e: 85 c0 test %eax,%eax - 101160: 0f 85 46 f8 ff ff jne 1009ac <_translate_sc+0x138> - 101166: ba 35 00 00 00 mov $0x35,%edx - 10116b: e9 3c f8 ff ff jmp 1009ac <_translate_sc+0x138> - 101170: a1 54 84 10 00 mov 0x108454,%eax - 101175: 31 d2 xor %edx,%edx - 101177: 85 c0 test %eax,%eax - 101179: 0f 84 2d f8 ff ff je 1009ac <_translate_sc+0x138> - 10117f: 8b 0d 00 80 10 00 mov 0x108000,%ecx - 101185: 85 c9 test %ecx,%ecx - 101187: 0f 85 1f f8 ff ff jne 1009ac <_translate_sc+0x138> - 10118d: ba 36 00 00 00 mov $0x36,%edx - 101192: e9 15 f8 ff ff jmp 1009ac <_translate_sc+0x138> - 101197: ba 2b 00 00 00 mov $0x2b,%edx - 10119c: e9 0b f8 ff ff jmp 1009ac <_translate_sc+0x138> - 1011a1: a1 54 84 10 00 mov 0x108454,%eax - 1011a6: 31 d2 xor %edx,%edx - 1011a8: 85 c0 test %eax,%eax - 1011aa: 0f 84 fc f7 ff ff je 1009ac <_translate_sc+0x138> - 1011b0: a1 00 80 10 00 mov 0x108000,%eax - 1011b5: 85 c0 test %eax,%eax - 1011b7: 0f 85 ef f7 ff ff jne 1009ac <_translate_sc+0x138> - 1011bd: ba 31 00 00 00 mov $0x31,%edx - 1011c2: e9 e5 f7 ff ff jmp 1009ac <_translate_sc+0x138> - 1011c7: a1 54 84 10 00 mov 0x108454,%eax - 1011cc: 31 d2 xor %edx,%edx - 1011ce: 85 c0 test %eax,%eax - 1011d0: 0f 84 d6 f7 ff ff je 1009ac <_translate_sc+0x138> - 1011d6: 8b 0d 00 80 10 00 mov 0x108000,%ecx - 1011dc: 85 c9 test %ecx,%ecx - 1011de: 0f 85 c8 f7 ff ff jne 1009ac <_translate_sc+0x138> - 1011e4: ba 32 00 00 00 mov $0x32,%edx - 1011e9: e9 be f7 ff ff jmp 1009ac <_translate_sc+0x138> - 1011ee: a1 54 84 10 00 mov 0x108454,%eax - 1011f3: 31 d2 xor %edx,%edx - 1011f5: 85 c0 test %eax,%eax - 1011f7: 0f 84 af f7 ff ff je 1009ac <_translate_sc+0x138> - 1011fd: a1 00 80 10 00 mov 0x108000,%eax - 101202: 85 c0 test %eax,%eax - 101204: 0f 85 a2 f7 ff ff jne 1009ac <_translate_sc+0x138> - 10120a: ba 33 00 00 00 mov $0x33,%edx - 10120f: e9 98 f7 ff ff jmp 1009ac <_translate_sc+0x138> - 101214: a1 54 84 10 00 mov 0x108454,%eax - 101219: 31 d2 xor %edx,%edx - 10121b: 85 c0 test %eax,%eax - 10121d: 0f 84 89 f7 ff ff je 1009ac <_translate_sc+0x138> - 101223: 8b 0d 00 80 10 00 mov 0x108000,%ecx - 101229: 85 c9 test %ecx,%ecx - 10122b: 0f 85 7b f7 ff ff jne 1009ac <_translate_sc+0x138> - 101231: ba 30 00 00 00 mov $0x30,%edx - 101236: e9 71 f7 ff ff jmp 1009ac <_translate_sc+0x138> - 10123b: a1 54 84 10 00 mov 0x108454,%eax - 101240: 31 d2 xor %edx,%edx - 101242: 85 c0 test %eax,%eax - 101244: 0f 84 62 f7 ff ff je 1009ac <_translate_sc+0x138> - 10124a: 8b 0d 00 80 10 00 mov 0x108000,%ecx - 101250: 85 c9 test %ecx,%ecx - 101252: 0f 85 54 f7 ff ff jne 1009ac <_translate_sc+0x138> - 101258: ba 2e 00 00 00 mov $0x2e,%edx - 10125d: e9 4a f7 ff ff jmp 1009ac <_translate_sc+0x138> - 101262: 89 f6 mov %esi,%esi - 101264: 31 c0 xor %eax,%eax - 101266: 31 d2 xor %edx,%edx - 101268: 85 c0 test %eax,%eax - 10126a: 0f 85 34 f6 ff ff jne 1008a4 <_translate_sc+0x30> - 101270: e9 37 f7 ff ff jmp 1009ac <_translate_sc+0x138> - 101275: 8d 76 00 lea 0x0(%esi),%esi - 101278: 8b 15 40 85 10 00 mov 0x108540,%edx - 10127e: 4a dec %edx - 10127f: 0f 89 01 f6 ff ff jns 100886 <_translate_sc+0x12> - 101285: 31 c0 xor %eax,%eax - 101287: c7 05 40 85 10 00 00 movl $0x0,0x108540 - 10128e: 00 00 00 - 101291: e9 60 f6 ff ff jmp 1008f6 <_translate_sc+0x82> - 101296: 89 f6 mov %esi,%esi - -00101298 : - -/** - * handle_meta_key() - * - * I'll pretty this up later - */ -void handle_meta_key(unsigned k) -{ - 101298: 55 push %ebp - 101299: 89 e5 mov %esp,%ebp - 10129b: 83 ec 08 sub $0x8,%esp - int i; - k = k; /* to shut gcc up */ - - /** - * Check for the infamous three finger salute - */ - if((keys[KEY_RCTRL] || keys[KEY_LCTRL]) && - 10129e: 8b 15 b4 83 10 00 mov 0x1083b4,%edx - 1012a4: 85 d2 test %edx,%edx - 1012a6: 74 69 je 101311 - 1012a8: 8b 15 20 84 10 00 mov 0x108420,%edx - 1012ae: 85 d2 test %edx,%edx - 1012b0: 74 0a je 1012bc - 1012b2: a1 8c 84 10 00 mov 0x10848c,%eax - 1012b7: 85 c0 test %eax,%eax - 1012b9: 75 51 jne 10130c - 1012bb: 90 nop - (keys[KEY_RALT] || keys[KEY_LALT]) && - keys[KEY_DEL]) - { - /** - * FIXME - * - * This should call _send_signal() - */ - reboot(); - } - - /** - * Check for Alt + F1-F12 for virtual terminals - */ - for(i = 0; i < 10; i++) - 1012bc: 31 c0 xor %eax,%eax - 1012be: b9 40 83 10 00 mov $0x108340,%ecx - 1012c3: 90 nop - { - if((keys[KEY_LALT] || keys[KEY_RALT]) && keys[i + KEY_F1]) - 1012c4: 85 d2 test %edx,%edx - 1012c6: 74 0a je 1012d2 - 1012c8: 83 bc 81 ec 00 00 00 cmpl $0x0,0xec(%ecx,%eax,4) - 1012cf: 00 - 1012d0: 75 35 jne 101307 - 1012d2: 40 inc %eax - 1012d3: 83 f8 09 cmp $0x9,%eax - 1012d6: 7e ec jle 1012c4 - { - select_vc(i); - return; - } - } - - if((keys[KEY_LALT] || keys[KEY_RALT]) && keys[KEY_F11]) - 1012d8: 85 d2 test %edx,%edx - 1012da: 74 13 je 1012ef - 1012dc: 8b 15 9c 84 10 00 mov 0x10849c,%edx - 1012e2: 85 d2 test %edx,%edx - 1012e4: 75 18 jne 1012fe - { - select_vc(10); - return; - } - - if((keys[KEY_LALT] || keys[KEY_RALT]) && keys[KEY_F12]) - 1012e6: a1 a0 84 10 00 mov 0x1084a0,%eax - 1012eb: 85 c0 test %eax,%eax - 1012ed: 75 02 jne 1012f1 - { - select_vc(11); - return; - } -} - 1012ef: c9 leave - 1012f0: c3 ret - 1012f1: c7 45 08 0b 00 00 00 movl $0xb,0x8(%ebp) - 1012f8: c9 leave - 1012f9: e9 06 35 00 00 jmp 104804 - 1012fe: c7 45 08 0a 00 00 00 movl $0xa,0x8(%ebp) - 101305: eb f1 jmp 1012f8 - 101307: 89 45 08 mov %eax,0x8(%ebp) - 10130a: eb ec jmp 1012f8 - 10130c: e8 d3 f4 ff ff call 1007e4 - 101311: 8b 15 20 84 10 00 mov 0x108420,%edx - 101317: eb a3 jmp 1012bc - 101319: 8d 76 00 lea 0x0(%esi),%esi - -0010131c : - -/** - * keyboard_irq() - * - * Called when a keyboard interrupt is generated. - */ -void keyboard_irq(void) -{ - 10131c: 55 push %ebp - 10131d: 89 e5 mov %esp,%ebp - 10131f: 53 push %ebx - 101320: 83 ec 10 sub $0x10,%esp - register char a; - unsigned c; - unsigned short kbdstat; - - rawkey = inportb(0x60); - 101323: 6a 60 push $0x60 - 101325: e8 ea 3c 00 00 call 105014 - 10132a: a3 20 83 10 00 mov %eax,0x108320 - outportb(0x61, (a=inportb(0x61)|0x82)); - 10132f: c7 04 24 61 00 00 00 movl $0x61,(%esp,1) - 101336: e8 d9 3c 00 00 call 105014 - 10133b: 83 c8 82 or $0xffffff82,%eax - 10133e: 59 pop %ecx - 10133f: 5b pop %ebx - 101340: 0f be d8 movsbl %al,%ebx - 101343: 53 push %ebx - 101344: 6a 61 push $0x61 - 101346: e8 69 3d 00 00 call 1050b4 - outportb(0x61, a & 0x7F); - 10134b: 58 pop %eax - 10134c: 5a pop %edx - 10134d: 83 e3 7f and $0x7f,%ebx - 101350: 53 push %ebx - 101351: 6a 61 push $0x61 - 101353: e8 5c 3d 00 00 call 1050b4 - - /** - * If it's less than 0x80 then it's definatelly - * a make code or a repeat code - */ - if(rawkey < 0x80) - 101358: 8b 0d 20 83 10 00 mov 0x108320,%ecx - 10135e: 83 c4 10 add $0x10,%esp - 101361: 83 f9 7f cmp $0x7f,%ecx - 101364: 7f 6a jg 1013d0 - { - /** - * We don't want to gunk up the numlock key - * because we will define it's state in the - * break code a bit later - */ - if((rawkey != KEYP_NUMLCK) && (rawkey != KEY_SCRLCK) && (rawkey != KEY_CAPS)) - 101366: 8d 41 bb lea 0xffffffbb(%ecx),%eax - 101369: 83 f8 01 cmp $0x1,%eax - 10136c: 76 10 jbe 10137e - 10136e: 83 f9 3a cmp $0x3a,%ecx - 101371: 74 0b je 10137e - keys[rawkey] = 1; - 101373: c7 04 8d 40 83 10 00 movl $0x1,0x108340(,%ecx,4) - 10137a: 01 00 00 00 - - keyDown(rawkey); - 10137e: 83 ec 0c sub $0xc,%esp - 101381: ff 35 20 83 10 00 pushl 0x108320 - 101387: e8 c4 ee ff ff call 100250 - 10138c: 58 pop %eax - } - else /* rawkey >= 0x80 */ - { - if(rawkey == 0xE0) - { - /** - * It's either a make code, break code, or repeat code - */ - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - if(rawkey < 0x80) - { - /** - * Ok, it's a make code or repeat code for the numeric - * keypad (gray keys) - */ - - keys[rawkey] = 1; - - keyDown(rawkey); - } - else /* rawkey >= 0x80 */ - { - /** - * It's either a make code for the numeric keypad or - * a break code for the numeric keypad. - */ - if(rawkey == 0x2A) - { - /** - * Ok, we have a make code for the numeric keypad - * and NUMLOCK is on. The second byte is what we - * want since what we have so far is this: - * - * 0xE0 0x2A - */ - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - rawkey = inportb(0x60); - outportb(0x61, (a=inportb(0x61)|0x82)); - outportb(0x61, a & 0x7F); - - keys[rawkey] = 1; - - keyDown(rawkey); - } - else - { - /** - * It's a break code from the numeric keypad. - */ - keys[rawkey] = 0; - - keyUp(rawkey); - } - } - } - else /* rawkey != 0xE0 */ - { - /** - * It's a break code - * - * Make sure we toggle the numlock, scroll lock, and caps lock key. - */ - if(((rawkey - 0x80) == KEYP_NUMLCK) || - ((rawkey - 0x80) == KEY_SCRLCK) || - ((rawkey - 0x80) == KEY_CAPS)) - { - keys[rawkey - 0x80] = !keys[rawkey - 0x80]; - - kbdstat = 0; - if(keys[KEY_SCRLCK]) - kbdstat |= 1; - if(keys[KEYP_NUMLCK]) - kbdstat |= 2; - if(keys[KEY_CAPS]) - kbdstat |= 4; - - _write_kb(0x60, 0xED); - _write_kb(0x60, kbdstat); - outportb(0x20, 0x20); - - keyUp(rawkey); - return; - } - - keys[rawkey - 0x80] = 0; - - keyUp(rawkey); - } - } - - c = _translate_sc(rawkey); - 10138d: ff 35 20 83 10 00 pushl 0x108320 - 101393: e8 dc f4 ff ff call 100874 <_translate_sc> - - if(c != 0) - 101398: 83 c4 10 add $0x10,%esp - 10139b: 85 c0 test %eax,%eax - 10139d: 74 21 je 1013c0 - printf("%c", c); - 10139f: 83 ec 08 sub $0x8,%esp - 1013a2: 50 push %eax - 1013a3: 68 e5 51 10 00 push $0x1051e5 - 1013a8: e8 27 3d 00 00 call 1050d4 - 1013ad: 59 pop %ecx - 1013ae: 5b pop %ebx - else - { - /** - * We need to check for meta-key-crap here - */ - handle_meta_key(rawkey); - } - - //enable(); - outportb(0x20, 0x20); - 1013af: 6a 20 push $0x20 - 1013b1: 6a 20 push $0x20 - 1013b3: e8 fc 3c 00 00 call 1050b4 -} - 1013b8: 8b 5d fc mov 0xfffffffc(%ebp),%ebx - 1013bb: c9 leave - 1013bc: c3 ret - 1013bd: 8d 76 00 lea 0x0(%esi),%esi - 1013c0: 83 ec 0c sub $0xc,%esp - 1013c3: ff 35 20 83 10 00 pushl 0x108320 - 1013c9: e8 ca fe ff ff call 101298 - 1013ce: eb dd jmp 1013ad - 1013d0: 81 f9 e0 00 00 00 cmp $0xe0,%ecx - 1013d6: 0f 84 a5 00 00 00 je 101481 - 1013dc: 8d 81 3b ff ff ff lea 0xffffff3b(%ecx),%eax - 1013e2: 83 f8 01 cmp $0x1,%eax - 1013e5: 76 21 jbe 101408 - 1013e7: 81 f9 ba 00 00 00 cmp $0xba,%ecx - 1013ed: 74 19 je 101408 - 1013ef: 83 ec 0c sub $0xc,%esp - 1013f2: c7 04 8d 40 81 10 00 movl $0x0,0x108140(,%ecx,4) - 1013f9: 00 00 00 00 - 1013fd: 51 push %ecx - 1013fe: e8 55 ee ff ff call 100258 - 101403: eb 87 jmp 10138c - 101405: 8d 76 00 lea 0x0(%esi),%esi - 101408: ba 40 83 10 00 mov $0x108340,%edx - 10140d: 31 c0 xor %eax,%eax - 10140f: 83 bc 8a 00 fe ff ff cmpl $0x0,0xfffffe00(%edx,%ecx,4) - 101416: 00 - 101417: 0f 94 c0 sete %al - 10141a: 89 84 8a 00 fe ff ff mov %eax,0xfffffe00(%edx,%ecx,4) - 101421: a1 58 84 10 00 mov 0x108458,%eax - 101426: 31 db xor %ebx,%ebx - 101428: 85 c0 test %eax,%eax - 10142a: 74 05 je 101431 - 10142c: bb 01 00 00 00 mov $0x1,%ebx - 101431: a1 54 84 10 00 mov 0x108454,%eax - 101436: 85 c0 test %eax,%eax - 101438: 74 03 je 10143d - 10143a: 83 cb 02 or $0x2,%ebx - 10143d: a1 28 84 10 00 mov 0x108428,%eax - 101442: 85 c0 test %eax,%eax - 101444: 74 03 je 101449 - 101446: 83 cb 04 or $0x4,%ebx - 101449: 83 ec 08 sub $0x8,%esp - 10144c: 68 ed 00 00 00 push $0xed - 101451: 6a 60 push $0x60 - 101453: e8 d4 f3 ff ff call 10082c <_write_kb> - 101458: 59 pop %ecx - 101459: 58 pop %eax - 10145a: 0f b7 c3 movzwl %bx,%eax - 10145d: 50 push %eax - 10145e: 6a 60 push $0x60 - 101460: e8 c7 f3 ff ff call 10082c <_write_kb> - 101465: 58 pop %eax - 101466: 5a pop %edx - 101467: 6a 20 push $0x20 - 101469: 6a 20 push $0x20 - 10146b: e8 44 3c 00 00 call 1050b4 - 101470: 58 pop %eax - 101471: ff 35 20 83 10 00 pushl 0x108320 - 101477: e8 dc ed ff ff call 100258 - 10147c: e9 37 ff ff ff jmp 1013b8 - 101481: 83 ec 0c sub $0xc,%esp - 101484: 6a 60 push $0x60 - 101486: e8 89 3b 00 00 call 105014 - 10148b: a3 20 83 10 00 mov %eax,0x108320 - 101490: c7 04 24 61 00 00 00 movl $0x61,(%esp,1) - 101497: e8 78 3b 00 00 call 105014 - 10149c: 83 c8 82 or $0xffffff82,%eax - 10149f: 59 pop %ecx - 1014a0: 5b pop %ebx - 1014a1: 0f be d8 movsbl %al,%ebx - 1014a4: 53 push %ebx - 1014a5: 6a 61 push $0x61 - 1014a7: e8 08 3c 00 00 call 1050b4 - 1014ac: 58 pop %eax - 1014ad: 5a pop %edx - 1014ae: 83 e3 7f and $0x7f,%ebx - 1014b1: 53 push %ebx - 1014b2: 6a 61 push $0x61 - 1014b4: e8 fb 3b 00 00 call 1050b4 - 1014b9: a1 20 83 10 00 mov 0x108320,%eax - 1014be: 83 c4 10 add $0x10,%esp - 1014c1: 83 f8 7f cmp $0x7f,%eax - 1014c4: 0f 8e a2 00 00 00 jle 10156c - 1014ca: 83 f8 2a cmp $0x2a,%eax - 1014cd: 74 14 je 1014e3 - 1014cf: 83 ec 0c sub $0xc,%esp - 1014d2: 50 push %eax - 1014d3: c7 04 85 40 83 10 00 movl $0x0,0x108340(,%eax,4) - 1014da: 00 00 00 00 - 1014de: e9 1b ff ff ff jmp 1013fe - 1014e3: 83 ec 0c sub $0xc,%esp - 1014e6: 6a 60 push $0x60 - 1014e8: e8 27 3b 00 00 call 105014 - 1014ed: a3 20 83 10 00 mov %eax,0x108320 - 1014f2: c7 04 24 61 00 00 00 movl $0x61,(%esp,1) - 1014f9: e8 16 3b 00 00 call 105014 - 1014fe: 83 c8 82 or $0xffffff82,%eax - 101501: 59 pop %ecx - 101502: 5b pop %ebx - 101503: 0f be d8 movsbl %al,%ebx - 101506: 53 push %ebx - 101507: 6a 61 push $0x61 - 101509: e8 a6 3b 00 00 call 1050b4 - 10150e: 58 pop %eax - 10150f: 5a pop %edx - 101510: 83 e3 7f and $0x7f,%ebx - 101513: 53 push %ebx - 101514: 6a 61 push $0x61 - 101516: e8 99 3b 00 00 call 1050b4 - 10151b: c7 04 24 60 00 00 00 movl $0x60,(%esp,1) - 101522: e8 ed 3a 00 00 call 105014 - 101527: a3 20 83 10 00 mov %eax,0x108320 - 10152c: c7 04 24 61 00 00 00 movl $0x61,(%esp,1) - 101533: e8 dc 3a 00 00 call 105014 - 101538: 83 c8 82 or $0xffffff82,%eax - 10153b: 5a pop %edx - 10153c: 59 pop %ecx - 10153d: 0f be d8 movsbl %al,%ebx - 101540: 53 push %ebx - 101541: 6a 61 push $0x61 - 101543: e8 6c 3b 00 00 call 1050b4 - 101548: 59 pop %ecx - 101549: 58 pop %eax - 10154a: 83 e3 7f and $0x7f,%ebx - 10154d: 53 push %ebx - 10154e: 6a 61 push $0x61 - 101550: e8 5f 3b 00 00 call 1050b4 - 101555: a1 20 83 10 00 mov 0x108320,%eax - 10155a: 5a pop %edx - 10155b: c7 04 85 40 83 10 00 movl $0x1,0x108340(,%eax,4) - 101562: 01 00 00 00 - 101566: 50 push %eax - 101567: e9 1b fe ff ff jmp 101387 - 10156c: c7 04 85 40 83 10 00 movl $0x1,0x108340(,%eax,4) - 101573: 01 00 00 00 - 101577: 83 ec 0c sub $0xc,%esp - 10157a: eb ea jmp 101566 - -0010157c : - -/** - * init_keyboard() - * - */ -void init_keyboard(void) -{ - 10157c: 55 push %ebp - 10157d: 89 e5 mov %esp,%ebp - static unsigned char buffers[KBD_BUF_SIZE * MAX_VC]; - - int i; - - //klog("init", "keyboard %2u buf, %2ub each", K_KLOG_PENDING, &_vc[0]); - for(i = 0; i < MAX_VC; i++) - 10157f: b9 20 80 10 00 mov $0x108020,%ecx - 101584: 83 ec 08 sub $0x8,%esp - 101587: 31 d2 xor %edx,%edx - 101589: b8 0b 00 00 00 mov $0xb,%eax - { - _vc[i].keystrokes.data = buffers + KBD_BUF_SIZE * i; - 10158e: 89 8a e0 a2 19 00 mov %ecx,0x19a2e0(%edx) - _vc[i].keystrokes.size = KBD_BUF_SIZE; - 101594: c7 82 e4 a2 19 00 40 movl $0x40,0x19a2e4(%edx) - 10159b: 00 00 00 - 10159e: 83 c1 40 add $0x40,%ecx - 1015a1: 83 c2 34 add $0x34,%edx - 1015a4: 48 dec %eax - 1015a5: 79 e7 jns 10158e - } - - for(i = 0; i < 128; i++) - 1015a7: 31 c0 xor %eax,%eax - 1015a9: 8d 76 00 lea 0x0(%esi),%esi - keys[i] = 0; - 1015ac: c7 04 85 40 83 10 00 movl $0x0,0x108340(,%eax,4) - 1015b3: 00 00 00 00 - 1015b7: 40 inc %eax - 1015b8: 83 f8 7f cmp $0x7f,%eax - 1015bb: 7e ef jle 1015ac - - makebreak = 0; - //klog(NULL, K_KLOG_SUCCESS, &_vc[0], NULL); - //kprintf("init_kbd: %u buffers, %u bytes each\n", - // MAX_VC, KBD_BUF_SIZE); - - //kprintf("[ Entering Runlevel 0 ].......................................................Ok"); - _vc[0].attrib = 8; - printf("[ "); - 1015bd: 83 ec 0c sub $0xc,%esp - 1015c0: 68 b6 51 10 00 push $0x1051b6 - 1015c5: c7 05 a0 85 10 00 00 movl $0x0,0x1085a0 - 1015cc: 00 00 00 - 1015cf: c7 05 f8 a2 19 00 08 movl $0x8,0x19a2f8 - 1015d6: 00 00 00 - 1015d9: e8 f6 3a 00 00 call 1050d4 - _vc[0].attrib = 15; - printf("init: keyboard %2u buf, %2ub each ", MAX_VC, KBD_BUF_SIZE); - 1015de: 83 c4 0c add $0xc,%esp - 1015e1: 6a 40 push $0x40 - 1015e3: 6a 0c push $0xc - 1015e5: 68 60 58 10 00 push $0x105860 - 1015ea: c7 05 f8 a2 19 00 0f movl $0xf,0x19a2f8 - 1015f1: 00 00 00 - 1015f4: e8 db 3a 00 00 call 1050d4 - _vc[0].attrib = 8; - printf("]..........................................."); - 1015f9: c7 04 24 a0 58 10 00 movl $0x1058a0,(%esp,1) - 101600: c7 05 f8 a2 19 00 08 movl $0x8,0x19a2f8 - 101607: 00 00 00 - 10160a: e8 c5 3a 00 00 call 1050d4 - _vc[0].attrib = 2; - printf("Ok"); - 10160f: c7 04 24 d9 54 10 00 movl $0x1054d9,(%esp,1) - 101616: c7 05 f8 a2 19 00 02 movl $0x2,0x19a2f8 - 10161d: 00 00 00 - 101620: e8 af 3a 00 00 call 1050d4 - _vc[0].attrib = 7; - 101625: c7 05 f8 a2 19 00 07 movl $0x7,0x19a2f8 - 10162c: 00 00 00 -} - 10162f: c9 leave - 101630: c3 ret - ... - -00101640 : - 101640: a1 00 70 10 00 mov 0x107000,%eax - 101645: 3d 2a da 44 35 cmp $0x3544da2a,%eax - 10164a: 74 0b je 101657 - 10164c: 66 c7 05 00 80 0b 00 movw $0x9f44,0xb8000 - 101653: 44 9f - 101655: eb fe jmp 101655 - -00101657 : - 101657: 0f 01 15 24 70 10 00 lgdtl 0x107024 - 10165e: 66 b8 10 00 mov $0x10,%ax - 101662: 8e d8 mov %eax,%ds - 101664: 8e c0 mov %eax,%es - 101666: 8e d0 mov %eax,%ss - 101668: 8e e0 mov %eax,%fs - 10166a: 8e e8 mov %eax,%gs - 10166c: ea 73 16 10 00 18 00 ljmp $0x18,$0x101673 - -00101673 : - 101673: bf 00 80 10 00 mov $0x108000,%edi - 101678: b9 00 b0 19 00 mov $0x19b000,%ecx - 10167d: 29 f9 sub %edi,%ecx - 10167f: 31 c0 xor %eax,%eax - 101681: f3 aa repz stos %al,%es:(%edi) - 101683: bc a4 95 10 00 mov $0x1095a4,%esp - 101688: b9 00 01 00 00 mov $0x100,%ecx - 10168d: bf 2a 70 10 00 mov $0x10702a,%edi - 101692: be 6b 17 10 00 mov $0x10176b,%esi - -00101697 : - 101697: 89 f0 mov %esi,%eax - 101699: 66 89 07 mov %ax,(%edi) - 10169c: c1 e8 10 shr $0x10,%eax - 10169f: 66 89 47 06 mov %ax,0x6(%edi) - 1016a3: 81 c7 08 00 00 00 add $0x8,%edi - 1016a9: 81 c6 26 00 00 00 add $0x26,%esi - 1016af: e2 e6 loop 101697 - 1016b1: 0f 01 1d 2a 78 10 00 lidtl 0x10782a - 1016b8: 68 02 00 00 00 push $0x2 - 1016bd: 9d popf - 1016be: e8 61 2c 00 00 call 104324
- 1016c3: eb fe jmp 1016c3 - 1016c5: 90 nop - 1016c6: 90 nop - 1016c7: 90 nop - -001016c8 : - 1016c8: 02 b0 ad 1b 03 00 add 0x31bad(%eax),%dh - 1016ce: 01 00 add %eax,(%eax) - 1016d0: fb sti - 1016d1: 4f dec %edi - 1016d2: 51 push %ecx - 1016d3: e4 c8 in $0xc8,%al - 1016d5: 16 push %ss - 1016d6: 10 00 adc %al,(%eax) - 1016d8: 00 00 add %al,(%eax) - 1016da: 10 00 adc %al,(%eax) - 1016dc: 00 80 10 00 00 b0 add %al,0xb0000010(%eax) - 1016e2: 19 00 sbb %eax,(%eax) - 1016e4: 40 inc %eax - 1016e5: 16 push %ss - 1016e6: 10 00 adc %al,(%eax) - -001016e8 : - 1016e8: 58 pop %eax - 1016e9: 61 popa - 1016ea: 1f pop %ds - 1016eb: 07 pop %es - 1016ec: 0f a1 pop %fs - 1016ee: 0f a9 pop %gs - 1016f0: 81 c4 08 00 00 00 add $0x8,%esp - 1016f6: cf iret - -001016f7 <_getvect>: - 1016f7: 55 push %ebp - 1016f8: 89 e5 mov %esp,%ebp - 1016fa: 56 push %esi - 1016fb: 53 push %ebx - 1016fc: 8b 75 08 mov 0x8(%ebp),%esi - 1016ff: 31 db xor %ebx,%ebx - 101701: 8a 5d 0c mov 0xc(%ebp),%bl - 101704: c1 e3 03 shl $0x3,%ebx - 101707: 8a 83 2f 70 10 00 mov 0x10702f(%ebx),%al - 10170d: 89 06 mov %eax,(%esi) - 10170f: b8 91 17 10 00 mov $0x101791,%eax - 101714: 2d 6b 17 10 00 sub $0x10176b,%eax - 101719: f6 65 0c mulb 0xc(%ebp) - 10171c: 89 c3 mov %eax,%ebx - 10171e: 81 c3 6b 17 10 00 add $0x10176b,%ebx - 101724: 8b 83 1b 00 00 00 mov 0x1b(%ebx),%eax - 10172a: 89 46 04 mov %eax,0x4(%esi) - 10172d: 5b pop %ebx - 10172e: 5e pop %esi - 10172f: 5d pop %ebp - 101730: c3 ret - -00101731 <_setvect>: - 101731: 55 push %ebp - 101732: 89 e5 mov %esp,%ebp - 101734: 56 push %esi - 101735: 53 push %ebx - 101736: 8b 75 08 mov 0x8(%ebp),%esi - 101739: 8b 06 mov (%esi),%eax - 10173b: 31 db xor %ebx,%ebx - 10173d: 8a 5d 0c mov 0xc(%ebp),%bl - 101740: c1 e3 03 shl $0x3,%ebx - 101743: 88 83 2f 70 10 00 mov %al,0x10702f(%ebx) - 101749: b8 91 17 10 00 mov $0x101791,%eax - 10174e: 2d 6b 17 10 00 sub $0x10176b,%eax - 101753: f6 65 0c mulb 0xc(%ebp) - 101756: 89 c3 mov %eax,%ebx - 101758: 81 c3 6b 17 10 00 add $0x10176b,%ebx - 10175e: 8b 46 04 mov 0x4(%esi),%eax - 101761: 89 83 1b 00 00 00 mov %eax,0x1b(%ebx) - 101767: 5b pop %ebx - 101768: 5e pop %esi - 101769: 5d pop %ebp - 10176a: c3 ret - -0010176b : - 10176b: 6a 00 push $0x0 - 10176d: 6a 00 push $0x0 - 10176f: 0f a8 push %gs - 101771: 0f a0 push %fs - 101773: 06 push %es - 101774: 1e push %ds - 101775: 60 pusha - 101776: 66 b8 10 00 mov $0x10,%ax - 10177a: 8e d8 mov %eax,%ds - 10177c: 8e c0 mov %eax,%es - 10177e: 8e e0 mov %eax,%fs - 101780: 8e e8 mov %eax,%gs - 101782: 89 e0 mov %esp,%eax - 101784: 50 push %eax - -00101785 : - 101785: b8 04 3e 10 00 mov $0x103e04,%eax - 10178a: ff d0 call *%eax - 10178c: e9 57 ff ff ff jmp 1016e8 - -00101791 : - 101791: 6a 00 push $0x0 - 101793: 6a 01 push $0x1 - 101795: 0f a8 push %gs - 101797: 0f a0 push %fs - 101799: 06 push %es - 10179a: 1e push %ds - 10179b: 60 pusha - 10179c: 66 b8 10 00 mov $0x10,%ax - 1017a0: 8e d8 mov %eax,%ds - 1017a2: 8e c0 mov %eax,%es - 1017a4: 8e e0 mov %eax,%fs - 1017a6: 8e e8 mov %eax,%gs - 1017a8: 89 e0 mov %esp,%eax - 1017aa: 50 push %eax - -001017ab : - 1017ab: b8 04 3e 10 00 mov $0x103e04,%eax - 1017b0: ff d0 call *%eax - 1017b2: e9 31 ff ff ff jmp 1016e8 - -001017b7 : - 1017b7: 6a 00 push $0x0 - 1017b9: 6a 02 push $0x2 - 1017bb: 0f a8 push %gs - 1017bd: 0f a0 push %fs - 1017bf: 06 push %es - 1017c0: 1e push %ds - 1017c1: 60 pusha - 1017c2: 66 b8 10 00 mov $0x10,%ax - 1017c6: 8e d8 mov %eax,%ds - 1017c8: 8e c0 mov %eax,%es - 1017ca: 8e e0 mov %eax,%fs - 1017cc: 8e e8 mov %eax,%gs - 1017ce: 89 e0 mov %esp,%eax - 1017d0: 50 push %eax - -001017d1 : - 1017d1: b8 04 3e 10 00 mov $0x103e04,%eax - 1017d6: ff d0 call *%eax - 1017d8: e9 0b ff ff ff jmp 1016e8 - -001017dd : - 1017dd: 6a 00 push $0x0 - 1017df: 6a 03 push $0x3 - 1017e1: 0f a8 push %gs - 1017e3: 0f a0 push %fs - 1017e5: 06 push %es - 1017e6: 1e push %ds - 1017e7: 60 pusha - 1017e8: 66 b8 10 00 mov $0x10,%ax - 1017ec: 8e d8 mov %eax,%ds - 1017ee: 8e c0 mov %eax,%es - 1017f0: 8e e0 mov %eax,%fs - 1017f2: 8e e8 mov %eax,%gs - 1017f4: 89 e0 mov %esp,%eax - 1017f6: 50 push %eax - -001017f7 : - 1017f7: b8 04 3e 10 00 mov $0x103e04,%eax - 1017fc: ff d0 call *%eax - 1017fe: e9 e5 fe ff ff jmp 1016e8 - -00101803 : - 101803: 6a 00 push $0x0 - 101805: 6a 04 push $0x4 - 101807: 0f a8 push %gs - 101809: 0f a0 push %fs - 10180b: 06 push %es - 10180c: 1e push %ds - 10180d: 60 pusha - 10180e: 66 b8 10 00 mov $0x10,%ax - 101812: 8e d8 mov %eax,%ds - 101814: 8e c0 mov %eax,%es - 101816: 8e e0 mov %eax,%fs - 101818: 8e e8 mov %eax,%gs - 10181a: 89 e0 mov %esp,%eax - 10181c: 50 push %eax - -0010181d : - 10181d: b8 04 3e 10 00 mov $0x103e04,%eax - 101822: ff d0 call *%eax - 101824: e9 bf fe ff ff jmp 1016e8 - -00101829 : - 101829: 6a 00 push $0x0 - 10182b: 6a 05 push $0x5 - 10182d: 0f a8 push %gs - 10182f: 0f a0 push %fs - 101831: 06 push %es - 101832: 1e push %ds - 101833: 60 pusha - 101834: 66 b8 10 00 mov $0x10,%ax - 101838: 8e d8 mov %eax,%ds - 10183a: 8e c0 mov %eax,%es - 10183c: 8e e0 mov %eax,%fs - 10183e: 8e e8 mov %eax,%gs - 101840: 89 e0 mov %esp,%eax - 101842: 50 push %eax - -00101843 : - 101843: b8 04 3e 10 00 mov $0x103e04,%eax - 101848: ff d0 call *%eax - 10184a: e9 99 fe ff ff jmp 1016e8 - -0010184f : - 10184f: 6a 00 push $0x0 - 101851: 6a 06 push $0x6 - 101853: 0f a8 push %gs - 101855: 0f a0 push %fs - 101857: 06 push %es - 101858: 1e push %ds - 101859: 60 pusha - 10185a: 66 b8 10 00 mov $0x10,%ax - 10185e: 8e d8 mov %eax,%ds - 101860: 8e c0 mov %eax,%es - 101862: 8e e0 mov %eax,%fs - 101864: 8e e8 mov %eax,%gs - 101866: 89 e0 mov %esp,%eax - 101868: 50 push %eax - -00101869 : - 101869: b8 04 3e 10 00 mov $0x103e04,%eax - 10186e: ff d0 call *%eax - 101870: e9 73 fe ff ff jmp 1016e8 - -00101875 : - 101875: 6a 00 push $0x0 - 101877: 6a 07 push $0x7 - 101879: 0f a8 push %gs - 10187b: 0f a0 push %fs - 10187d: 06 push %es - 10187e: 1e push %ds - 10187f: 60 pusha - 101880: 66 b8 10 00 mov $0x10,%ax - 101884: 8e d8 mov %eax,%ds - 101886: 8e c0 mov %eax,%es - 101888: 8e e0 mov %eax,%fs - 10188a: 8e e8 mov %eax,%gs - 10188c: 89 e0 mov %esp,%eax - 10188e: 50 push %eax - -0010188f : - 10188f: b8 04 3e 10 00 mov $0x103e04,%eax - 101894: ff d0 call *%eax - 101896: e9 4d fe ff ff jmp 1016e8 - -0010189b : - 10189b: 90 nop - 10189c: 90 nop - 10189d: 6a 08 push $0x8 - 10189f: 0f a8 push %gs - 1018a1: 0f a0 push %fs - 1018a3: 06 push %es - 1018a4: 1e push %ds - 1018a5: 60 pusha - 1018a6: 66 b8 10 00 mov $0x10,%ax - 1018aa: 8e d8 mov %eax,%ds - 1018ac: 8e c0 mov %eax,%es - 1018ae: 8e e0 mov %eax,%fs - 1018b0: 8e e8 mov %eax,%gs - 1018b2: 89 e0 mov %esp,%eax - 1018b4: 50 push %eax - -001018b5 : - 1018b5: b8 04 3e 10 00 mov $0x103e04,%eax - 1018ba: ff d0 call *%eax - 1018bc: e9 27 fe ff ff jmp 1016e8 - -001018c1 : - 1018c1: 6a 00 push $0x0 - 1018c3: 6a 09 push $0x9 - 1018c5: 0f a8 push %gs - 1018c7: 0f a0 push %fs - 1018c9: 06 push %es - 1018ca: 1e push %ds - 1018cb: 60 pusha - 1018cc: 66 b8 10 00 mov $0x10,%ax - 1018d0: 8e d8 mov %eax,%ds - 1018d2: 8e c0 mov %eax,%es - 1018d4: 8e e0 mov %eax,%fs - 1018d6: 8e e8 mov %eax,%gs - 1018d8: 89 e0 mov %esp,%eax - 1018da: 50 push %eax - -001018db : - 1018db: b8 04 3e 10 00 mov $0x103e04,%eax - 1018e0: ff d0 call *%eax - 1018e2: e9 01 fe ff ff jmp 1016e8 - -001018e7 : - 1018e7: 90 nop - 1018e8: 90 nop - 1018e9: 6a 0a push $0xa - 1018eb: 0f a8 push %gs - 1018ed: 0f a0 push %fs - 1018ef: 06 push %es - 1018f0: 1e push %ds - 1018f1: 60 pusha - 1018f2: 66 b8 10 00 mov $0x10,%ax - 1018f6: 8e d8 mov %eax,%ds - 1018f8: 8e c0 mov %eax,%es - 1018fa: 8e e0 mov %eax,%fs - 1018fc: 8e e8 mov %eax,%gs - 1018fe: 89 e0 mov %esp,%eax - 101900: 50 push %eax - -00101901 : - 101901: b8 04 3e 10 00 mov $0x103e04,%eax - 101906: ff d0 call *%eax - 101908: e9 db fd ff ff jmp 1016e8 - -0010190d : - 10190d: 90 nop - 10190e: 90 nop - 10190f: 6a 0b push $0xb - 101911: 0f a8 push %gs - 101913: 0f a0 push %fs - 101915: 06 push %es - 101916: 1e push %ds - 101917: 60 pusha - 101918: 66 b8 10 00 mov $0x10,%ax - 10191c: 8e d8 mov %eax,%ds - 10191e: 8e c0 mov %eax,%es - 101920: 8e e0 mov %eax,%fs - 101922: 8e e8 mov %eax,%gs - 101924: 89 e0 mov %esp,%eax - 101926: 50 push %eax - -00101927 : - 101927: b8 04 3e 10 00 mov $0x103e04,%eax - 10192c: ff d0 call *%eax - 10192e: e9 b5 fd ff ff jmp 1016e8 - -00101933 : - 101933: 90 nop - 101934: 90 nop - 101935: 6a 0c push $0xc - 101937: 0f a8 push %gs - 101939: 0f a0 push %fs - 10193b: 06 push %es - 10193c: 1e push %ds - 10193d: 60 pusha - 10193e: 66 b8 10 00 mov $0x10,%ax - 101942: 8e d8 mov %eax,%ds - 101944: 8e c0 mov %eax,%es - 101946: 8e e0 mov %eax,%fs - 101948: 8e e8 mov %eax,%gs - 10194a: 89 e0 mov %esp,%eax - 10194c: 50 push %eax - -0010194d : - 10194d: b8 04 3e 10 00 mov $0x103e04,%eax - 101952: ff d0 call *%eax - 101954: e9 8f fd ff ff jmp 1016e8 - -00101959 : - 101959: 90 nop - 10195a: 90 nop - 10195b: 6a 0d push $0xd - 10195d: 0f a8 push %gs - 10195f: 0f a0 push %fs - 101961: 06 push %es - 101962: 1e push %ds - 101963: 60 pusha - 101964: 66 b8 10 00 mov $0x10,%ax - 101968: 8e d8 mov %eax,%ds - 10196a: 8e c0 mov %eax,%es - 10196c: 8e e0 mov %eax,%fs - 10196e: 8e e8 mov %eax,%gs - 101970: 89 e0 mov %esp,%eax - 101972: 50 push %eax - -00101973 : - 101973: b8 04 3e 10 00 mov $0x103e04,%eax - 101978: ff d0 call *%eax - 10197a: e9 69 fd ff ff jmp 1016e8 - -0010197f : - 10197f: 90 nop - 101980: 90 nop - 101981: 6a 0e push $0xe - 101983: 0f a8 push %gs - 101985: 0f a0 push %fs - 101987: 06 push %es - 101988: 1e push %ds - 101989: 60 pusha - 10198a: 66 b8 10 00 mov $0x10,%ax - 10198e: 8e d8 mov %eax,%ds - 101990: 8e c0 mov %eax,%es - 101992: 8e e0 mov %eax,%fs - 101994: 8e e8 mov %eax,%gs - 101996: 89 e0 mov %esp,%eax - 101998: 50 push %eax - -00101999 : - 101999: b8 04 3e 10 00 mov $0x103e04,%eax - 10199e: ff d0 call *%eax - 1019a0: e9 43 fd ff ff jmp 1016e8 - -001019a5 : - 1019a5: 6a 00 push $0x0 - 1019a7: 6a 0f push $0xf - 1019a9: 0f a8 push %gs - 1019ab: 0f a0 push %fs - 1019ad: 06 push %es - 1019ae: 1e push %ds - 1019af: 60 pusha - 1019b0: 66 b8 10 00 mov $0x10,%ax - 1019b4: 8e d8 mov %eax,%ds - 1019b6: 8e c0 mov %eax,%es - 1019b8: 8e e0 mov %eax,%fs - 1019ba: 8e e8 mov %eax,%gs - 1019bc: 89 e0 mov %esp,%eax - 1019be: 50 push %eax - -001019bf : - 1019bf: b8 04 3e 10 00 mov $0x103e04,%eax - 1019c4: ff d0 call *%eax - 1019c6: e9 1d fd ff ff jmp 1016e8 - -001019cb : - 1019cb: 6a 00 push $0x0 - 1019cd: 6a 10 push $0x10 - 1019cf: 0f a8 push %gs - 1019d1: 0f a0 push %fs - 1019d3: 06 push %es - 1019d4: 1e push %ds - 1019d5: 60 pusha - 1019d6: 66 b8 10 00 mov $0x10,%ax - 1019da: 8e d8 mov %eax,%ds - 1019dc: 8e c0 mov %eax,%es - 1019de: 8e e0 mov %eax,%fs - 1019e0: 8e e8 mov %eax,%gs - 1019e2: 89 e0 mov %esp,%eax - 1019e4: 50 push %eax - -001019e5 : - 1019e5: b8 04 3e 10 00 mov $0x103e04,%eax - 1019ea: ff d0 call *%eax - 1019ec: e9 f7 fc ff ff jmp 1016e8 - -001019f1 : - 1019f1: 6a 00 push $0x0 - 1019f3: 6a 11 push $0x11 - 1019f5: 0f a8 push %gs - 1019f7: 0f a0 push %fs - 1019f9: 06 push %es - 1019fa: 1e push %ds - 1019fb: 60 pusha - 1019fc: 66 b8 10 00 mov $0x10,%ax - 101a00: 8e d8 mov %eax,%ds - 101a02: 8e c0 mov %eax,%es - 101a04: 8e e0 mov %eax,%fs - 101a06: 8e e8 mov %eax,%gs - 101a08: 89 e0 mov %esp,%eax - 101a0a: 50 push %eax - -00101a0b : - 101a0b: b8 04 3e 10 00 mov $0x103e04,%eax - 101a10: ff d0 call *%eax - 101a12: e9 d1 fc ff ff jmp 1016e8 - -00101a17 : - 101a17: 6a 00 push $0x0 - 101a19: 6a 12 push $0x12 - 101a1b: 0f a8 push %gs - 101a1d: 0f a0 push %fs - 101a1f: 06 push %es - 101a20: 1e push %ds - 101a21: 60 pusha - 101a22: 66 b8 10 00 mov $0x10,%ax - 101a26: 8e d8 mov %eax,%ds - 101a28: 8e c0 mov %eax,%es - 101a2a: 8e e0 mov %eax,%fs - 101a2c: 8e e8 mov %eax,%gs - 101a2e: 89 e0 mov %esp,%eax - 101a30: 50 push %eax - -00101a31 : - 101a31: b8 04 3e 10 00 mov $0x103e04,%eax - 101a36: ff d0 call *%eax - 101a38: e9 ab fc ff ff jmp 1016e8 - -00101a3d : - 101a3d: 6a 00 push $0x0 - 101a3f: 6a 13 push $0x13 - 101a41: 0f a8 push %gs - 101a43: 0f a0 push %fs - 101a45: 06 push %es - 101a46: 1e push %ds - 101a47: 60 pusha - 101a48: 66 b8 10 00 mov $0x10,%ax - 101a4c: 8e d8 mov %eax,%ds - 101a4e: 8e c0 mov %eax,%es - 101a50: 8e e0 mov %eax,%fs - 101a52: 8e e8 mov %eax,%gs - 101a54: 89 e0 mov %esp,%eax - 101a56: 50 push %eax - -00101a57 : - 101a57: b8 04 3e 10 00 mov $0x103e04,%eax - 101a5c: ff d0 call *%eax - 101a5e: e9 85 fc ff ff jmp 1016e8 - -00101a63 : - 101a63: 6a 00 push $0x0 - 101a65: 6a 14 push $0x14 - 101a67: 0f a8 push %gs - 101a69: 0f a0 push %fs - 101a6b: 06 push %es - 101a6c: 1e push %ds - 101a6d: 60 pusha - 101a6e: 66 b8 10 00 mov $0x10,%ax - 101a72: 8e d8 mov %eax,%ds - 101a74: 8e c0 mov %eax,%es - 101a76: 8e e0 mov %eax,%fs - 101a78: 8e e8 mov %eax,%gs - 101a7a: 89 e0 mov %esp,%eax - 101a7c: 50 push %eax - -00101a7d : - 101a7d: b8 04 3e 10 00 mov $0x103e04,%eax - 101a82: ff d0 call *%eax - 101a84: e9 5f fc ff ff jmp 1016e8 - -00101a89 : - 101a89: 6a 00 push $0x0 - 101a8b: 6a 15 push $0x15 - 101a8d: 0f a8 push %gs - 101a8f: 0f a0 push %fs - 101a91: 06 push %es - 101a92: 1e push %ds - 101a93: 60 pusha - 101a94: 66 b8 10 00 mov $0x10,%ax - 101a98: 8e d8 mov %eax,%ds - 101a9a: 8e c0 mov %eax,%es - 101a9c: 8e e0 mov %eax,%fs - 101a9e: 8e e8 mov %eax,%gs - 101aa0: 89 e0 mov %esp,%eax - 101aa2: 50 push %eax - -00101aa3 : - 101aa3: b8 04 3e 10 00 mov $0x103e04,%eax - 101aa8: ff d0 call *%eax - 101aaa: e9 39 fc ff ff jmp 1016e8 - -00101aaf : - 101aaf: 6a 00 push $0x0 - 101ab1: 6a 16 push $0x16 - 101ab3: 0f a8 push %gs - 101ab5: 0f a0 push %fs - 101ab7: 06 push %es - 101ab8: 1e push %ds - 101ab9: 60 pusha - 101aba: 66 b8 10 00 mov $0x10,%ax - 101abe: 8e d8 mov %eax,%ds - 101ac0: 8e c0 mov %eax,%es - 101ac2: 8e e0 mov %eax,%fs - 101ac4: 8e e8 mov %eax,%gs - 101ac6: 89 e0 mov %esp,%eax - 101ac8: 50 push %eax - -00101ac9 : - 101ac9: b8 04 3e 10 00 mov $0x103e04,%eax - 101ace: ff d0 call *%eax - 101ad0: e9 13 fc ff ff jmp 1016e8 - -00101ad5 : - 101ad5: 6a 00 push $0x0 - 101ad7: 6a 17 push $0x17 - 101ad9: 0f a8 push %gs - 101adb: 0f a0 push %fs - 101add: 06 push %es - 101ade: 1e push %ds - 101adf: 60 pusha - 101ae0: 66 b8 10 00 mov $0x10,%ax - 101ae4: 8e d8 mov %eax,%ds - 101ae6: 8e c0 mov %eax,%es - 101ae8: 8e e0 mov %eax,%fs - 101aea: 8e e8 mov %eax,%gs - 101aec: 89 e0 mov %esp,%eax - 101aee: 50 push %eax - -00101aef : - 101aef: b8 04 3e 10 00 mov $0x103e04,%eax - 101af4: ff d0 call *%eax - 101af6: e9 ed fb ff ff jmp 1016e8 - -00101afb : - 101afb: 6a 00 push $0x0 - 101afd: 6a 18 push $0x18 - 101aff: 0f a8 push %gs - 101b01: 0f a0 push %fs - 101b03: 06 push %es - 101b04: 1e push %ds - 101b05: 60 pusha - 101b06: 66 b8 10 00 mov $0x10,%ax - 101b0a: 8e d8 mov %eax,%ds - 101b0c: 8e c0 mov %eax,%es - 101b0e: 8e e0 mov %eax,%fs - 101b10: 8e e8 mov %eax,%gs - 101b12: 89 e0 mov %esp,%eax - 101b14: 50 push %eax - -00101b15 : - 101b15: b8 04 3e 10 00 mov $0x103e04,%eax - 101b1a: ff d0 call *%eax - 101b1c: e9 c7 fb ff ff jmp 1016e8 - -00101b21 : - 101b21: 6a 00 push $0x0 - 101b23: 6a 19 push $0x19 - 101b25: 0f a8 push %gs - 101b27: 0f a0 push %fs - 101b29: 06 push %es - 101b2a: 1e push %ds - 101b2b: 60 pusha - 101b2c: 66 b8 10 00 mov $0x10,%ax - 101b30: 8e d8 mov %eax,%ds - 101b32: 8e c0 mov %eax,%es - 101b34: 8e e0 mov %eax,%fs - 101b36: 8e e8 mov %eax,%gs - 101b38: 89 e0 mov %esp,%eax - 101b3a: 50 push %eax - -00101b3b : - 101b3b: b8 04 3e 10 00 mov $0x103e04,%eax - 101b40: ff d0 call *%eax - 101b42: e9 a1 fb ff ff jmp 1016e8 - -00101b47 : - 101b47: 6a 00 push $0x0 - 101b49: 6a 1a push $0x1a - 101b4b: 0f a8 push %gs - 101b4d: 0f a0 push %fs - 101b4f: 06 push %es - 101b50: 1e push %ds - 101b51: 60 pusha - 101b52: 66 b8 10 00 mov $0x10,%ax - 101b56: 8e d8 mov %eax,%ds - 101b58: 8e c0 mov %eax,%es - 101b5a: 8e e0 mov %eax,%fs - 101b5c: 8e e8 mov %eax,%gs - 101b5e: 89 e0 mov %esp,%eax - 101b60: 50 push %eax - -00101b61 : - 101b61: b8 04 3e 10 00 mov $0x103e04,%eax - 101b66: ff d0 call *%eax - 101b68: e9 7b fb ff ff jmp 1016e8 - -00101b6d : - 101b6d: 6a 00 push $0x0 - 101b6f: 6a 1b push $0x1b - 101b71: 0f a8 push %gs - 101b73: 0f a0 push %fs - 101b75: 06 push %es - 101b76: 1e push %ds - 101b77: 60 pusha - 101b78: 66 b8 10 00 mov $0x10,%ax - 101b7c: 8e d8 mov %eax,%ds - 101b7e: 8e c0 mov %eax,%es - 101b80: 8e e0 mov %eax,%fs - 101b82: 8e e8 mov %eax,%gs - 101b84: 89 e0 mov %esp,%eax - 101b86: 50 push %eax - -00101b87 : - 101b87: b8 04 3e 10 00 mov $0x103e04,%eax - 101b8c: ff d0 call *%eax - 101b8e: e9 55 fb ff ff jmp 1016e8 - -00101b93 : - 101b93: 6a 00 push $0x0 - 101b95: 6a 1c push $0x1c - 101b97: 0f a8 push %gs - 101b99: 0f a0 push %fs - 101b9b: 06 push %es - 101b9c: 1e push %ds - 101b9d: 60 pusha - 101b9e: 66 b8 10 00 mov $0x10,%ax - 101ba2: 8e d8 mov %eax,%ds - 101ba4: 8e c0 mov %eax,%es - 101ba6: 8e e0 mov %eax,%fs - 101ba8: 8e e8 mov %eax,%gs - 101baa: 89 e0 mov %esp,%eax - 101bac: 50 push %eax - -00101bad : - 101bad: b8 04 3e 10 00 mov $0x103e04,%eax - 101bb2: ff d0 call *%eax - 101bb4: e9 2f fb ff ff jmp 1016e8 - -00101bb9 : - 101bb9: 6a 00 push $0x0 - 101bbb: 6a 1d push $0x1d - 101bbd: 0f a8 push %gs - 101bbf: 0f a0 push %fs - 101bc1: 06 push %es - 101bc2: 1e push %ds - 101bc3: 60 pusha - 101bc4: 66 b8 10 00 mov $0x10,%ax - 101bc8: 8e d8 mov %eax,%ds - 101bca: 8e c0 mov %eax,%es - 101bcc: 8e e0 mov %eax,%fs - 101bce: 8e e8 mov %eax,%gs - 101bd0: 89 e0 mov %esp,%eax - 101bd2: 50 push %eax - -00101bd3 : - 101bd3: b8 04 3e 10 00 mov $0x103e04,%eax - 101bd8: ff d0 call *%eax - 101bda: e9 09 fb ff ff jmp 1016e8 - -00101bdf : - 101bdf: 6a 00 push $0x0 - 101be1: 6a 1e push $0x1e - 101be3: 0f a8 push %gs - 101be5: 0f a0 push %fs - 101be7: 06 push %es - 101be8: 1e push %ds - 101be9: 60 pusha - 101bea: 66 b8 10 00 mov $0x10,%ax - 101bee: 8e d8 mov %eax,%ds - 101bf0: 8e c0 mov %eax,%es - 101bf2: 8e e0 mov %eax,%fs - 101bf4: 8e e8 mov %eax,%gs - 101bf6: 89 e0 mov %esp,%eax - 101bf8: 50 push %eax - -00101bf9 : - 101bf9: b8 04 3e 10 00 mov $0x103e04,%eax - 101bfe: ff d0 call *%eax - 101c00: e9 e3 fa ff ff jmp 1016e8 - -00101c05 : - 101c05: 6a 00 push $0x0 - 101c07: 6a 1f push $0x1f - 101c09: 0f a8 push %gs - 101c0b: 0f a0 push %fs - 101c0d: 06 push %es - 101c0e: 1e push %ds - 101c0f: 60 pusha - 101c10: 66 b8 10 00 mov $0x10,%ax - 101c14: 8e d8 mov %eax,%ds - 101c16: 8e c0 mov %eax,%es - 101c18: 8e e0 mov %eax,%fs - 101c1a: 8e e8 mov %eax,%gs - 101c1c: 89 e0 mov %esp,%eax - 101c1e: 50 push %eax - -00101c1f : - 101c1f: b8 04 3e 10 00 mov $0x103e04,%eax - 101c24: ff d0 call *%eax - 101c26: e9 bd fa ff ff jmp 1016e8 - -00101c2b : - 101c2b: 6a 00 push $0x0 - 101c2d: 6a 20 push $0x20 - 101c2f: 0f a8 push %gs - 101c31: 0f a0 push %fs - 101c33: 06 push %es - 101c34: 1e push %ds - 101c35: 60 pusha - 101c36: 66 b8 10 00 mov $0x10,%ax - 101c3a: 8e d8 mov %eax,%ds - 101c3c: 8e c0 mov %eax,%es - 101c3e: 8e e0 mov %eax,%fs - 101c40: 8e e8 mov %eax,%gs - 101c42: 89 e0 mov %esp,%eax - 101c44: 50 push %eax - -00101c45 : - 101c45: b8 04 3e 10 00 mov $0x103e04,%eax - 101c4a: ff d0 call *%eax - 101c4c: e9 97 fa ff ff jmp 1016e8 - -00101c51 : - 101c51: 6a 00 push $0x0 - 101c53: 6a 21 push $0x21 - 101c55: 0f a8 push %gs - 101c57: 0f a0 push %fs - 101c59: 06 push %es - 101c5a: 1e push %ds - 101c5b: 60 pusha - 101c5c: 66 b8 10 00 mov $0x10,%ax - 101c60: 8e d8 mov %eax,%ds - 101c62: 8e c0 mov %eax,%es - 101c64: 8e e0 mov %eax,%fs - 101c66: 8e e8 mov %eax,%gs - 101c68: 89 e0 mov %esp,%eax - 101c6a: 50 push %eax - -00101c6b : - 101c6b: b8 04 3e 10 00 mov $0x103e04,%eax - 101c70: ff d0 call *%eax - 101c72: e9 71 fa ff ff jmp 1016e8 - -00101c77 : - 101c77: 6a 00 push $0x0 - 101c79: 6a 22 push $0x22 - 101c7b: 0f a8 push %gs - 101c7d: 0f a0 push %fs - 101c7f: 06 push %es - 101c80: 1e push %ds - 101c81: 60 pusha - 101c82: 66 b8 10 00 mov $0x10,%ax - 101c86: 8e d8 mov %eax,%ds - 101c88: 8e c0 mov %eax,%es - 101c8a: 8e e0 mov %eax,%fs - 101c8c: 8e e8 mov %eax,%gs - 101c8e: 89 e0 mov %esp,%eax - 101c90: 50 push %eax - -00101c91 : - 101c91: b8 04 3e 10 00 mov $0x103e04,%eax - 101c96: ff d0 call *%eax - 101c98: e9 4b fa ff ff jmp 1016e8 - -00101c9d : - 101c9d: 6a 00 push $0x0 - 101c9f: 6a 23 push $0x23 - 101ca1: 0f a8 push %gs - 101ca3: 0f a0 push %fs - 101ca5: 06 push %es - 101ca6: 1e push %ds - 101ca7: 60 pusha - 101ca8: 66 b8 10 00 mov $0x10,%ax - 101cac: 8e d8 mov %eax,%ds - 101cae: 8e c0 mov %eax,%es - 101cb0: 8e e0 mov %eax,%fs - 101cb2: 8e e8 mov %eax,%gs - 101cb4: 89 e0 mov %esp,%eax - 101cb6: 50 push %eax - -00101cb7 : - 101cb7: b8 04 3e 10 00 mov $0x103e04,%eax - 101cbc: ff d0 call *%eax - 101cbe: e9 25 fa ff ff jmp 1016e8 - -00101cc3 : - 101cc3: 6a 00 push $0x0 - 101cc5: 6a 24 push $0x24 - 101cc7: 0f a8 push %gs - 101cc9: 0f a0 push %fs - 101ccb: 06 push %es - 101ccc: 1e push %ds - 101ccd: 60 pusha - 101cce: 66 b8 10 00 mov $0x10,%ax - 101cd2: 8e d8 mov %eax,%ds - 101cd4: 8e c0 mov %eax,%es - 101cd6: 8e e0 mov %eax,%fs - 101cd8: 8e e8 mov %eax,%gs - 101cda: 89 e0 mov %esp,%eax - 101cdc: 50 push %eax - -00101cdd : - 101cdd: b8 04 3e 10 00 mov $0x103e04,%eax - 101ce2: ff d0 call *%eax - 101ce4: e9 ff f9 ff ff jmp 1016e8 - -00101ce9 : - 101ce9: 6a 00 push $0x0 - 101ceb: 6a 25 push $0x25 - 101ced: 0f a8 push %gs - 101cef: 0f a0 push %fs - 101cf1: 06 push %es - 101cf2: 1e push %ds - 101cf3: 60 pusha - 101cf4: 66 b8 10 00 mov $0x10,%ax - 101cf8: 8e d8 mov %eax,%ds - 101cfa: 8e c0 mov %eax,%es - 101cfc: 8e e0 mov %eax,%fs - 101cfe: 8e e8 mov %eax,%gs - 101d00: 89 e0 mov %esp,%eax - 101d02: 50 push %eax - -00101d03 : - 101d03: b8 04 3e 10 00 mov $0x103e04,%eax - 101d08: ff d0 call *%eax - 101d0a: e9 d9 f9 ff ff jmp 1016e8 - -00101d0f : - 101d0f: 6a 00 push $0x0 - 101d11: 6a 26 push $0x26 - 101d13: 0f a8 push %gs - 101d15: 0f a0 push %fs - 101d17: 06 push %es - 101d18: 1e push %ds - 101d19: 60 pusha - 101d1a: 66 b8 10 00 mov $0x10,%ax - 101d1e: 8e d8 mov %eax,%ds - 101d20: 8e c0 mov %eax,%es - 101d22: 8e e0 mov %eax,%fs - 101d24: 8e e8 mov %eax,%gs - 101d26: 89 e0 mov %esp,%eax - 101d28: 50 push %eax - -00101d29 : - 101d29: b8 04 3e 10 00 mov $0x103e04,%eax - 101d2e: ff d0 call *%eax - 101d30: e9 b3 f9 ff ff jmp 1016e8 - -00101d35 : - 101d35: 6a 00 push $0x0 - 101d37: 6a 27 push $0x27 - 101d39: 0f a8 push %gs - 101d3b: 0f a0 push %fs - 101d3d: 06 push %es - 101d3e: 1e push %ds - 101d3f: 60 pusha - 101d40: 66 b8 10 00 mov $0x10,%ax - 101d44: 8e d8 mov %eax,%ds - 101d46: 8e c0 mov %eax,%es - 101d48: 8e e0 mov %eax,%fs - 101d4a: 8e e8 mov %eax,%gs - 101d4c: 89 e0 mov %esp,%eax - 101d4e: 50 push %eax - -00101d4f : - 101d4f: b8 04 3e 10 00 mov $0x103e04,%eax - 101d54: ff d0 call *%eax - 101d56: e9 8d f9 ff ff jmp 1016e8 - -00101d5b : - 101d5b: 6a 00 push $0x0 - 101d5d: 6a 28 push $0x28 - 101d5f: 0f a8 push %gs - 101d61: 0f a0 push %fs - 101d63: 06 push %es - 101d64: 1e push %ds - 101d65: 60 pusha - 101d66: 66 b8 10 00 mov $0x10,%ax - 101d6a: 8e d8 mov %eax,%ds - 101d6c: 8e c0 mov %eax,%es - 101d6e: 8e e0 mov %eax,%fs - 101d70: 8e e8 mov %eax,%gs - 101d72: 89 e0 mov %esp,%eax - 101d74: 50 push %eax - -00101d75 : - 101d75: b8 04 3e 10 00 mov $0x103e04,%eax - 101d7a: ff d0 call *%eax - 101d7c: e9 67 f9 ff ff jmp 1016e8 - -00101d81 : - 101d81: 6a 00 push $0x0 - 101d83: 6a 29 push $0x29 - 101d85: 0f a8 push %gs - 101d87: 0f a0 push %fs - 101d89: 06 push %es - 101d8a: 1e push %ds - 101d8b: 60 pusha - 101d8c: 66 b8 10 00 mov $0x10,%ax - 101d90: 8e d8 mov %eax,%ds - 101d92: 8e c0 mov %eax,%es - 101d94: 8e e0 mov %eax,%fs - 101d96: 8e e8 mov %eax,%gs - 101d98: 89 e0 mov %esp,%eax - 101d9a: 50 push %eax - -00101d9b : - 101d9b: b8 04 3e 10 00 mov $0x103e04,%eax - 101da0: ff d0 call *%eax - 101da2: e9 41 f9 ff ff jmp 1016e8 - -00101da7 : - 101da7: 6a 00 push $0x0 - 101da9: 6a 2a push $0x2a - 101dab: 0f a8 push %gs - 101dad: 0f a0 push %fs - 101daf: 06 push %es - 101db0: 1e push %ds - 101db1: 60 pusha - 101db2: 66 b8 10 00 mov $0x10,%ax - 101db6: 8e d8 mov %eax,%ds - 101db8: 8e c0 mov %eax,%es - 101dba: 8e e0 mov %eax,%fs - 101dbc: 8e e8 mov %eax,%gs - 101dbe: 89 e0 mov %esp,%eax - 101dc0: 50 push %eax - -00101dc1 : - 101dc1: b8 04 3e 10 00 mov $0x103e04,%eax - 101dc6: ff d0 call *%eax - 101dc8: e9 1b f9 ff ff jmp 1016e8 - -00101dcd : - 101dcd: 6a 00 push $0x0 - 101dcf: 6a 2b push $0x2b - 101dd1: 0f a8 push %gs - 101dd3: 0f a0 push %fs - 101dd5: 06 push %es - 101dd6: 1e push %ds - 101dd7: 60 pusha - 101dd8: 66 b8 10 00 mov $0x10,%ax - 101ddc: 8e d8 mov %eax,%ds - 101dde: 8e c0 mov %eax,%es - 101de0: 8e e0 mov %eax,%fs - 101de2: 8e e8 mov %eax,%gs - 101de4: 89 e0 mov %esp,%eax - 101de6: 50 push %eax - -00101de7 : - 101de7: b8 04 3e 10 00 mov $0x103e04,%eax - 101dec: ff d0 call *%eax - 101dee: e9 f5 f8 ff ff jmp 1016e8 - -00101df3 : - 101df3: 6a 00 push $0x0 - 101df5: 6a 2c push $0x2c - 101df7: 0f a8 push %gs - 101df9: 0f a0 push %fs - 101dfb: 06 push %es - 101dfc: 1e push %ds - 101dfd: 60 pusha - 101dfe: 66 b8 10 00 mov $0x10,%ax - 101e02: 8e d8 mov %eax,%ds - 101e04: 8e c0 mov %eax,%es - 101e06: 8e e0 mov %eax,%fs - 101e08: 8e e8 mov %eax,%gs - 101e0a: 89 e0 mov %esp,%eax - 101e0c: 50 push %eax - -00101e0d : - 101e0d: b8 04 3e 10 00 mov $0x103e04,%eax - 101e12: ff d0 call *%eax - 101e14: e9 cf f8 ff ff jmp 1016e8 - -00101e19 : - 101e19: 6a 00 push $0x0 - 101e1b: 6a 2d push $0x2d - 101e1d: 0f a8 push %gs - 101e1f: 0f a0 push %fs - 101e21: 06 push %es - 101e22: 1e push %ds - 101e23: 60 pusha - 101e24: 66 b8 10 00 mov $0x10,%ax - 101e28: 8e d8 mov %eax,%ds - 101e2a: 8e c0 mov %eax,%es - 101e2c: 8e e0 mov %eax,%fs - 101e2e: 8e e8 mov %eax,%gs - 101e30: 89 e0 mov %esp,%eax - 101e32: 50 push %eax - -00101e33 : - 101e33: b8 04 3e 10 00 mov $0x103e04,%eax - 101e38: ff d0 call *%eax - 101e3a: e9 a9 f8 ff ff jmp 1016e8 - -00101e3f : - 101e3f: 6a 00 push $0x0 - 101e41: 6a 2e push $0x2e - 101e43: 0f a8 push %gs - 101e45: 0f a0 push %fs - 101e47: 06 push %es - 101e48: 1e push %ds - 101e49: 60 pusha - 101e4a: 66 b8 10 00 mov $0x10,%ax - 101e4e: 8e d8 mov %eax,%ds - 101e50: 8e c0 mov %eax,%es - 101e52: 8e e0 mov %eax,%fs - 101e54: 8e e8 mov %eax,%gs - 101e56: 89 e0 mov %esp,%eax - 101e58: 50 push %eax - -00101e59 : - 101e59: b8 04 3e 10 00 mov $0x103e04,%eax - 101e5e: ff d0 call *%eax - 101e60: e9 83 f8 ff ff jmp 1016e8 - -00101e65 : - 101e65: 6a 00 push $0x0 - 101e67: 6a 2f push $0x2f - 101e69: 0f a8 push %gs - 101e6b: 0f a0 push %fs - 101e6d: 06 push %es - 101e6e: 1e push %ds - 101e6f: 60 pusha - 101e70: 66 b8 10 00 mov $0x10,%ax - 101e74: 8e d8 mov %eax,%ds - 101e76: 8e c0 mov %eax,%es - 101e78: 8e e0 mov %eax,%fs - 101e7a: 8e e8 mov %eax,%gs - 101e7c: 89 e0 mov %esp,%eax - 101e7e: 50 push %eax - -00101e7f : - 101e7f: b8 04 3e 10 00 mov $0x103e04,%eax - 101e84: ff d0 call *%eax - 101e86: e9 5d f8 ff ff jmp 1016e8 - -00101e8b : - 101e8b: 6a 00 push $0x0 - 101e8d: 6a 30 push $0x30 - 101e8f: 0f a8 push %gs - 101e91: 0f a0 push %fs - 101e93: 06 push %es - 101e94: 1e push %ds - 101e95: 60 pusha - 101e96: 66 b8 10 00 mov $0x10,%ax - 101e9a: 8e d8 mov %eax,%ds - 101e9c: 8e c0 mov %eax,%es - 101e9e: 8e e0 mov %eax,%fs - 101ea0: 8e e8 mov %eax,%gs - 101ea2: 89 e0 mov %esp,%eax - 101ea4: 50 push %eax - -00101ea5 : - 101ea5: b8 04 3e 10 00 mov $0x103e04,%eax - 101eaa: ff d0 call *%eax - 101eac: e9 37 f8 ff ff jmp 1016e8 - -00101eb1 : - 101eb1: 6a 00 push $0x0 - 101eb3: 6a 31 push $0x31 - 101eb5: 0f a8 push %gs - 101eb7: 0f a0 push %fs - 101eb9: 06 push %es - 101eba: 1e push %ds - 101ebb: 60 pusha - 101ebc: 66 b8 10 00 mov $0x10,%ax - 101ec0: 8e d8 mov %eax,%ds - 101ec2: 8e c0 mov %eax,%es - 101ec4: 8e e0 mov %eax,%fs - 101ec6: 8e e8 mov %eax,%gs - 101ec8: 89 e0 mov %esp,%eax - 101eca: 50 push %eax - -00101ecb : - 101ecb: b8 04 3e 10 00 mov $0x103e04,%eax - 101ed0: ff d0 call *%eax - 101ed2: e9 11 f8 ff ff jmp 1016e8 - -00101ed7 : - 101ed7: 6a 00 push $0x0 - 101ed9: 6a 32 push $0x32 - 101edb: 0f a8 push %gs - 101edd: 0f a0 push %fs - 101edf: 06 push %es - 101ee0: 1e push %ds - 101ee1: 60 pusha - 101ee2: 66 b8 10 00 mov $0x10,%ax - 101ee6: 8e d8 mov %eax,%ds - 101ee8: 8e c0 mov %eax,%es - 101eea: 8e e0 mov %eax,%fs - 101eec: 8e e8 mov %eax,%gs - 101eee: 89 e0 mov %esp,%eax - 101ef0: 50 push %eax - -00101ef1 : - 101ef1: b8 04 3e 10 00 mov $0x103e04,%eax - 101ef6: ff d0 call *%eax - 101ef8: e9 eb f7 ff ff jmp 1016e8 - -00101efd : - 101efd: 6a 00 push $0x0 - 101eff: 6a 33 push $0x33 - 101f01: 0f a8 push %gs - 101f03: 0f a0 push %fs - 101f05: 06 push %es - 101f06: 1e push %ds - 101f07: 60 pusha - 101f08: 66 b8 10 00 mov $0x10,%ax - 101f0c: 8e d8 mov %eax,%ds - 101f0e: 8e c0 mov %eax,%es - 101f10: 8e e0 mov %eax,%fs - 101f12: 8e e8 mov %eax,%gs - 101f14: 89 e0 mov %esp,%eax - 101f16: 50 push %eax - -00101f17 : - 101f17: b8 04 3e 10 00 mov $0x103e04,%eax - 101f1c: ff d0 call *%eax - 101f1e: e9 c5 f7 ff ff jmp 1016e8 - -00101f23 : - 101f23: 6a 00 push $0x0 - 101f25: 6a 34 push $0x34 - 101f27: 0f a8 push %gs - 101f29: 0f a0 push %fs - 101f2b: 06 push %es - 101f2c: 1e push %ds - 101f2d: 60 pusha - 101f2e: 66 b8 10 00 mov $0x10,%ax - 101f32: 8e d8 mov %eax,%ds - 101f34: 8e c0 mov %eax,%es - 101f36: 8e e0 mov %eax,%fs - 101f38: 8e e8 mov %eax,%gs - 101f3a: 89 e0 mov %esp,%eax - 101f3c: 50 push %eax - -00101f3d : - 101f3d: b8 04 3e 10 00 mov $0x103e04,%eax - 101f42: ff d0 call *%eax - 101f44: e9 9f f7 ff ff jmp 1016e8 - -00101f49 : - 101f49: 6a 00 push $0x0 - 101f4b: 6a 35 push $0x35 - 101f4d: 0f a8 push %gs - 101f4f: 0f a0 push %fs - 101f51: 06 push %es - 101f52: 1e push %ds - 101f53: 60 pusha - 101f54: 66 b8 10 00 mov $0x10,%ax - 101f58: 8e d8 mov %eax,%ds - 101f5a: 8e c0 mov %eax,%es - 101f5c: 8e e0 mov %eax,%fs - 101f5e: 8e e8 mov %eax,%gs - 101f60: 89 e0 mov %esp,%eax - 101f62: 50 push %eax - -00101f63 : - 101f63: b8 04 3e 10 00 mov $0x103e04,%eax - 101f68: ff d0 call *%eax - 101f6a: e9 79 f7 ff ff jmp 1016e8 - -00101f6f : - 101f6f: 6a 00 push $0x0 - 101f71: 6a 36 push $0x36 - 101f73: 0f a8 push %gs - 101f75: 0f a0 push %fs - 101f77: 06 push %es - 101f78: 1e push %ds - 101f79: 60 pusha - 101f7a: 66 b8 10 00 mov $0x10,%ax - 101f7e: 8e d8 mov %eax,%ds - 101f80: 8e c0 mov %eax,%es - 101f82: 8e e0 mov %eax,%fs - 101f84: 8e e8 mov %eax,%gs - 101f86: 89 e0 mov %esp,%eax - 101f88: 50 push %eax - -00101f89 : - 101f89: b8 04 3e 10 00 mov $0x103e04,%eax - 101f8e: ff d0 call *%eax - 101f90: e9 53 f7 ff ff jmp 1016e8 - -00101f95 : - 101f95: 6a 00 push $0x0 - 101f97: 6a 37 push $0x37 - 101f99: 0f a8 push %gs - 101f9b: 0f a0 push %fs - 101f9d: 06 push %es - 101f9e: 1e push %ds - 101f9f: 60 pusha - 101fa0: 66 b8 10 00 mov $0x10,%ax - 101fa4: 8e d8 mov %eax,%ds - 101fa6: 8e c0 mov %eax,%es - 101fa8: 8e e0 mov %eax,%fs - 101faa: 8e e8 mov %eax,%gs - 101fac: 89 e0 mov %esp,%eax - 101fae: 50 push %eax - -00101faf : - 101faf: b8 04 3e 10 00 mov $0x103e04,%eax - 101fb4: ff d0 call *%eax - 101fb6: e9 2d f7 ff ff jmp 1016e8 - -00101fbb : - 101fbb: 6a 00 push $0x0 - 101fbd: 6a 38 push $0x38 - 101fbf: 0f a8 push %gs - 101fc1: 0f a0 push %fs - 101fc3: 06 push %es - 101fc4: 1e push %ds - 101fc5: 60 pusha - 101fc6: 66 b8 10 00 mov $0x10,%ax - 101fca: 8e d8 mov %eax,%ds - 101fcc: 8e c0 mov %eax,%es - 101fce: 8e e0 mov %eax,%fs - 101fd0: 8e e8 mov %eax,%gs - 101fd2: 89 e0 mov %esp,%eax - 101fd4: 50 push %eax - -00101fd5 : - 101fd5: b8 04 3e 10 00 mov $0x103e04,%eax - 101fda: ff d0 call *%eax - 101fdc: e9 07 f7 ff ff jmp 1016e8 - -00101fe1 : - 101fe1: 6a 00 push $0x0 - 101fe3: 6a 39 push $0x39 - 101fe5: 0f a8 push %gs - 101fe7: 0f a0 push %fs - 101fe9: 06 push %es - 101fea: 1e push %ds - 101feb: 60 pusha - 101fec: 66 b8 10 00 mov $0x10,%ax - 101ff0: 8e d8 mov %eax,%ds - 101ff2: 8e c0 mov %eax,%es - 101ff4: 8e e0 mov %eax,%fs - 101ff6: 8e e8 mov %eax,%gs - 101ff8: 89 e0 mov %esp,%eax - 101ffa: 50 push %eax - -00101ffb : - 101ffb: b8 04 3e 10 00 mov $0x103e04,%eax - 102000: ff d0 call *%eax - 102002: e9 e1 f6 ff ff jmp 1016e8 - -00102007 : - 102007: 6a 00 push $0x0 - 102009: 6a 3a push $0x3a - 10200b: 0f a8 push %gs - 10200d: 0f a0 push %fs - 10200f: 06 push %es - 102010: 1e push %ds - 102011: 60 pusha - 102012: 66 b8 10 00 mov $0x10,%ax - 102016: 8e d8 mov %eax,%ds - 102018: 8e c0 mov %eax,%es - 10201a: 8e e0 mov %eax,%fs - 10201c: 8e e8 mov %eax,%gs - 10201e: 89 e0 mov %esp,%eax - 102020: 50 push %eax - -00102021 : - 102021: b8 04 3e 10 00 mov $0x103e04,%eax - 102026: ff d0 call *%eax - 102028: e9 bb f6 ff ff jmp 1016e8 - -0010202d : - 10202d: 6a 00 push $0x0 - 10202f: 6a 3b push $0x3b - 102031: 0f a8 push %gs - 102033: 0f a0 push %fs - 102035: 06 push %es - 102036: 1e push %ds - 102037: 60 pusha - 102038: 66 b8 10 00 mov $0x10,%ax - 10203c: 8e d8 mov %eax,%ds - 10203e: 8e c0 mov %eax,%es - 102040: 8e e0 mov %eax,%fs - 102042: 8e e8 mov %eax,%gs - 102044: 89 e0 mov %esp,%eax - 102046: 50 push %eax - -00102047 : - 102047: b8 04 3e 10 00 mov $0x103e04,%eax - 10204c: ff d0 call *%eax - 10204e: e9 95 f6 ff ff jmp 1016e8 - -00102053 : - 102053: 6a 00 push $0x0 - 102055: 6a 3c push $0x3c - 102057: 0f a8 push %gs - 102059: 0f a0 push %fs - 10205b: 06 push %es - 10205c: 1e push %ds - 10205d: 60 pusha - 10205e: 66 b8 10 00 mov $0x10,%ax - 102062: 8e d8 mov %eax,%ds - 102064: 8e c0 mov %eax,%es - 102066: 8e e0 mov %eax,%fs - 102068: 8e e8 mov %eax,%gs - 10206a: 89 e0 mov %esp,%eax - 10206c: 50 push %eax - -0010206d : - 10206d: b8 04 3e 10 00 mov $0x103e04,%eax - 102072: ff d0 call *%eax - 102074: e9 6f f6 ff ff jmp 1016e8 - -00102079 : - 102079: 6a 00 push $0x0 - 10207b: 6a 3d push $0x3d - 10207d: 0f a8 push %gs - 10207f: 0f a0 push %fs - 102081: 06 push %es - 102082: 1e push %ds - 102083: 60 pusha - 102084: 66 b8 10 00 mov $0x10,%ax - 102088: 8e d8 mov %eax,%ds - 10208a: 8e c0 mov %eax,%es - 10208c: 8e e0 mov %eax,%fs - 10208e: 8e e8 mov %eax,%gs - 102090: 89 e0 mov %esp,%eax - 102092: 50 push %eax - -00102093 : - 102093: b8 04 3e 10 00 mov $0x103e04,%eax - 102098: ff d0 call *%eax - 10209a: e9 49 f6 ff ff jmp 1016e8 - -0010209f : - 10209f: 6a 00 push $0x0 - 1020a1: 6a 3e push $0x3e - 1020a3: 0f a8 push %gs - 1020a5: 0f a0 push %fs - 1020a7: 06 push %es - 1020a8: 1e push %ds - 1020a9: 60 pusha - 1020aa: 66 b8 10 00 mov $0x10,%ax - 1020ae: 8e d8 mov %eax,%ds - 1020b0: 8e c0 mov %eax,%es - 1020b2: 8e e0 mov %eax,%fs - 1020b4: 8e e8 mov %eax,%gs - 1020b6: 89 e0 mov %esp,%eax - 1020b8: 50 push %eax - -001020b9 : - 1020b9: b8 04 3e 10 00 mov $0x103e04,%eax - 1020be: ff d0 call *%eax - 1020c0: e9 23 f6 ff ff jmp 1016e8 - -001020c5 : - 1020c5: 6a 00 push $0x0 - 1020c7: 6a 3f push $0x3f - 1020c9: 0f a8 push %gs - 1020cb: 0f a0 push %fs - 1020cd: 06 push %es - 1020ce: 1e push %ds - 1020cf: 60 pusha - 1020d0: 66 b8 10 00 mov $0x10,%ax - 1020d4: 8e d8 mov %eax,%ds - 1020d6: 8e c0 mov %eax,%es - 1020d8: 8e e0 mov %eax,%fs - 1020da: 8e e8 mov %eax,%gs - 1020dc: 89 e0 mov %esp,%eax - 1020de: 50 push %eax - -001020df : - 1020df: b8 04 3e 10 00 mov $0x103e04,%eax - 1020e4: ff d0 call *%eax - 1020e6: e9 fd f5 ff ff jmp 1016e8 - -001020eb : - 1020eb: 6a 00 push $0x0 - 1020ed: 6a 40 push $0x40 - 1020ef: 0f a8 push %gs - 1020f1: 0f a0 push %fs - 1020f3: 06 push %es - 1020f4: 1e push %ds - 1020f5: 60 pusha - 1020f6: 66 b8 10 00 mov $0x10,%ax - 1020fa: 8e d8 mov %eax,%ds - 1020fc: 8e c0 mov %eax,%es - 1020fe: 8e e0 mov %eax,%fs - 102100: 8e e8 mov %eax,%gs - 102102: 89 e0 mov %esp,%eax - 102104: 50 push %eax - -00102105 : - 102105: b8 04 3e 10 00 mov $0x103e04,%eax - 10210a: ff d0 call *%eax - 10210c: e9 d7 f5 ff ff jmp 1016e8 - -00102111 : - 102111: 6a 00 push $0x0 - 102113: 6a 41 push $0x41 - 102115: 0f a8 push %gs - 102117: 0f a0 push %fs - 102119: 06 push %es - 10211a: 1e push %ds - 10211b: 60 pusha - 10211c: 66 b8 10 00 mov $0x10,%ax - 102120: 8e d8 mov %eax,%ds - 102122: 8e c0 mov %eax,%es - 102124: 8e e0 mov %eax,%fs - 102126: 8e e8 mov %eax,%gs - 102128: 89 e0 mov %esp,%eax - 10212a: 50 push %eax - -0010212b : - 10212b: b8 04 3e 10 00 mov $0x103e04,%eax - 102130: ff d0 call *%eax - 102132: e9 b1 f5 ff ff jmp 1016e8 - -00102137 : - 102137: 6a 00 push $0x0 - 102139: 6a 42 push $0x42 - 10213b: 0f a8 push %gs - 10213d: 0f a0 push %fs - 10213f: 06 push %es - 102140: 1e push %ds - 102141: 60 pusha - 102142: 66 b8 10 00 mov $0x10,%ax - 102146: 8e d8 mov %eax,%ds - 102148: 8e c0 mov %eax,%es - 10214a: 8e e0 mov %eax,%fs - 10214c: 8e e8 mov %eax,%gs - 10214e: 89 e0 mov %esp,%eax - 102150: 50 push %eax - -00102151 : - 102151: b8 04 3e 10 00 mov $0x103e04,%eax - 102156: ff d0 call *%eax - 102158: e9 8b f5 ff ff jmp 1016e8 - -0010215d : - 10215d: 6a 00 push $0x0 - 10215f: 6a 43 push $0x43 - 102161: 0f a8 push %gs - 102163: 0f a0 push %fs - 102165: 06 push %es - 102166: 1e push %ds - 102167: 60 pusha - 102168: 66 b8 10 00 mov $0x10,%ax - 10216c: 8e d8 mov %eax,%ds - 10216e: 8e c0 mov %eax,%es - 102170: 8e e0 mov %eax,%fs - 102172: 8e e8 mov %eax,%gs - 102174: 89 e0 mov %esp,%eax - 102176: 50 push %eax - -00102177 : - 102177: b8 04 3e 10 00 mov $0x103e04,%eax - 10217c: ff d0 call *%eax - 10217e: e9 65 f5 ff ff jmp 1016e8 - -00102183 : - 102183: 6a 00 push $0x0 - 102185: 6a 44 push $0x44 - 102187: 0f a8 push %gs - 102189: 0f a0 push %fs - 10218b: 06 push %es - 10218c: 1e push %ds - 10218d: 60 pusha - 10218e: 66 b8 10 00 mov $0x10,%ax - 102192: 8e d8 mov %eax,%ds - 102194: 8e c0 mov %eax,%es - 102196: 8e e0 mov %eax,%fs - 102198: 8e e8 mov %eax,%gs - 10219a: 89 e0 mov %esp,%eax - 10219c: 50 push %eax - -0010219d : - 10219d: b8 04 3e 10 00 mov $0x103e04,%eax - 1021a2: ff d0 call *%eax - 1021a4: e9 3f f5 ff ff jmp 1016e8 - -001021a9 : - 1021a9: 6a 00 push $0x0 - 1021ab: 6a 45 push $0x45 - 1021ad: 0f a8 push %gs - 1021af: 0f a0 push %fs - 1021b1: 06 push %es - 1021b2: 1e push %ds - 1021b3: 60 pusha - 1021b4: 66 b8 10 00 mov $0x10,%ax - 1021b8: 8e d8 mov %eax,%ds - 1021ba: 8e c0 mov %eax,%es - 1021bc: 8e e0 mov %eax,%fs - 1021be: 8e e8 mov %eax,%gs - 1021c0: 89 e0 mov %esp,%eax - 1021c2: 50 push %eax - -001021c3 : - 1021c3: b8 04 3e 10 00 mov $0x103e04,%eax - 1021c8: ff d0 call *%eax - 1021ca: e9 19 f5 ff ff jmp 1016e8 - -001021cf : - 1021cf: 6a 00 push $0x0 - 1021d1: 6a 46 push $0x46 - 1021d3: 0f a8 push %gs - 1021d5: 0f a0 push %fs - 1021d7: 06 push %es - 1021d8: 1e push %ds - 1021d9: 60 pusha - 1021da: 66 b8 10 00 mov $0x10,%ax - 1021de: 8e d8 mov %eax,%ds - 1021e0: 8e c0 mov %eax,%es - 1021e2: 8e e0 mov %eax,%fs - 1021e4: 8e e8 mov %eax,%gs - 1021e6: 89 e0 mov %esp,%eax - 1021e8: 50 push %eax - -001021e9 : - 1021e9: b8 04 3e 10 00 mov $0x103e04,%eax - 1021ee: ff d0 call *%eax - 1021f0: e9 f3 f4 ff ff jmp 1016e8 - -001021f5 : - 1021f5: 6a 00 push $0x0 - 1021f7: 6a 47 push $0x47 - 1021f9: 0f a8 push %gs - 1021fb: 0f a0 push %fs - 1021fd: 06 push %es - 1021fe: 1e push %ds - 1021ff: 60 pusha - 102200: 66 b8 10 00 mov $0x10,%ax - 102204: 8e d8 mov %eax,%ds - 102206: 8e c0 mov %eax,%es - 102208: 8e e0 mov %eax,%fs - 10220a: 8e e8 mov %eax,%gs - 10220c: 89 e0 mov %esp,%eax - 10220e: 50 push %eax - -0010220f : - 10220f: b8 04 3e 10 00 mov $0x103e04,%eax - 102214: ff d0 call *%eax - 102216: e9 cd f4 ff ff jmp 1016e8 - -0010221b : - 10221b: 6a 00 push $0x0 - 10221d: 6a 48 push $0x48 - 10221f: 0f a8 push %gs - 102221: 0f a0 push %fs - 102223: 06 push %es - 102224: 1e push %ds - 102225: 60 pusha - 102226: 66 b8 10 00 mov $0x10,%ax - 10222a: 8e d8 mov %eax,%ds - 10222c: 8e c0 mov %eax,%es - 10222e: 8e e0 mov %eax,%fs - 102230: 8e e8 mov %eax,%gs - 102232: 89 e0 mov %esp,%eax - 102234: 50 push %eax - -00102235 : - 102235: b8 04 3e 10 00 mov $0x103e04,%eax - 10223a: ff d0 call *%eax - 10223c: e9 a7 f4 ff ff jmp 1016e8 - -00102241 : - 102241: 6a 00 push $0x0 - 102243: 6a 49 push $0x49 - 102245: 0f a8 push %gs - 102247: 0f a0 push %fs - 102249: 06 push %es - 10224a: 1e push %ds - 10224b: 60 pusha - 10224c: 66 b8 10 00 mov $0x10,%ax - 102250: 8e d8 mov %eax,%ds - 102252: 8e c0 mov %eax,%es - 102254: 8e e0 mov %eax,%fs - 102256: 8e e8 mov %eax,%gs - 102258: 89 e0 mov %esp,%eax - 10225a: 50 push %eax - -0010225b : - 10225b: b8 04 3e 10 00 mov $0x103e04,%eax - 102260: ff d0 call *%eax - 102262: e9 81 f4 ff ff jmp 1016e8 - -00102267 : - 102267: 6a 00 push $0x0 - 102269: 6a 4a push $0x4a - 10226b: 0f a8 push %gs - 10226d: 0f a0 push %fs - 10226f: 06 push %es - 102270: 1e push %ds - 102271: 60 pusha - 102272: 66 b8 10 00 mov $0x10,%ax - 102276: 8e d8 mov %eax,%ds - 102278: 8e c0 mov %eax,%es - 10227a: 8e e0 mov %eax,%fs - 10227c: 8e e8 mov %eax,%gs - 10227e: 89 e0 mov %esp,%eax - 102280: 50 push %eax - -00102281 : - 102281: b8 04 3e 10 00 mov $0x103e04,%eax - 102286: ff d0 call *%eax - 102288: e9 5b f4 ff ff jmp 1016e8 - -0010228d : - 10228d: 6a 00 push $0x0 - 10228f: 6a 4b push $0x4b - 102291: 0f a8 push %gs - 102293: 0f a0 push %fs - 102295: 06 push %es - 102296: 1e push %ds - 102297: 60 pusha - 102298: 66 b8 10 00 mov $0x10,%ax - 10229c: 8e d8 mov %eax,%ds - 10229e: 8e c0 mov %eax,%es - 1022a0: 8e e0 mov %eax,%fs - 1022a2: 8e e8 mov %eax,%gs - 1022a4: 89 e0 mov %esp,%eax - 1022a6: 50 push %eax - -001022a7 : - 1022a7: b8 04 3e 10 00 mov $0x103e04,%eax - 1022ac: ff d0 call *%eax - 1022ae: e9 35 f4 ff ff jmp 1016e8 - -001022b3 : - 1022b3: 6a 00 push $0x0 - 1022b5: 6a 4c push $0x4c - 1022b7: 0f a8 push %gs - 1022b9: 0f a0 push %fs - 1022bb: 06 push %es - 1022bc: 1e push %ds - 1022bd: 60 pusha - 1022be: 66 b8 10 00 mov $0x10,%ax - 1022c2: 8e d8 mov %eax,%ds - 1022c4: 8e c0 mov %eax,%es - 1022c6: 8e e0 mov %eax,%fs - 1022c8: 8e e8 mov %eax,%gs - 1022ca: 89 e0 mov %esp,%eax - 1022cc: 50 push %eax - -001022cd : - 1022cd: b8 04 3e 10 00 mov $0x103e04,%eax - 1022d2: ff d0 call *%eax - 1022d4: e9 0f f4 ff ff jmp 1016e8 - -001022d9 : - 1022d9: 6a 00 push $0x0 - 1022db: 6a 4d push $0x4d - 1022dd: 0f a8 push %gs - 1022df: 0f a0 push %fs - 1022e1: 06 push %es - 1022e2: 1e push %ds - 1022e3: 60 pusha - 1022e4: 66 b8 10 00 mov $0x10,%ax - 1022e8: 8e d8 mov %eax,%ds - 1022ea: 8e c0 mov %eax,%es - 1022ec: 8e e0 mov %eax,%fs - 1022ee: 8e e8 mov %eax,%gs - 1022f0: 89 e0 mov %esp,%eax - 1022f2: 50 push %eax - -001022f3 : - 1022f3: b8 04 3e 10 00 mov $0x103e04,%eax - 1022f8: ff d0 call *%eax - 1022fa: e9 e9 f3 ff ff jmp 1016e8 - -001022ff : - 1022ff: 6a 00 push $0x0 - 102301: 6a 4e push $0x4e - 102303: 0f a8 push %gs - 102305: 0f a0 push %fs - 102307: 06 push %es - 102308: 1e push %ds - 102309: 60 pusha - 10230a: 66 b8 10 00 mov $0x10,%ax - 10230e: 8e d8 mov %eax,%ds - 102310: 8e c0 mov %eax,%es - 102312: 8e e0 mov %eax,%fs - 102314: 8e e8 mov %eax,%gs - 102316: 89 e0 mov %esp,%eax - 102318: 50 push %eax - -00102319 : - 102319: b8 04 3e 10 00 mov $0x103e04,%eax - 10231e: ff d0 call *%eax - 102320: e9 c3 f3 ff ff jmp 1016e8 - -00102325 : - 102325: 6a 00 push $0x0 - 102327: 6a 4f push $0x4f - 102329: 0f a8 push %gs - 10232b: 0f a0 push %fs - 10232d: 06 push %es - 10232e: 1e push %ds - 10232f: 60 pusha - 102330: 66 b8 10 00 mov $0x10,%ax - 102334: 8e d8 mov %eax,%ds - 102336: 8e c0 mov %eax,%es - 102338: 8e e0 mov %eax,%fs - 10233a: 8e e8 mov %eax,%gs - 10233c: 89 e0 mov %esp,%eax - 10233e: 50 push %eax - -0010233f : - 10233f: b8 04 3e 10 00 mov $0x103e04,%eax - 102344: ff d0 call *%eax - 102346: e9 9d f3 ff ff jmp 1016e8 - -0010234b : - 10234b: 6a 00 push $0x0 - 10234d: 6a 50 push $0x50 - 10234f: 0f a8 push %gs - 102351: 0f a0 push %fs - 102353: 06 push %es - 102354: 1e push %ds - 102355: 60 pusha - 102356: 66 b8 10 00 mov $0x10,%ax - 10235a: 8e d8 mov %eax,%ds - 10235c: 8e c0 mov %eax,%es - 10235e: 8e e0 mov %eax,%fs - 102360: 8e e8 mov %eax,%gs - 102362: 89 e0 mov %esp,%eax - 102364: 50 push %eax - -00102365 : - 102365: b8 04 3e 10 00 mov $0x103e04,%eax - 10236a: ff d0 call *%eax - 10236c: e9 77 f3 ff ff jmp 1016e8 - -00102371 : - 102371: 6a 00 push $0x0 - 102373: 6a 51 push $0x51 - 102375: 0f a8 push %gs - 102377: 0f a0 push %fs - 102379: 06 push %es - 10237a: 1e push %ds - 10237b: 60 pusha - 10237c: 66 b8 10 00 mov $0x10,%ax - 102380: 8e d8 mov %eax,%ds - 102382: 8e c0 mov %eax,%es - 102384: 8e e0 mov %eax,%fs - 102386: 8e e8 mov %eax,%gs - 102388: 89 e0 mov %esp,%eax - 10238a: 50 push %eax - -0010238b : - 10238b: b8 04 3e 10 00 mov $0x103e04,%eax - 102390: ff d0 call *%eax - 102392: e9 51 f3 ff ff jmp 1016e8 - -00102397 : - 102397: 6a 00 push $0x0 - 102399: 6a 52 push $0x52 - 10239b: 0f a8 push %gs - 10239d: 0f a0 push %fs - 10239f: 06 push %es - 1023a0: 1e push %ds - 1023a1: 60 pusha - 1023a2: 66 b8 10 00 mov $0x10,%ax - 1023a6: 8e d8 mov %eax,%ds - 1023a8: 8e c0 mov %eax,%es - 1023aa: 8e e0 mov %eax,%fs - 1023ac: 8e e8 mov %eax,%gs - 1023ae: 89 e0 mov %esp,%eax - 1023b0: 50 push %eax - -001023b1 : - 1023b1: b8 04 3e 10 00 mov $0x103e04,%eax - 1023b6: ff d0 call *%eax - 1023b8: e9 2b f3 ff ff jmp 1016e8 - -001023bd : - 1023bd: 6a 00 push $0x0 - 1023bf: 6a 53 push $0x53 - 1023c1: 0f a8 push %gs - 1023c3: 0f a0 push %fs - 1023c5: 06 push %es - 1023c6: 1e push %ds - 1023c7: 60 pusha - 1023c8: 66 b8 10 00 mov $0x10,%ax - 1023cc: 8e d8 mov %eax,%ds - 1023ce: 8e c0 mov %eax,%es - 1023d0: 8e e0 mov %eax,%fs - 1023d2: 8e e8 mov %eax,%gs - 1023d4: 89 e0 mov %esp,%eax - 1023d6: 50 push %eax - -001023d7 : - 1023d7: b8 04 3e 10 00 mov $0x103e04,%eax - 1023dc: ff d0 call *%eax - 1023de: e9 05 f3 ff ff jmp 1016e8 - -001023e3 : - 1023e3: 6a 00 push $0x0 - 1023e5: 6a 54 push $0x54 - 1023e7: 0f a8 push %gs - 1023e9: 0f a0 push %fs - 1023eb: 06 push %es - 1023ec: 1e push %ds - 1023ed: 60 pusha - 1023ee: 66 b8 10 00 mov $0x10,%ax - 1023f2: 8e d8 mov %eax,%ds - 1023f4: 8e c0 mov %eax,%es - 1023f6: 8e e0 mov %eax,%fs - 1023f8: 8e e8 mov %eax,%gs - 1023fa: 89 e0 mov %esp,%eax - 1023fc: 50 push %eax - -001023fd : - 1023fd: b8 04 3e 10 00 mov $0x103e04,%eax - 102402: ff d0 call *%eax - 102404: e9 df f2 ff ff jmp 1016e8 - -00102409 : - 102409: 6a 00 push $0x0 - 10240b: 6a 55 push $0x55 - 10240d: 0f a8 push %gs - 10240f: 0f a0 push %fs - 102411: 06 push %es - 102412: 1e push %ds - 102413: 60 pusha - 102414: 66 b8 10 00 mov $0x10,%ax - 102418: 8e d8 mov %eax,%ds - 10241a: 8e c0 mov %eax,%es - 10241c: 8e e0 mov %eax,%fs - 10241e: 8e e8 mov %eax,%gs - 102420: 89 e0 mov %esp,%eax - 102422: 50 push %eax - -00102423 : - 102423: b8 04 3e 10 00 mov $0x103e04,%eax - 102428: ff d0 call *%eax - 10242a: e9 b9 f2 ff ff jmp 1016e8 - -0010242f : - 10242f: 6a 00 push $0x0 - 102431: 6a 56 push $0x56 - 102433: 0f a8 push %gs - 102435: 0f a0 push %fs - 102437: 06 push %es - 102438: 1e push %ds - 102439: 60 pusha - 10243a: 66 b8 10 00 mov $0x10,%ax - 10243e: 8e d8 mov %eax,%ds - 102440: 8e c0 mov %eax,%es - 102442: 8e e0 mov %eax,%fs - 102444: 8e e8 mov %eax,%gs - 102446: 89 e0 mov %esp,%eax - 102448: 50 push %eax - -00102449 : - 102449: b8 04 3e 10 00 mov $0x103e04,%eax - 10244e: ff d0 call *%eax - 102450: e9 93 f2 ff ff jmp 1016e8 - -00102455 : - 102455: 6a 00 push $0x0 - 102457: 6a 57 push $0x57 - 102459: 0f a8 push %gs - 10245b: 0f a0 push %fs - 10245d: 06 push %es - 10245e: 1e push %ds - 10245f: 60 pusha - 102460: 66 b8 10 00 mov $0x10,%ax - 102464: 8e d8 mov %eax,%ds - 102466: 8e c0 mov %eax,%es - 102468: 8e e0 mov %eax,%fs - 10246a: 8e e8 mov %eax,%gs - 10246c: 89 e0 mov %esp,%eax - 10246e: 50 push %eax - -0010246f : - 10246f: b8 04 3e 10 00 mov $0x103e04,%eax - 102474: ff d0 call *%eax - 102476: e9 6d f2 ff ff jmp 1016e8 - -0010247b : - 10247b: 6a 00 push $0x0 - 10247d: 6a 58 push $0x58 - 10247f: 0f a8 push %gs - 102481: 0f a0 push %fs - 102483: 06 push %es - 102484: 1e push %ds - 102485: 60 pusha - 102486: 66 b8 10 00 mov $0x10,%ax - 10248a: 8e d8 mov %eax,%ds - 10248c: 8e c0 mov %eax,%es - 10248e: 8e e0 mov %eax,%fs - 102490: 8e e8 mov %eax,%gs - 102492: 89 e0 mov %esp,%eax - 102494: 50 push %eax - -00102495 : - 102495: b8 04 3e 10 00 mov $0x103e04,%eax - 10249a: ff d0 call *%eax - 10249c: e9 47 f2 ff ff jmp 1016e8 - -001024a1 : - 1024a1: 6a 00 push $0x0 - 1024a3: 6a 59 push $0x59 - 1024a5: 0f a8 push %gs - 1024a7: 0f a0 push %fs - 1024a9: 06 push %es - 1024aa: 1e push %ds - 1024ab: 60 pusha - 1024ac: 66 b8 10 00 mov $0x10,%ax - 1024b0: 8e d8 mov %eax,%ds - 1024b2: 8e c0 mov %eax,%es - 1024b4: 8e e0 mov %eax,%fs - 1024b6: 8e e8 mov %eax,%gs - 1024b8: 89 e0 mov %esp,%eax - 1024ba: 50 push %eax - -001024bb : - 1024bb: b8 04 3e 10 00 mov $0x103e04,%eax - 1024c0: ff d0 call *%eax - 1024c2: e9 21 f2 ff ff jmp 1016e8 - -001024c7 : - 1024c7: 6a 00 push $0x0 - 1024c9: 6a 5a push $0x5a - 1024cb: 0f a8 push %gs - 1024cd: 0f a0 push %fs - 1024cf: 06 push %es - 1024d0: 1e push %ds - 1024d1: 60 pusha - 1024d2: 66 b8 10 00 mov $0x10,%ax - 1024d6: 8e d8 mov %eax,%ds - 1024d8: 8e c0 mov %eax,%es - 1024da: 8e e0 mov %eax,%fs - 1024dc: 8e e8 mov %eax,%gs - 1024de: 89 e0 mov %esp,%eax - 1024e0: 50 push %eax - -001024e1 : - 1024e1: b8 04 3e 10 00 mov $0x103e04,%eax - 1024e6: ff d0 call *%eax - 1024e8: e9 fb f1 ff ff jmp 1016e8 - -001024ed : - 1024ed: 6a 00 push $0x0 - 1024ef: 6a 5b push $0x5b - 1024f1: 0f a8 push %gs - 1024f3: 0f a0 push %fs - 1024f5: 06 push %es - 1024f6: 1e push %ds - 1024f7: 60 pusha - 1024f8: 66 b8 10 00 mov $0x10,%ax - 1024fc: 8e d8 mov %eax,%ds - 1024fe: 8e c0 mov %eax,%es - 102500: 8e e0 mov %eax,%fs - 102502: 8e e8 mov %eax,%gs - 102504: 89 e0 mov %esp,%eax - 102506: 50 push %eax - -00102507 : - 102507: b8 04 3e 10 00 mov $0x103e04,%eax - 10250c: ff d0 call *%eax - 10250e: e9 d5 f1 ff ff jmp 1016e8 - -00102513 : - 102513: 6a 00 push $0x0 - 102515: 6a 5c push $0x5c - 102517: 0f a8 push %gs - 102519: 0f a0 push %fs - 10251b: 06 push %es - 10251c: 1e push %ds - 10251d: 60 pusha - 10251e: 66 b8 10 00 mov $0x10,%ax - 102522: 8e d8 mov %eax,%ds - 102524: 8e c0 mov %eax,%es - 102526: 8e e0 mov %eax,%fs - 102528: 8e e8 mov %eax,%gs - 10252a: 89 e0 mov %esp,%eax - 10252c: 50 push %eax - -0010252d : - 10252d: b8 04 3e 10 00 mov $0x103e04,%eax - 102532: ff d0 call *%eax - 102534: e9 af f1 ff ff jmp 1016e8 - -00102539 : - 102539: 6a 00 push $0x0 - 10253b: 6a 5d push $0x5d - 10253d: 0f a8 push %gs - 10253f: 0f a0 push %fs - 102541: 06 push %es - 102542: 1e push %ds - 102543: 60 pusha - 102544: 66 b8 10 00 mov $0x10,%ax - 102548: 8e d8 mov %eax,%ds - 10254a: 8e c0 mov %eax,%es - 10254c: 8e e0 mov %eax,%fs - 10254e: 8e e8 mov %eax,%gs - 102550: 89 e0 mov %esp,%eax - 102552: 50 push %eax - -00102553 : - 102553: b8 04 3e 10 00 mov $0x103e04,%eax - 102558: ff d0 call *%eax - 10255a: e9 89 f1 ff ff jmp 1016e8 - -0010255f : - 10255f: 6a 00 push $0x0 - 102561: 6a 5e push $0x5e - 102563: 0f a8 push %gs - 102565: 0f a0 push %fs - 102567: 06 push %es - 102568: 1e push %ds - 102569: 60 pusha - 10256a: 66 b8 10 00 mov $0x10,%ax - 10256e: 8e d8 mov %eax,%ds - 102570: 8e c0 mov %eax,%es - 102572: 8e e0 mov %eax,%fs - 102574: 8e e8 mov %eax,%gs - 102576: 89 e0 mov %esp,%eax - 102578: 50 push %eax - -00102579 : - 102579: b8 04 3e 10 00 mov $0x103e04,%eax - 10257e: ff d0 call *%eax - 102580: e9 63 f1 ff ff jmp 1016e8 - -00102585 : - 102585: 6a 00 push $0x0 - 102587: 6a 5f push $0x5f - 102589: 0f a8 push %gs - 10258b: 0f a0 push %fs - 10258d: 06 push %es - 10258e: 1e push %ds - 10258f: 60 pusha - 102590: 66 b8 10 00 mov $0x10,%ax - 102594: 8e d8 mov %eax,%ds - 102596: 8e c0 mov %eax,%es - 102598: 8e e0 mov %eax,%fs - 10259a: 8e e8 mov %eax,%gs - 10259c: 89 e0 mov %esp,%eax - 10259e: 50 push %eax - -0010259f : - 10259f: b8 04 3e 10 00 mov $0x103e04,%eax - 1025a4: ff d0 call *%eax - 1025a6: e9 3d f1 ff ff jmp 1016e8 - -001025ab : - 1025ab: 6a 00 push $0x0 - 1025ad: 6a 60 push $0x60 - 1025af: 0f a8 push %gs - 1025b1: 0f a0 push %fs - 1025b3: 06 push %es - 1025b4: 1e push %ds - 1025b5: 60 pusha - 1025b6: 66 b8 10 00 mov $0x10,%ax - 1025ba: 8e d8 mov %eax,%ds - 1025bc: 8e c0 mov %eax,%es - 1025be: 8e e0 mov %eax,%fs - 1025c0: 8e e8 mov %eax,%gs - 1025c2: 89 e0 mov %esp,%eax - 1025c4: 50 push %eax - -001025c5 : - 1025c5: b8 04 3e 10 00 mov $0x103e04,%eax - 1025ca: ff d0 call *%eax - 1025cc: e9 17 f1 ff ff jmp 1016e8 - -001025d1 : - 1025d1: 6a 00 push $0x0 - 1025d3: 6a 61 push $0x61 - 1025d5: 0f a8 push %gs - 1025d7: 0f a0 push %fs - 1025d9: 06 push %es - 1025da: 1e push %ds - 1025db: 60 pusha - 1025dc: 66 b8 10 00 mov $0x10,%ax - 1025e0: 8e d8 mov %eax,%ds - 1025e2: 8e c0 mov %eax,%es - 1025e4: 8e e0 mov %eax,%fs - 1025e6: 8e e8 mov %eax,%gs - 1025e8: 89 e0 mov %esp,%eax - 1025ea: 50 push %eax - -001025eb : - 1025eb: b8 04 3e 10 00 mov $0x103e04,%eax - 1025f0: ff d0 call *%eax - 1025f2: e9 f1 f0 ff ff jmp 1016e8 - -001025f7 : - 1025f7: 6a 00 push $0x0 - 1025f9: 6a 62 push $0x62 - 1025fb: 0f a8 push %gs - 1025fd: 0f a0 push %fs - 1025ff: 06 push %es - 102600: 1e push %ds - 102601: 60 pusha - 102602: 66 b8 10 00 mov $0x10,%ax - 102606: 8e d8 mov %eax,%ds - 102608: 8e c0 mov %eax,%es - 10260a: 8e e0 mov %eax,%fs - 10260c: 8e e8 mov %eax,%gs - 10260e: 89 e0 mov %esp,%eax - 102610: 50 push %eax - -00102611 : - 102611: b8 04 3e 10 00 mov $0x103e04,%eax - 102616: ff d0 call *%eax - 102618: e9 cb f0 ff ff jmp 1016e8 - -0010261d : - 10261d: 6a 00 push $0x0 - 10261f: 6a 63 push $0x63 - 102621: 0f a8 push %gs - 102623: 0f a0 push %fs - 102625: 06 push %es - 102626: 1e push %ds - 102627: 60 pusha - 102628: 66 b8 10 00 mov $0x10,%ax - 10262c: 8e d8 mov %eax,%ds - 10262e: 8e c0 mov %eax,%es - 102630: 8e e0 mov %eax,%fs - 102632: 8e e8 mov %eax,%gs - 102634: 89 e0 mov %esp,%eax - 102636: 50 push %eax - -00102637 : - 102637: b8 04 3e 10 00 mov $0x103e04,%eax - 10263c: ff d0 call *%eax - 10263e: e9 a5 f0 ff ff jmp 1016e8 - -00102643 : - 102643: 6a 00 push $0x0 - 102645: 6a 64 push $0x64 - 102647: 0f a8 push %gs - 102649: 0f a0 push %fs - 10264b: 06 push %es - 10264c: 1e push %ds - 10264d: 60 pusha - 10264e: 66 b8 10 00 mov $0x10,%ax - 102652: 8e d8 mov %eax,%ds - 102654: 8e c0 mov %eax,%es - 102656: 8e e0 mov %eax,%fs - 102658: 8e e8 mov %eax,%gs - 10265a: 89 e0 mov %esp,%eax - 10265c: 50 push %eax - -0010265d : - 10265d: b8 04 3e 10 00 mov $0x103e04,%eax - 102662: ff d0 call *%eax - 102664: e9 7f f0 ff ff jmp 1016e8 - -00102669 : - 102669: 6a 00 push $0x0 - 10266b: 6a 65 push $0x65 - 10266d: 0f a8 push %gs - 10266f: 0f a0 push %fs - 102671: 06 push %es - 102672: 1e push %ds - 102673: 60 pusha - 102674: 66 b8 10 00 mov $0x10,%ax - 102678: 8e d8 mov %eax,%ds - 10267a: 8e c0 mov %eax,%es - 10267c: 8e e0 mov %eax,%fs - 10267e: 8e e8 mov %eax,%gs - 102680: 89 e0 mov %esp,%eax - 102682: 50 push %eax - -00102683 : - 102683: b8 04 3e 10 00 mov $0x103e04,%eax - 102688: ff d0 call *%eax - 10268a: e9 59 f0 ff ff jmp 1016e8 - -0010268f : - 10268f: 6a 00 push $0x0 - 102691: 6a 66 push $0x66 - 102693: 0f a8 push %gs - 102695: 0f a0 push %fs - 102697: 06 push %es - 102698: 1e push %ds - 102699: 60 pusha - 10269a: 66 b8 10 00 mov $0x10,%ax - 10269e: 8e d8 mov %eax,%ds - 1026a0: 8e c0 mov %eax,%es - 1026a2: 8e e0 mov %eax,%fs - 1026a4: 8e e8 mov %eax,%gs - 1026a6: 89 e0 mov %esp,%eax - 1026a8: 50 push %eax - -001026a9 : - 1026a9: b8 04 3e 10 00 mov $0x103e04,%eax - 1026ae: ff d0 call *%eax - 1026b0: e9 33 f0 ff ff jmp 1016e8 - -001026b5 : - 1026b5: 6a 00 push $0x0 - 1026b7: 6a 67 push $0x67 - 1026b9: 0f a8 push %gs - 1026bb: 0f a0 push %fs - 1026bd: 06 push %es - 1026be: 1e push %ds - 1026bf: 60 pusha - 1026c0: 66 b8 10 00 mov $0x10,%ax - 1026c4: 8e d8 mov %eax,%ds - 1026c6: 8e c0 mov %eax,%es - 1026c8: 8e e0 mov %eax,%fs - 1026ca: 8e e8 mov %eax,%gs - 1026cc: 89 e0 mov %esp,%eax - 1026ce: 50 push %eax - -001026cf : - 1026cf: b8 04 3e 10 00 mov $0x103e04,%eax - 1026d4: ff d0 call *%eax - 1026d6: e9 0d f0 ff ff jmp 1016e8 - -001026db : - 1026db: 6a 00 push $0x0 - 1026dd: 6a 68 push $0x68 - 1026df: 0f a8 push %gs - 1026e1: 0f a0 push %fs - 1026e3: 06 push %es - 1026e4: 1e push %ds - 1026e5: 60 pusha - 1026e6: 66 b8 10 00 mov $0x10,%ax - 1026ea: 8e d8 mov %eax,%ds - 1026ec: 8e c0 mov %eax,%es - 1026ee: 8e e0 mov %eax,%fs - 1026f0: 8e e8 mov %eax,%gs - 1026f2: 89 e0 mov %esp,%eax - 1026f4: 50 push %eax - -001026f5 : - 1026f5: b8 04 3e 10 00 mov $0x103e04,%eax - 1026fa: ff d0 call *%eax - 1026fc: e9 e7 ef ff ff jmp 1016e8 - -00102701 : - 102701: 6a 00 push $0x0 - 102703: 6a 69 push $0x69 - 102705: 0f a8 push %gs - 102707: 0f a0 push %fs - 102709: 06 push %es - 10270a: 1e push %ds - 10270b: 60 pusha - 10270c: 66 b8 10 00 mov $0x10,%ax - 102710: 8e d8 mov %eax,%ds - 102712: 8e c0 mov %eax,%es - 102714: 8e e0 mov %eax,%fs - 102716: 8e e8 mov %eax,%gs - 102718: 89 e0 mov %esp,%eax - 10271a: 50 push %eax - -0010271b : - 10271b: b8 04 3e 10 00 mov $0x103e04,%eax - 102720: ff d0 call *%eax - 102722: e9 c1 ef ff ff jmp 1016e8 - -00102727 : - 102727: 6a 00 push $0x0 - 102729: 6a 6a push $0x6a - 10272b: 0f a8 push %gs - 10272d: 0f a0 push %fs - 10272f: 06 push %es - 102730: 1e push %ds - 102731: 60 pusha - 102732: 66 b8 10 00 mov $0x10,%ax - 102736: 8e d8 mov %eax,%ds - 102738: 8e c0 mov %eax,%es - 10273a: 8e e0 mov %eax,%fs - 10273c: 8e e8 mov %eax,%gs - 10273e: 89 e0 mov %esp,%eax - 102740: 50 push %eax - -00102741 : - 102741: b8 04 3e 10 00 mov $0x103e04,%eax - 102746: ff d0 call *%eax - 102748: e9 9b ef ff ff jmp 1016e8 - -0010274d : - 10274d: 6a 00 push $0x0 - 10274f: 6a 6b push $0x6b - 102751: 0f a8 push %gs - 102753: 0f a0 push %fs - 102755: 06 push %es - 102756: 1e push %ds - 102757: 60 pusha - 102758: 66 b8 10 00 mov $0x10,%ax - 10275c: 8e d8 mov %eax,%ds - 10275e: 8e c0 mov %eax,%es - 102760: 8e e0 mov %eax,%fs - 102762: 8e e8 mov %eax,%gs - 102764: 89 e0 mov %esp,%eax - 102766: 50 push %eax - -00102767 : - 102767: b8 04 3e 10 00 mov $0x103e04,%eax - 10276c: ff d0 call *%eax - 10276e: e9 75 ef ff ff jmp 1016e8 - -00102773 : - 102773: 6a 00 push $0x0 - 102775: 6a 6c push $0x6c - 102777: 0f a8 push %gs - 102779: 0f a0 push %fs - 10277b: 06 push %es - 10277c: 1e push %ds - 10277d: 60 pusha - 10277e: 66 b8 10 00 mov $0x10,%ax - 102782: 8e d8 mov %eax,%ds - 102784: 8e c0 mov %eax,%es - 102786: 8e e0 mov %eax,%fs - 102788: 8e e8 mov %eax,%gs - 10278a: 89 e0 mov %esp,%eax - 10278c: 50 push %eax - -0010278d : - 10278d: b8 04 3e 10 00 mov $0x103e04,%eax - 102792: ff d0 call *%eax - 102794: e9 4f ef ff ff jmp 1016e8 - -00102799 : - 102799: 6a 00 push $0x0 - 10279b: 6a 6d push $0x6d - 10279d: 0f a8 push %gs - 10279f: 0f a0 push %fs - 1027a1: 06 push %es - 1027a2: 1e push %ds - 1027a3: 60 pusha - 1027a4: 66 b8 10 00 mov $0x10,%ax - 1027a8: 8e d8 mov %eax,%ds - 1027aa: 8e c0 mov %eax,%es - 1027ac: 8e e0 mov %eax,%fs - 1027ae: 8e e8 mov %eax,%gs - 1027b0: 89 e0 mov %esp,%eax - 1027b2: 50 push %eax - -001027b3 : - 1027b3: b8 04 3e 10 00 mov $0x103e04,%eax - 1027b8: ff d0 call *%eax - 1027ba: e9 29 ef ff ff jmp 1016e8 - -001027bf : - 1027bf: 6a 00 push $0x0 - 1027c1: 6a 6e push $0x6e - 1027c3: 0f a8 push %gs - 1027c5: 0f a0 push %fs - 1027c7: 06 push %es - 1027c8: 1e push %ds - 1027c9: 60 pusha - 1027ca: 66 b8 10 00 mov $0x10,%ax - 1027ce: 8e d8 mov %eax,%ds - 1027d0: 8e c0 mov %eax,%es - 1027d2: 8e e0 mov %eax,%fs - 1027d4: 8e e8 mov %eax,%gs - 1027d6: 89 e0 mov %esp,%eax - 1027d8: 50 push %eax - -001027d9 : - 1027d9: b8 04 3e 10 00 mov $0x103e04,%eax - 1027de: ff d0 call *%eax - 1027e0: e9 03 ef ff ff jmp 1016e8 - -001027e5 : - 1027e5: 6a 00 push $0x0 - 1027e7: 6a 6f push $0x6f - 1027e9: 0f a8 push %gs - 1027eb: 0f a0 push %fs - 1027ed: 06 push %es - 1027ee: 1e push %ds - 1027ef: 60 pusha - 1027f0: 66 b8 10 00 mov $0x10,%ax - 1027f4: 8e d8 mov %eax,%ds - 1027f6: 8e c0 mov %eax,%es - 1027f8: 8e e0 mov %eax,%fs - 1027fa: 8e e8 mov %eax,%gs - 1027fc: 89 e0 mov %esp,%eax - 1027fe: 50 push %eax - -001027ff : - 1027ff: b8 04 3e 10 00 mov $0x103e04,%eax - 102804: ff d0 call *%eax - 102806: e9 dd ee ff ff jmp 1016e8 - -0010280b : - 10280b: 6a 00 push $0x0 - 10280d: 6a 70 push $0x70 - 10280f: 0f a8 push %gs - 102811: 0f a0 push %fs - 102813: 06 push %es - 102814: 1e push %ds - 102815: 60 pusha - 102816: 66 b8 10 00 mov $0x10,%ax - 10281a: 8e d8 mov %eax,%ds - 10281c: 8e c0 mov %eax,%es - 10281e: 8e e0 mov %eax,%fs - 102820: 8e e8 mov %eax,%gs - 102822: 89 e0 mov %esp,%eax - 102824: 50 push %eax - -00102825 : - 102825: b8 04 3e 10 00 mov $0x103e04,%eax - 10282a: ff d0 call *%eax - 10282c: e9 b7 ee ff ff jmp 1016e8 - -00102831 : - 102831: 6a 00 push $0x0 - 102833: 6a 71 push $0x71 - 102835: 0f a8 push %gs - 102837: 0f a0 push %fs - 102839: 06 push %es - 10283a: 1e push %ds - 10283b: 60 pusha - 10283c: 66 b8 10 00 mov $0x10,%ax - 102840: 8e d8 mov %eax,%ds - 102842: 8e c0 mov %eax,%es - 102844: 8e e0 mov %eax,%fs - 102846: 8e e8 mov %eax,%gs - 102848: 89 e0 mov %esp,%eax - 10284a: 50 push %eax - -0010284b : - 10284b: b8 04 3e 10 00 mov $0x103e04,%eax - 102850: ff d0 call *%eax - 102852: e9 91 ee ff ff jmp 1016e8 - -00102857 : - 102857: 6a 00 push $0x0 - 102859: 6a 72 push $0x72 - 10285b: 0f a8 push %gs - 10285d: 0f a0 push %fs - 10285f: 06 push %es - 102860: 1e push %ds - 102861: 60 pusha - 102862: 66 b8 10 00 mov $0x10,%ax - 102866: 8e d8 mov %eax,%ds - 102868: 8e c0 mov %eax,%es - 10286a: 8e e0 mov %eax,%fs - 10286c: 8e e8 mov %eax,%gs - 10286e: 89 e0 mov %esp,%eax - 102870: 50 push %eax - -00102871 : - 102871: b8 04 3e 10 00 mov $0x103e04,%eax - 102876: ff d0 call *%eax - 102878: e9 6b ee ff ff jmp 1016e8 - -0010287d : - 10287d: 6a 00 push $0x0 - 10287f: 6a 73 push $0x73 - 102881: 0f a8 push %gs - 102883: 0f a0 push %fs - 102885: 06 push %es - 102886: 1e push %ds - 102887: 60 pusha - 102888: 66 b8 10 00 mov $0x10,%ax - 10288c: 8e d8 mov %eax,%ds - 10288e: 8e c0 mov %eax,%es - 102890: 8e e0 mov %eax,%fs - 102892: 8e e8 mov %eax,%gs - 102894: 89 e0 mov %esp,%eax - 102896: 50 push %eax - -00102897 : - 102897: b8 04 3e 10 00 mov $0x103e04,%eax - 10289c: ff d0 call *%eax - 10289e: e9 45 ee ff ff jmp 1016e8 - -001028a3 : - 1028a3: 6a 00 push $0x0 - 1028a5: 6a 74 push $0x74 - 1028a7: 0f a8 push %gs - 1028a9: 0f a0 push %fs - 1028ab: 06 push %es - 1028ac: 1e push %ds - 1028ad: 60 pusha - 1028ae: 66 b8 10 00 mov $0x10,%ax - 1028b2: 8e d8 mov %eax,%ds - 1028b4: 8e c0 mov %eax,%es - 1028b6: 8e e0 mov %eax,%fs - 1028b8: 8e e8 mov %eax,%gs - 1028ba: 89 e0 mov %esp,%eax - 1028bc: 50 push %eax - -001028bd : - 1028bd: b8 04 3e 10 00 mov $0x103e04,%eax - 1028c2: ff d0 call *%eax - 1028c4: e9 1f ee ff ff jmp 1016e8 - -001028c9 : - 1028c9: 6a 00 push $0x0 - 1028cb: 6a 75 push $0x75 - 1028cd: 0f a8 push %gs - 1028cf: 0f a0 push %fs - 1028d1: 06 push %es - 1028d2: 1e push %ds - 1028d3: 60 pusha - 1028d4: 66 b8 10 00 mov $0x10,%ax - 1028d8: 8e d8 mov %eax,%ds - 1028da: 8e c0 mov %eax,%es - 1028dc: 8e e0 mov %eax,%fs - 1028de: 8e e8 mov %eax,%gs - 1028e0: 89 e0 mov %esp,%eax - 1028e2: 50 push %eax - -001028e3 : - 1028e3: b8 04 3e 10 00 mov $0x103e04,%eax - 1028e8: ff d0 call *%eax - 1028ea: e9 f9 ed ff ff jmp 1016e8 - -001028ef : - 1028ef: 6a 00 push $0x0 - 1028f1: 6a 76 push $0x76 - 1028f3: 0f a8 push %gs - 1028f5: 0f a0 push %fs - 1028f7: 06 push %es - 1028f8: 1e push %ds - 1028f9: 60 pusha - 1028fa: 66 b8 10 00 mov $0x10,%ax - 1028fe: 8e d8 mov %eax,%ds - 102900: 8e c0 mov %eax,%es - 102902: 8e e0 mov %eax,%fs - 102904: 8e e8 mov %eax,%gs - 102906: 89 e0 mov %esp,%eax - 102908: 50 push %eax - -00102909 : - 102909: b8 04 3e 10 00 mov $0x103e04,%eax - 10290e: ff d0 call *%eax - 102910: e9 d3 ed ff ff jmp 1016e8 - -00102915 : - 102915: 6a 00 push $0x0 - 102917: 6a 77 push $0x77 - 102919: 0f a8 push %gs - 10291b: 0f a0 push %fs - 10291d: 06 push %es - 10291e: 1e push %ds - 10291f: 60 pusha - 102920: 66 b8 10 00 mov $0x10,%ax - 102924: 8e d8 mov %eax,%ds - 102926: 8e c0 mov %eax,%es - 102928: 8e e0 mov %eax,%fs - 10292a: 8e e8 mov %eax,%gs - 10292c: 89 e0 mov %esp,%eax - 10292e: 50 push %eax - -0010292f : - 10292f: b8 04 3e 10 00 mov $0x103e04,%eax - 102934: ff d0 call *%eax - 102936: e9 ad ed ff ff jmp 1016e8 - -0010293b : - 10293b: 6a 00 push $0x0 - 10293d: 6a 78 push $0x78 - 10293f: 0f a8 push %gs - 102941: 0f a0 push %fs - 102943: 06 push %es - 102944: 1e push %ds - 102945: 60 pusha - 102946: 66 b8 10 00 mov $0x10,%ax - 10294a: 8e d8 mov %eax,%ds - 10294c: 8e c0 mov %eax,%es - 10294e: 8e e0 mov %eax,%fs - 102950: 8e e8 mov %eax,%gs - 102952: 89 e0 mov %esp,%eax - 102954: 50 push %eax - -00102955 : - 102955: b8 04 3e 10 00 mov $0x103e04,%eax - 10295a: ff d0 call *%eax - 10295c: e9 87 ed ff ff jmp 1016e8 - -00102961 : - 102961: 6a 00 push $0x0 - 102963: 6a 79 push $0x79 - 102965: 0f a8 push %gs - 102967: 0f a0 push %fs - 102969: 06 push %es - 10296a: 1e push %ds - 10296b: 60 pusha - 10296c: 66 b8 10 00 mov $0x10,%ax - 102970: 8e d8 mov %eax,%ds - 102972: 8e c0 mov %eax,%es - 102974: 8e e0 mov %eax,%fs - 102976: 8e e8 mov %eax,%gs - 102978: 89 e0 mov %esp,%eax - 10297a: 50 push %eax - -0010297b : - 10297b: b8 04 3e 10 00 mov $0x103e04,%eax - 102980: ff d0 call *%eax - 102982: e9 61 ed ff ff jmp 1016e8 - -00102987 : - 102987: 6a 00 push $0x0 - 102989: 6a 7a push $0x7a - 10298b: 0f a8 push %gs - 10298d: 0f a0 push %fs - 10298f: 06 push %es - 102990: 1e push %ds - 102991: 60 pusha - 102992: 66 b8 10 00 mov $0x10,%ax - 102996: 8e d8 mov %eax,%ds - 102998: 8e c0 mov %eax,%es - 10299a: 8e e0 mov %eax,%fs - 10299c: 8e e8 mov %eax,%gs - 10299e: 89 e0 mov %esp,%eax - 1029a0: 50 push %eax - -001029a1 : - 1029a1: b8 04 3e 10 00 mov $0x103e04,%eax - 1029a6: ff d0 call *%eax - 1029a8: e9 3b ed ff ff jmp 1016e8 - -001029ad : - 1029ad: 6a 00 push $0x0 - 1029af: 6a 7b push $0x7b - 1029b1: 0f a8 push %gs - 1029b3: 0f a0 push %fs - 1029b5: 06 push %es - 1029b6: 1e push %ds - 1029b7: 60 pusha - 1029b8: 66 b8 10 00 mov $0x10,%ax - 1029bc: 8e d8 mov %eax,%ds - 1029be: 8e c0 mov %eax,%es - 1029c0: 8e e0 mov %eax,%fs - 1029c2: 8e e8 mov %eax,%gs - 1029c4: 89 e0 mov %esp,%eax - 1029c6: 50 push %eax - -001029c7 : - 1029c7: b8 04 3e 10 00 mov $0x103e04,%eax - 1029cc: ff d0 call *%eax - 1029ce: e9 15 ed ff ff jmp 1016e8 - -001029d3 : - 1029d3: 6a 00 push $0x0 - 1029d5: 6a 7c push $0x7c - 1029d7: 0f a8 push %gs - 1029d9: 0f a0 push %fs - 1029db: 06 push %es - 1029dc: 1e push %ds - 1029dd: 60 pusha - 1029de: 66 b8 10 00 mov $0x10,%ax - 1029e2: 8e d8 mov %eax,%ds - 1029e4: 8e c0 mov %eax,%es - 1029e6: 8e e0 mov %eax,%fs - 1029e8: 8e e8 mov %eax,%gs - 1029ea: 89 e0 mov %esp,%eax - 1029ec: 50 push %eax - -001029ed : - 1029ed: b8 04 3e 10 00 mov $0x103e04,%eax - 1029f2: ff d0 call *%eax - 1029f4: e9 ef ec ff ff jmp 1016e8 - -001029f9 : - 1029f9: 6a 00 push $0x0 - 1029fb: 6a 7d push $0x7d - 1029fd: 0f a8 push %gs - 1029ff: 0f a0 push %fs - 102a01: 06 push %es - 102a02: 1e push %ds - 102a03: 60 pusha - 102a04: 66 b8 10 00 mov $0x10,%ax - 102a08: 8e d8 mov %eax,%ds - 102a0a: 8e c0 mov %eax,%es - 102a0c: 8e e0 mov %eax,%fs - 102a0e: 8e e8 mov %eax,%gs - 102a10: 89 e0 mov %esp,%eax - 102a12: 50 push %eax - -00102a13 : - 102a13: b8 04 3e 10 00 mov $0x103e04,%eax - 102a18: ff d0 call *%eax - 102a1a: e9 c9 ec ff ff jmp 1016e8 - -00102a1f : - 102a1f: 6a 00 push $0x0 - 102a21: 6a 7e push $0x7e - 102a23: 0f a8 push %gs - 102a25: 0f a0 push %fs - 102a27: 06 push %es - 102a28: 1e push %ds - 102a29: 60 pusha - 102a2a: 66 b8 10 00 mov $0x10,%ax - 102a2e: 8e d8 mov %eax,%ds - 102a30: 8e c0 mov %eax,%es - 102a32: 8e e0 mov %eax,%fs - 102a34: 8e e8 mov %eax,%gs - 102a36: 89 e0 mov %esp,%eax - 102a38: 50 push %eax - -00102a39 : - 102a39: b8 04 3e 10 00 mov $0x103e04,%eax - 102a3e: ff d0 call *%eax - 102a40: e9 a3 ec ff ff jmp 1016e8 - -00102a45 : - 102a45: 6a 00 push $0x0 - 102a47: 6a 7f push $0x7f - 102a49: 0f a8 push %gs - 102a4b: 0f a0 push %fs - 102a4d: 06 push %es - 102a4e: 1e push %ds - 102a4f: 60 pusha - 102a50: 66 b8 10 00 mov $0x10,%ax - 102a54: 8e d8 mov %eax,%ds - 102a56: 8e c0 mov %eax,%es - 102a58: 8e e0 mov %eax,%fs - 102a5a: 8e e8 mov %eax,%gs - 102a5c: 89 e0 mov %esp,%eax - 102a5e: 50 push %eax - -00102a5f : - 102a5f: b8 04 3e 10 00 mov $0x103e04,%eax - 102a64: ff d0 call *%eax - 102a66: e9 7d ec ff ff jmp 1016e8 - -00102a6b : - 102a6b: 6a 00 push $0x0 - 102a6d: 6a 80 push $0xffffff80 - 102a6f: 0f a8 push %gs - 102a71: 0f a0 push %fs - 102a73: 06 push %es - 102a74: 1e push %ds - 102a75: 60 pusha - 102a76: 66 b8 10 00 mov $0x10,%ax - 102a7a: 8e d8 mov %eax,%ds - 102a7c: 8e c0 mov %eax,%es - 102a7e: 8e e0 mov %eax,%fs - 102a80: 8e e8 mov %eax,%gs - 102a82: 89 e0 mov %esp,%eax - 102a84: 50 push %eax - -00102a85 : - 102a85: b8 04 3e 10 00 mov $0x103e04,%eax - 102a8a: ff d0 call *%eax - 102a8c: e9 57 ec ff ff jmp 1016e8 - -00102a91 : - 102a91: 6a 00 push $0x0 - 102a93: 6a 81 push $0xffffff81 - 102a95: 0f a8 push %gs - 102a97: 0f a0 push %fs - 102a99: 06 push %es - 102a9a: 1e push %ds - 102a9b: 60 pusha - 102a9c: 66 b8 10 00 mov $0x10,%ax - 102aa0: 8e d8 mov %eax,%ds - 102aa2: 8e c0 mov %eax,%es - 102aa4: 8e e0 mov %eax,%fs - 102aa6: 8e e8 mov %eax,%gs - 102aa8: 89 e0 mov %esp,%eax - 102aaa: 50 push %eax - -00102aab : - 102aab: b8 04 3e 10 00 mov $0x103e04,%eax - 102ab0: ff d0 call *%eax - 102ab2: e9 31 ec ff ff jmp 1016e8 - -00102ab7 : - 102ab7: 6a 00 push $0x0 - 102ab9: 6a 82 push $0xffffff82 - 102abb: 0f a8 push %gs - 102abd: 0f a0 push %fs - 102abf: 06 push %es - 102ac0: 1e push %ds - 102ac1: 60 pusha - 102ac2: 66 b8 10 00 mov $0x10,%ax - 102ac6: 8e d8 mov %eax,%ds - 102ac8: 8e c0 mov %eax,%es - 102aca: 8e e0 mov %eax,%fs - 102acc: 8e e8 mov %eax,%gs - 102ace: 89 e0 mov %esp,%eax - 102ad0: 50 push %eax - -00102ad1 : - 102ad1: b8 04 3e 10 00 mov $0x103e04,%eax - 102ad6: ff d0 call *%eax - 102ad8: e9 0b ec ff ff jmp 1016e8 - -00102add : - 102add: 6a 00 push $0x0 - 102adf: 6a 83 push $0xffffff83 - 102ae1: 0f a8 push %gs - 102ae3: 0f a0 push %fs - 102ae5: 06 push %es - 102ae6: 1e push %ds - 102ae7: 60 pusha - 102ae8: 66 b8 10 00 mov $0x10,%ax - 102aec: 8e d8 mov %eax,%ds - 102aee: 8e c0 mov %eax,%es - 102af0: 8e e0 mov %eax,%fs - 102af2: 8e e8 mov %eax,%gs - 102af4: 89 e0 mov %esp,%eax - 102af6: 50 push %eax - -00102af7 : - 102af7: b8 04 3e 10 00 mov $0x103e04,%eax - 102afc: ff d0 call *%eax - 102afe: e9 e5 eb ff ff jmp 1016e8 - -00102b03 : - 102b03: 6a 00 push $0x0 - 102b05: 6a 84 push $0xffffff84 - 102b07: 0f a8 push %gs - 102b09: 0f a0 push %fs - 102b0b: 06 push %es - 102b0c: 1e push %ds - 102b0d: 60 pusha - 102b0e: 66 b8 10 00 mov $0x10,%ax - 102b12: 8e d8 mov %eax,%ds - 102b14: 8e c0 mov %eax,%es - 102b16: 8e e0 mov %eax,%fs - 102b18: 8e e8 mov %eax,%gs - 102b1a: 89 e0 mov %esp,%eax - 102b1c: 50 push %eax - -00102b1d : - 102b1d: b8 04 3e 10 00 mov $0x103e04,%eax - 102b22: ff d0 call *%eax - 102b24: e9 bf eb ff ff jmp 1016e8 - -00102b29 : - 102b29: 6a 00 push $0x0 - 102b2b: 6a 85 push $0xffffff85 - 102b2d: 0f a8 push %gs - 102b2f: 0f a0 push %fs - 102b31: 06 push %es - 102b32: 1e push %ds - 102b33: 60 pusha - 102b34: 66 b8 10 00 mov $0x10,%ax - 102b38: 8e d8 mov %eax,%ds - 102b3a: 8e c0 mov %eax,%es - 102b3c: 8e e0 mov %eax,%fs - 102b3e: 8e e8 mov %eax,%gs - 102b40: 89 e0 mov %esp,%eax - 102b42: 50 push %eax - -00102b43 : - 102b43: b8 04 3e 10 00 mov $0x103e04,%eax - 102b48: ff d0 call *%eax - 102b4a: e9 99 eb ff ff jmp 1016e8 - -00102b4f : - 102b4f: 6a 00 push $0x0 - 102b51: 6a 86 push $0xffffff86 - 102b53: 0f a8 push %gs - 102b55: 0f a0 push %fs - 102b57: 06 push %es - 102b58: 1e push %ds - 102b59: 60 pusha - 102b5a: 66 b8 10 00 mov $0x10,%ax - 102b5e: 8e d8 mov %eax,%ds - 102b60: 8e c0 mov %eax,%es - 102b62: 8e e0 mov %eax,%fs - 102b64: 8e e8 mov %eax,%gs - 102b66: 89 e0 mov %esp,%eax - 102b68: 50 push %eax - -00102b69 : - 102b69: b8 04 3e 10 00 mov $0x103e04,%eax - 102b6e: ff d0 call *%eax - 102b70: e9 73 eb ff ff jmp 1016e8 - -00102b75 : - 102b75: 6a 00 push $0x0 - 102b77: 6a 87 push $0xffffff87 - 102b79: 0f a8 push %gs - 102b7b: 0f a0 push %fs - 102b7d: 06 push %es - 102b7e: 1e push %ds - 102b7f: 60 pusha - 102b80: 66 b8 10 00 mov $0x10,%ax - 102b84: 8e d8 mov %eax,%ds - 102b86: 8e c0 mov %eax,%es - 102b88: 8e e0 mov %eax,%fs - 102b8a: 8e e8 mov %eax,%gs - 102b8c: 89 e0 mov %esp,%eax - 102b8e: 50 push %eax - -00102b8f : - 102b8f: b8 04 3e 10 00 mov $0x103e04,%eax - 102b94: ff d0 call *%eax - 102b96: e9 4d eb ff ff jmp 1016e8 - -00102b9b : - 102b9b: 6a 00 push $0x0 - 102b9d: 6a 88 push $0xffffff88 - 102b9f: 0f a8 push %gs - 102ba1: 0f a0 push %fs - 102ba3: 06 push %es - 102ba4: 1e push %ds - 102ba5: 60 pusha - 102ba6: 66 b8 10 00 mov $0x10,%ax - 102baa: 8e d8 mov %eax,%ds - 102bac: 8e c0 mov %eax,%es - 102bae: 8e e0 mov %eax,%fs - 102bb0: 8e e8 mov %eax,%gs - 102bb2: 89 e0 mov %esp,%eax - 102bb4: 50 push %eax - -00102bb5 : - 102bb5: b8 04 3e 10 00 mov $0x103e04,%eax - 102bba: ff d0 call *%eax - 102bbc: e9 27 eb ff ff jmp 1016e8 - -00102bc1 : - 102bc1: 6a 00 push $0x0 - 102bc3: 6a 89 push $0xffffff89 - 102bc5: 0f a8 push %gs - 102bc7: 0f a0 push %fs - 102bc9: 06 push %es - 102bca: 1e push %ds - 102bcb: 60 pusha - 102bcc: 66 b8 10 00 mov $0x10,%ax - 102bd0: 8e d8 mov %eax,%ds - 102bd2: 8e c0 mov %eax,%es - 102bd4: 8e e0 mov %eax,%fs - 102bd6: 8e e8 mov %eax,%gs - 102bd8: 89 e0 mov %esp,%eax - 102bda: 50 push %eax - -00102bdb : - 102bdb: b8 04 3e 10 00 mov $0x103e04,%eax - 102be0: ff d0 call *%eax - 102be2: e9 01 eb ff ff jmp 1016e8 - -00102be7 : - 102be7: 6a 00 push $0x0 - 102be9: 6a 8a push $0xffffff8a - 102beb: 0f a8 push %gs - 102bed: 0f a0 push %fs - 102bef: 06 push %es - 102bf0: 1e push %ds - 102bf1: 60 pusha - 102bf2: 66 b8 10 00 mov $0x10,%ax - 102bf6: 8e d8 mov %eax,%ds - 102bf8: 8e c0 mov %eax,%es - 102bfa: 8e e0 mov %eax,%fs - 102bfc: 8e e8 mov %eax,%gs - 102bfe: 89 e0 mov %esp,%eax - 102c00: 50 push %eax - -00102c01 : - 102c01: b8 04 3e 10 00 mov $0x103e04,%eax - 102c06: ff d0 call *%eax - 102c08: e9 db ea ff ff jmp 1016e8 - -00102c0d : - 102c0d: 6a 00 push $0x0 - 102c0f: 6a 8b push $0xffffff8b - 102c11: 0f a8 push %gs - 102c13: 0f a0 push %fs - 102c15: 06 push %es - 102c16: 1e push %ds - 102c17: 60 pusha - 102c18: 66 b8 10 00 mov $0x10,%ax - 102c1c: 8e d8 mov %eax,%ds - 102c1e: 8e c0 mov %eax,%es - 102c20: 8e e0 mov %eax,%fs - 102c22: 8e e8 mov %eax,%gs - 102c24: 89 e0 mov %esp,%eax - 102c26: 50 push %eax - -00102c27 : - 102c27: b8 04 3e 10 00 mov $0x103e04,%eax - 102c2c: ff d0 call *%eax - 102c2e: e9 b5 ea ff ff jmp 1016e8 - -00102c33 : - 102c33: 6a 00 push $0x0 - 102c35: 6a 8c push $0xffffff8c - 102c37: 0f a8 push %gs - 102c39: 0f a0 push %fs - 102c3b: 06 push %es - 102c3c: 1e push %ds - 102c3d: 60 pusha - 102c3e: 66 b8 10 00 mov $0x10,%ax - 102c42: 8e d8 mov %eax,%ds - 102c44: 8e c0 mov %eax,%es - 102c46: 8e e0 mov %eax,%fs - 102c48: 8e e8 mov %eax,%gs - 102c4a: 89 e0 mov %esp,%eax - 102c4c: 50 push %eax - -00102c4d : - 102c4d: b8 04 3e 10 00 mov $0x103e04,%eax - 102c52: ff d0 call *%eax - 102c54: e9 8f ea ff ff jmp 1016e8 - -00102c59 : - 102c59: 6a 00 push $0x0 - 102c5b: 6a 8d push $0xffffff8d - 102c5d: 0f a8 push %gs - 102c5f: 0f a0 push %fs - 102c61: 06 push %es - 102c62: 1e push %ds - 102c63: 60 pusha - 102c64: 66 b8 10 00 mov $0x10,%ax - 102c68: 8e d8 mov %eax,%ds - 102c6a: 8e c0 mov %eax,%es - 102c6c: 8e e0 mov %eax,%fs - 102c6e: 8e e8 mov %eax,%gs - 102c70: 89 e0 mov %esp,%eax - 102c72: 50 push %eax - -00102c73 : - 102c73: b8 04 3e 10 00 mov $0x103e04,%eax - 102c78: ff d0 call *%eax - 102c7a: e9 69 ea ff ff jmp 1016e8 - -00102c7f : - 102c7f: 6a 00 push $0x0 - 102c81: 6a 8e push $0xffffff8e - 102c83: 0f a8 push %gs - 102c85: 0f a0 push %fs - 102c87: 06 push %es - 102c88: 1e push %ds - 102c89: 60 pusha - 102c8a: 66 b8 10 00 mov $0x10,%ax - 102c8e: 8e d8 mov %eax,%ds - 102c90: 8e c0 mov %eax,%es - 102c92: 8e e0 mov %eax,%fs - 102c94: 8e e8 mov %eax,%gs - 102c96: 89 e0 mov %esp,%eax - 102c98: 50 push %eax - -00102c99 : - 102c99: b8 04 3e 10 00 mov $0x103e04,%eax - 102c9e: ff d0 call *%eax - 102ca0: e9 43 ea ff ff jmp 1016e8 - -00102ca5 : - 102ca5: 6a 00 push $0x0 - 102ca7: 6a 8f push $0xffffff8f - 102ca9: 0f a8 push %gs - 102cab: 0f a0 push %fs - 102cad: 06 push %es - 102cae: 1e push %ds - 102caf: 60 pusha - 102cb0: 66 b8 10 00 mov $0x10,%ax - 102cb4: 8e d8 mov %eax,%ds - 102cb6: 8e c0 mov %eax,%es - 102cb8: 8e e0 mov %eax,%fs - 102cba: 8e e8 mov %eax,%gs - 102cbc: 89 e0 mov %esp,%eax - 102cbe: 50 push %eax - -00102cbf : - 102cbf: b8 04 3e 10 00 mov $0x103e04,%eax - 102cc4: ff d0 call *%eax - 102cc6: e9 1d ea ff ff jmp 1016e8 - -00102ccb : - 102ccb: 6a 00 push $0x0 - 102ccd: 6a 90 push $0xffffff90 - 102ccf: 0f a8 push %gs - 102cd1: 0f a0 push %fs - 102cd3: 06 push %es - 102cd4: 1e push %ds - 102cd5: 60 pusha - 102cd6: 66 b8 10 00 mov $0x10,%ax - 102cda: 8e d8 mov %eax,%ds - 102cdc: 8e c0 mov %eax,%es - 102cde: 8e e0 mov %eax,%fs - 102ce0: 8e e8 mov %eax,%gs - 102ce2: 89 e0 mov %esp,%eax - 102ce4: 50 push %eax - -00102ce5 : - 102ce5: b8 04 3e 10 00 mov $0x103e04,%eax - 102cea: ff d0 call *%eax - 102cec: e9 f7 e9 ff ff jmp 1016e8 - -00102cf1 : - 102cf1: 6a 00 push $0x0 - 102cf3: 6a 91 push $0xffffff91 - 102cf5: 0f a8 push %gs - 102cf7: 0f a0 push %fs - 102cf9: 06 push %es - 102cfa: 1e push %ds - 102cfb: 60 pusha - 102cfc: 66 b8 10 00 mov $0x10,%ax - 102d00: 8e d8 mov %eax,%ds - 102d02: 8e c0 mov %eax,%es - 102d04: 8e e0 mov %eax,%fs - 102d06: 8e e8 mov %eax,%gs - 102d08: 89 e0 mov %esp,%eax - 102d0a: 50 push %eax - -00102d0b : - 102d0b: b8 04 3e 10 00 mov $0x103e04,%eax - 102d10: ff d0 call *%eax - 102d12: e9 d1 e9 ff ff jmp 1016e8 - -00102d17 : - 102d17: 6a 00 push $0x0 - 102d19: 6a 92 push $0xffffff92 - 102d1b: 0f a8 push %gs - 102d1d: 0f a0 push %fs - 102d1f: 06 push %es - 102d20: 1e push %ds - 102d21: 60 pusha - 102d22: 66 b8 10 00 mov $0x10,%ax - 102d26: 8e d8 mov %eax,%ds - 102d28: 8e c0 mov %eax,%es - 102d2a: 8e e0 mov %eax,%fs - 102d2c: 8e e8 mov %eax,%gs - 102d2e: 89 e0 mov %esp,%eax - 102d30: 50 push %eax - -00102d31 : - 102d31: b8 04 3e 10 00 mov $0x103e04,%eax - 102d36: ff d0 call *%eax - 102d38: e9 ab e9 ff ff jmp 1016e8 - -00102d3d : - 102d3d: 6a 00 push $0x0 - 102d3f: 6a 93 push $0xffffff93 - 102d41: 0f a8 push %gs - 102d43: 0f a0 push %fs - 102d45: 06 push %es - 102d46: 1e push %ds - 102d47: 60 pusha - 102d48: 66 b8 10 00 mov $0x10,%ax - 102d4c: 8e d8 mov %eax,%ds - 102d4e: 8e c0 mov %eax,%es - 102d50: 8e e0 mov %eax,%fs - 102d52: 8e e8 mov %eax,%gs - 102d54: 89 e0 mov %esp,%eax - 102d56: 50 push %eax - -00102d57 : - 102d57: b8 04 3e 10 00 mov $0x103e04,%eax - 102d5c: ff d0 call *%eax - 102d5e: e9 85 e9 ff ff jmp 1016e8 - -00102d63 : - 102d63: 6a 00 push $0x0 - 102d65: 6a 94 push $0xffffff94 - 102d67: 0f a8 push %gs - 102d69: 0f a0 push %fs - 102d6b: 06 push %es - 102d6c: 1e push %ds - 102d6d: 60 pusha - 102d6e: 66 b8 10 00 mov $0x10,%ax - 102d72: 8e d8 mov %eax,%ds - 102d74: 8e c0 mov %eax,%es - 102d76: 8e e0 mov %eax,%fs - 102d78: 8e e8 mov %eax,%gs - 102d7a: 89 e0 mov %esp,%eax - 102d7c: 50 push %eax - -00102d7d : - 102d7d: b8 04 3e 10 00 mov $0x103e04,%eax - 102d82: ff d0 call *%eax - 102d84: e9 5f e9 ff ff jmp 1016e8 - -00102d89 : - 102d89: 6a 00 push $0x0 - 102d8b: 6a 95 push $0xffffff95 - 102d8d: 0f a8 push %gs - 102d8f: 0f a0 push %fs - 102d91: 06 push %es - 102d92: 1e push %ds - 102d93: 60 pusha - 102d94: 66 b8 10 00 mov $0x10,%ax - 102d98: 8e d8 mov %eax,%ds - 102d9a: 8e c0 mov %eax,%es - 102d9c: 8e e0 mov %eax,%fs - 102d9e: 8e e8 mov %eax,%gs - 102da0: 89 e0 mov %esp,%eax - 102da2: 50 push %eax - -00102da3 : - 102da3: b8 04 3e 10 00 mov $0x103e04,%eax - 102da8: ff d0 call *%eax - 102daa: e9 39 e9 ff ff jmp 1016e8 - -00102daf : - 102daf: 6a 00 push $0x0 - 102db1: 6a 96 push $0xffffff96 - 102db3: 0f a8 push %gs - 102db5: 0f a0 push %fs - 102db7: 06 push %es - 102db8: 1e push %ds - 102db9: 60 pusha - 102dba: 66 b8 10 00 mov $0x10,%ax - 102dbe: 8e d8 mov %eax,%ds - 102dc0: 8e c0 mov %eax,%es - 102dc2: 8e e0 mov %eax,%fs - 102dc4: 8e e8 mov %eax,%gs - 102dc6: 89 e0 mov %esp,%eax - 102dc8: 50 push %eax - -00102dc9 : - 102dc9: b8 04 3e 10 00 mov $0x103e04,%eax - 102dce: ff d0 call *%eax - 102dd0: e9 13 e9 ff ff jmp 1016e8 - -00102dd5 : - 102dd5: 6a 00 push $0x0 - 102dd7: 6a 97 push $0xffffff97 - 102dd9: 0f a8 push %gs - 102ddb: 0f a0 push %fs - 102ddd: 06 push %es - 102dde: 1e push %ds - 102ddf: 60 pusha - 102de0: 66 b8 10 00 mov $0x10,%ax - 102de4: 8e d8 mov %eax,%ds - 102de6: 8e c0 mov %eax,%es - 102de8: 8e e0 mov %eax,%fs - 102dea: 8e e8 mov %eax,%gs - 102dec: 89 e0 mov %esp,%eax - 102dee: 50 push %eax - -00102def : - 102def: b8 04 3e 10 00 mov $0x103e04,%eax - 102df4: ff d0 call *%eax - 102df6: e9 ed e8 ff ff jmp 1016e8 - -00102dfb : - 102dfb: 6a 00 push $0x0 - 102dfd: 6a 98 push $0xffffff98 - 102dff: 0f a8 push %gs - 102e01: 0f a0 push %fs - 102e03: 06 push %es - 102e04: 1e push %ds - 102e05: 60 pusha - 102e06: 66 b8 10 00 mov $0x10,%ax - 102e0a: 8e d8 mov %eax,%ds - 102e0c: 8e c0 mov %eax,%es - 102e0e: 8e e0 mov %eax,%fs - 102e10: 8e e8 mov %eax,%gs - 102e12: 89 e0 mov %esp,%eax - 102e14: 50 push %eax - -00102e15 : - 102e15: b8 04 3e 10 00 mov $0x103e04,%eax - 102e1a: ff d0 call *%eax - 102e1c: e9 c7 e8 ff ff jmp 1016e8 - -00102e21 : - 102e21: 6a 00 push $0x0 - 102e23: 6a 99 push $0xffffff99 - 102e25: 0f a8 push %gs - 102e27: 0f a0 push %fs - 102e29: 06 push %es - 102e2a: 1e push %ds - 102e2b: 60 pusha - 102e2c: 66 b8 10 00 mov $0x10,%ax - 102e30: 8e d8 mov %eax,%ds - 102e32: 8e c0 mov %eax,%es - 102e34: 8e e0 mov %eax,%fs - 102e36: 8e e8 mov %eax,%gs - 102e38: 89 e0 mov %esp,%eax - 102e3a: 50 push %eax - -00102e3b : - 102e3b: b8 04 3e 10 00 mov $0x103e04,%eax - 102e40: ff d0 call *%eax - 102e42: e9 a1 e8 ff ff jmp 1016e8 - -00102e47 : - 102e47: 6a 00 push $0x0 - 102e49: 6a 9a push $0xffffff9a - 102e4b: 0f a8 push %gs - 102e4d: 0f a0 push %fs - 102e4f: 06 push %es - 102e50: 1e push %ds - 102e51: 60 pusha - 102e52: 66 b8 10 00 mov $0x10,%ax - 102e56: 8e d8 mov %eax,%ds - 102e58: 8e c0 mov %eax,%es - 102e5a: 8e e0 mov %eax,%fs - 102e5c: 8e e8 mov %eax,%gs - 102e5e: 89 e0 mov %esp,%eax - 102e60: 50 push %eax - -00102e61 : - 102e61: b8 04 3e 10 00 mov $0x103e04,%eax - 102e66: ff d0 call *%eax - 102e68: e9 7b e8 ff ff jmp 1016e8 - -00102e6d : - 102e6d: 6a 00 push $0x0 - 102e6f: 6a 9b push $0xffffff9b - 102e71: 0f a8 push %gs - 102e73: 0f a0 push %fs - 102e75: 06 push %es - 102e76: 1e push %ds - 102e77: 60 pusha - 102e78: 66 b8 10 00 mov $0x10,%ax - 102e7c: 8e d8 mov %eax,%ds - 102e7e: 8e c0 mov %eax,%es - 102e80: 8e e0 mov %eax,%fs - 102e82: 8e e8 mov %eax,%gs - 102e84: 89 e0 mov %esp,%eax - 102e86: 50 push %eax - -00102e87 : - 102e87: b8 04 3e 10 00 mov $0x103e04,%eax - 102e8c: ff d0 call *%eax - 102e8e: e9 55 e8 ff ff jmp 1016e8 - -00102e93 : - 102e93: 6a 00 push $0x0 - 102e95: 6a 9c push $0xffffff9c - 102e97: 0f a8 push %gs - 102e99: 0f a0 push %fs - 102e9b: 06 push %es - 102e9c: 1e push %ds - 102e9d: 60 pusha - 102e9e: 66 b8 10 00 mov $0x10,%ax - 102ea2: 8e d8 mov %eax,%ds - 102ea4: 8e c0 mov %eax,%es - 102ea6: 8e e0 mov %eax,%fs - 102ea8: 8e e8 mov %eax,%gs - 102eaa: 89 e0 mov %esp,%eax - 102eac: 50 push %eax - -00102ead : - 102ead: b8 04 3e 10 00 mov $0x103e04,%eax - 102eb2: ff d0 call *%eax - 102eb4: e9 2f e8 ff ff jmp 1016e8 - -00102eb9 : - 102eb9: 6a 00 push $0x0 - 102ebb: 6a 9d push $0xffffff9d - 102ebd: 0f a8 push %gs - 102ebf: 0f a0 push %fs - 102ec1: 06 push %es - 102ec2: 1e push %ds - 102ec3: 60 pusha - 102ec4: 66 b8 10 00 mov $0x10,%ax - 102ec8: 8e d8 mov %eax,%ds - 102eca: 8e c0 mov %eax,%es - 102ecc: 8e e0 mov %eax,%fs - 102ece: 8e e8 mov %eax,%gs - 102ed0: 89 e0 mov %esp,%eax - 102ed2: 50 push %eax - -00102ed3 : - 102ed3: b8 04 3e 10 00 mov $0x103e04,%eax - 102ed8: ff d0 call *%eax - 102eda: e9 09 e8 ff ff jmp 1016e8 - -00102edf : - 102edf: 6a 00 push $0x0 - 102ee1: 6a 9e push $0xffffff9e - 102ee3: 0f a8 push %gs - 102ee5: 0f a0 push %fs - 102ee7: 06 push %es - 102ee8: 1e push %ds - 102ee9: 60 pusha - 102eea: 66 b8 10 00 mov $0x10,%ax - 102eee: 8e d8 mov %eax,%ds - 102ef0: 8e c0 mov %eax,%es - 102ef2: 8e e0 mov %eax,%fs - 102ef4: 8e e8 mov %eax,%gs - 102ef6: 89 e0 mov %esp,%eax - 102ef8: 50 push %eax - -00102ef9 : - 102ef9: b8 04 3e 10 00 mov $0x103e04,%eax - 102efe: ff d0 call *%eax - 102f00: e9 e3 e7 ff ff jmp 1016e8 - -00102f05 : - 102f05: 6a 00 push $0x0 - 102f07: 6a 9f push $0xffffff9f - 102f09: 0f a8 push %gs - 102f0b: 0f a0 push %fs - 102f0d: 06 push %es - 102f0e: 1e push %ds - 102f0f: 60 pusha - 102f10: 66 b8 10 00 mov $0x10,%ax - 102f14: 8e d8 mov %eax,%ds - 102f16: 8e c0 mov %eax,%es - 102f18: 8e e0 mov %eax,%fs - 102f1a: 8e e8 mov %eax,%gs - 102f1c: 89 e0 mov %esp,%eax - 102f1e: 50 push %eax - -00102f1f : - 102f1f: b8 04 3e 10 00 mov $0x103e04,%eax - 102f24: ff d0 call *%eax - 102f26: e9 bd e7 ff ff jmp 1016e8 - -00102f2b : - 102f2b: 6a 00 push $0x0 - 102f2d: 6a a0 push $0xffffffa0 - 102f2f: 0f a8 push %gs - 102f31: 0f a0 push %fs - 102f33: 06 push %es - 102f34: 1e push %ds - 102f35: 60 pusha - 102f36: 66 b8 10 00 mov $0x10,%ax - 102f3a: 8e d8 mov %eax,%ds - 102f3c: 8e c0 mov %eax,%es - 102f3e: 8e e0 mov %eax,%fs - 102f40: 8e e8 mov %eax,%gs - 102f42: 89 e0 mov %esp,%eax - 102f44: 50 push %eax - -00102f45 : - 102f45: b8 04 3e 10 00 mov $0x103e04,%eax - 102f4a: ff d0 call *%eax - 102f4c: e9 97 e7 ff ff jmp 1016e8 - -00102f51 : - 102f51: 6a 00 push $0x0 - 102f53: 6a a1 push $0xffffffa1 - 102f55: 0f a8 push %gs - 102f57: 0f a0 push %fs - 102f59: 06 push %es - 102f5a: 1e push %ds - 102f5b: 60 pusha - 102f5c: 66 b8 10 00 mov $0x10,%ax - 102f60: 8e d8 mov %eax,%ds - 102f62: 8e c0 mov %eax,%es - 102f64: 8e e0 mov %eax,%fs - 102f66: 8e e8 mov %eax,%gs - 102f68: 89 e0 mov %esp,%eax - 102f6a: 50 push %eax - -00102f6b : - 102f6b: b8 04 3e 10 00 mov $0x103e04,%eax - 102f70: ff d0 call *%eax - 102f72: e9 71 e7 ff ff jmp 1016e8 - -00102f77 : - 102f77: 6a 00 push $0x0 - 102f79: 6a a2 push $0xffffffa2 - 102f7b: 0f a8 push %gs - 102f7d: 0f a0 push %fs - 102f7f: 06 push %es - 102f80: 1e push %ds - 102f81: 60 pusha - 102f82: 66 b8 10 00 mov $0x10,%ax - 102f86: 8e d8 mov %eax,%ds - 102f88: 8e c0 mov %eax,%es - 102f8a: 8e e0 mov %eax,%fs - 102f8c: 8e e8 mov %eax,%gs - 102f8e: 89 e0 mov %esp,%eax - 102f90: 50 push %eax - -00102f91 : - 102f91: b8 04 3e 10 00 mov $0x103e04,%eax - 102f96: ff d0 call *%eax - 102f98: e9 4b e7 ff ff jmp 1016e8 - -00102f9d : - 102f9d: 6a 00 push $0x0 - 102f9f: 6a a3 push $0xffffffa3 - 102fa1: 0f a8 push %gs - 102fa3: 0f a0 push %fs - 102fa5: 06 push %es - 102fa6: 1e push %ds - 102fa7: 60 pusha - 102fa8: 66 b8 10 00 mov $0x10,%ax - 102fac: 8e d8 mov %eax,%ds - 102fae: 8e c0 mov %eax,%es - 102fb0: 8e e0 mov %eax,%fs - 102fb2: 8e e8 mov %eax,%gs - 102fb4: 89 e0 mov %esp,%eax - 102fb6: 50 push %eax - -00102fb7 : - 102fb7: b8 04 3e 10 00 mov $0x103e04,%eax - 102fbc: ff d0 call *%eax - 102fbe: e9 25 e7 ff ff jmp 1016e8 - -00102fc3 : - 102fc3: 6a 00 push $0x0 - 102fc5: 6a a4 push $0xffffffa4 - 102fc7: 0f a8 push %gs - 102fc9: 0f a0 push %fs - 102fcb: 06 push %es - 102fcc: 1e push %ds - 102fcd: 60 pusha - 102fce: 66 b8 10 00 mov $0x10,%ax - 102fd2: 8e d8 mov %eax,%ds - 102fd4: 8e c0 mov %eax,%es - 102fd6: 8e e0 mov %eax,%fs - 102fd8: 8e e8 mov %eax,%gs - 102fda: 89 e0 mov %esp,%eax - 102fdc: 50 push %eax - -00102fdd : - 102fdd: b8 04 3e 10 00 mov $0x103e04,%eax - 102fe2: ff d0 call *%eax - 102fe4: e9 ff e6 ff ff jmp 1016e8 - -00102fe9 : - 102fe9: 6a 00 push $0x0 - 102feb: 6a a5 push $0xffffffa5 - 102fed: 0f a8 push %gs - 102fef: 0f a0 push %fs - 102ff1: 06 push %es - 102ff2: 1e push %ds - 102ff3: 60 pusha - 102ff4: 66 b8 10 00 mov $0x10,%ax - 102ff8: 8e d8 mov %eax,%ds - 102ffa: 8e c0 mov %eax,%es - 102ffc: 8e e0 mov %eax,%fs - 102ffe: 8e e8 mov %eax,%gs - 103000: 89 e0 mov %esp,%eax - 103002: 50 push %eax - -00103003 : - 103003: b8 04 3e 10 00 mov $0x103e04,%eax - 103008: ff d0 call *%eax - 10300a: e9 d9 e6 ff ff jmp 1016e8 - -0010300f : - 10300f: 6a 00 push $0x0 - 103011: 6a a6 push $0xffffffa6 - 103013: 0f a8 push %gs - 103015: 0f a0 push %fs - 103017: 06 push %es - 103018: 1e push %ds - 103019: 60 pusha - 10301a: 66 b8 10 00 mov $0x10,%ax - 10301e: 8e d8 mov %eax,%ds - 103020: 8e c0 mov %eax,%es - 103022: 8e e0 mov %eax,%fs - 103024: 8e e8 mov %eax,%gs - 103026: 89 e0 mov %esp,%eax - 103028: 50 push %eax - -00103029 : - 103029: b8 04 3e 10 00 mov $0x103e04,%eax - 10302e: ff d0 call *%eax - 103030: e9 b3 e6 ff ff jmp 1016e8 - -00103035 : - 103035: 6a 00 push $0x0 - 103037: 6a a7 push $0xffffffa7 - 103039: 0f a8 push %gs - 10303b: 0f a0 push %fs - 10303d: 06 push %es - 10303e: 1e push %ds - 10303f: 60 pusha - 103040: 66 b8 10 00 mov $0x10,%ax - 103044: 8e d8 mov %eax,%ds - 103046: 8e c0 mov %eax,%es - 103048: 8e e0 mov %eax,%fs - 10304a: 8e e8 mov %eax,%gs - 10304c: 89 e0 mov %esp,%eax - 10304e: 50 push %eax - -0010304f : - 10304f: b8 04 3e 10 00 mov $0x103e04,%eax - 103054: ff d0 call *%eax - 103056: e9 8d e6 ff ff jmp 1016e8 - -0010305b : - 10305b: 6a 00 push $0x0 - 10305d: 6a a8 push $0xffffffa8 - 10305f: 0f a8 push %gs - 103061: 0f a0 push %fs - 103063: 06 push %es - 103064: 1e push %ds - 103065: 60 pusha - 103066: 66 b8 10 00 mov $0x10,%ax - 10306a: 8e d8 mov %eax,%ds - 10306c: 8e c0 mov %eax,%es - 10306e: 8e e0 mov %eax,%fs - 103070: 8e e8 mov %eax,%gs - 103072: 89 e0 mov %esp,%eax - 103074: 50 push %eax - -00103075 : - 103075: b8 04 3e 10 00 mov $0x103e04,%eax - 10307a: ff d0 call *%eax - 10307c: e9 67 e6 ff ff jmp 1016e8 - -00103081 : - 103081: 6a 00 push $0x0 - 103083: 6a a9 push $0xffffffa9 - 103085: 0f a8 push %gs - 103087: 0f a0 push %fs - 103089: 06 push %es - 10308a: 1e push %ds - 10308b: 60 pusha - 10308c: 66 b8 10 00 mov $0x10,%ax - 103090: 8e d8 mov %eax,%ds - 103092: 8e c0 mov %eax,%es - 103094: 8e e0 mov %eax,%fs - 103096: 8e e8 mov %eax,%gs - 103098: 89 e0 mov %esp,%eax - 10309a: 50 push %eax - -0010309b : - 10309b: b8 04 3e 10 00 mov $0x103e04,%eax - 1030a0: ff d0 call *%eax - 1030a2: e9 41 e6 ff ff jmp 1016e8 - -001030a7 : - 1030a7: 6a 00 push $0x0 - 1030a9: 6a aa push $0xffffffaa - 1030ab: 0f a8 push %gs - 1030ad: 0f a0 push %fs - 1030af: 06 push %es - 1030b0: 1e push %ds - 1030b1: 60 pusha - 1030b2: 66 b8 10 00 mov $0x10,%ax - 1030b6: 8e d8 mov %eax,%ds - 1030b8: 8e c0 mov %eax,%es - 1030ba: 8e e0 mov %eax,%fs - 1030bc: 8e e8 mov %eax,%gs - 1030be: 89 e0 mov %esp,%eax - 1030c0: 50 push %eax - -001030c1 : - 1030c1: b8 04 3e 10 00 mov $0x103e04,%eax - 1030c6: ff d0 call *%eax - 1030c8: e9 1b e6 ff ff jmp 1016e8 - -001030cd : - 1030cd: 6a 00 push $0x0 - 1030cf: 6a ab push $0xffffffab - 1030d1: 0f a8 push %gs - 1030d3: 0f a0 push %fs - 1030d5: 06 push %es - 1030d6: 1e push %ds - 1030d7: 60 pusha - 1030d8: 66 b8 10 00 mov $0x10,%ax - 1030dc: 8e d8 mov %eax,%ds - 1030de: 8e c0 mov %eax,%es - 1030e0: 8e e0 mov %eax,%fs - 1030e2: 8e e8 mov %eax,%gs - 1030e4: 89 e0 mov %esp,%eax - 1030e6: 50 push %eax - -001030e7 : - 1030e7: b8 04 3e 10 00 mov $0x103e04,%eax - 1030ec: ff d0 call *%eax - 1030ee: e9 f5 e5 ff ff jmp 1016e8 - -001030f3 : - 1030f3: 6a 00 push $0x0 - 1030f5: 6a ac push $0xffffffac - 1030f7: 0f a8 push %gs - 1030f9: 0f a0 push %fs - 1030fb: 06 push %es - 1030fc: 1e push %ds - 1030fd: 60 pusha - 1030fe: 66 b8 10 00 mov $0x10,%ax - 103102: 8e d8 mov %eax,%ds - 103104: 8e c0 mov %eax,%es - 103106: 8e e0 mov %eax,%fs - 103108: 8e e8 mov %eax,%gs - 10310a: 89 e0 mov %esp,%eax - 10310c: 50 push %eax - -0010310d : - 10310d: b8 04 3e 10 00 mov $0x103e04,%eax - 103112: ff d0 call *%eax - 103114: e9 cf e5 ff ff jmp 1016e8 - -00103119 : - 103119: 6a 00 push $0x0 - 10311b: 6a ad push $0xffffffad - 10311d: 0f a8 push %gs - 10311f: 0f a0 push %fs - 103121: 06 push %es - 103122: 1e push %ds - 103123: 60 pusha - 103124: 66 b8 10 00 mov $0x10,%ax - 103128: 8e d8 mov %eax,%ds - 10312a: 8e c0 mov %eax,%es - 10312c: 8e e0 mov %eax,%fs - 10312e: 8e e8 mov %eax,%gs - 103130: 89 e0 mov %esp,%eax - 103132: 50 push %eax - -00103133 : - 103133: b8 04 3e 10 00 mov $0x103e04,%eax - 103138: ff d0 call *%eax - 10313a: e9 a9 e5 ff ff jmp 1016e8 - -0010313f : - 10313f: 6a 00 push $0x0 - 103141: 6a ae push $0xffffffae - 103143: 0f a8 push %gs - 103145: 0f a0 push %fs - 103147: 06 push %es - 103148: 1e push %ds - 103149: 60 pusha - 10314a: 66 b8 10 00 mov $0x10,%ax - 10314e: 8e d8 mov %eax,%ds - 103150: 8e c0 mov %eax,%es - 103152: 8e e0 mov %eax,%fs - 103154: 8e e8 mov %eax,%gs - 103156: 89 e0 mov %esp,%eax - 103158: 50 push %eax - -00103159 : - 103159: b8 04 3e 10 00 mov $0x103e04,%eax - 10315e: ff d0 call *%eax - 103160: e9 83 e5 ff ff jmp 1016e8 - -00103165 : - 103165: 6a 00 push $0x0 - 103167: 6a af push $0xffffffaf - 103169: 0f a8 push %gs - 10316b: 0f a0 push %fs - 10316d: 06 push %es - 10316e: 1e push %ds - 10316f: 60 pusha - 103170: 66 b8 10 00 mov $0x10,%ax - 103174: 8e d8 mov %eax,%ds - 103176: 8e c0 mov %eax,%es - 103178: 8e e0 mov %eax,%fs - 10317a: 8e e8 mov %eax,%gs - 10317c: 89 e0 mov %esp,%eax - 10317e: 50 push %eax - -0010317f : - 10317f: b8 04 3e 10 00 mov $0x103e04,%eax - 103184: ff d0 call *%eax - 103186: e9 5d e5 ff ff jmp 1016e8 - -0010318b : - 10318b: 6a 00 push $0x0 - 10318d: 6a b0 push $0xffffffb0 - 10318f: 0f a8 push %gs - 103191: 0f a0 push %fs - 103193: 06 push %es - 103194: 1e push %ds - 103195: 60 pusha - 103196: 66 b8 10 00 mov $0x10,%ax - 10319a: 8e d8 mov %eax,%ds - 10319c: 8e c0 mov %eax,%es - 10319e: 8e e0 mov %eax,%fs - 1031a0: 8e e8 mov %eax,%gs - 1031a2: 89 e0 mov %esp,%eax - 1031a4: 50 push %eax - -001031a5 : - 1031a5: b8 04 3e 10 00 mov $0x103e04,%eax - 1031aa: ff d0 call *%eax - 1031ac: e9 37 e5 ff ff jmp 1016e8 - -001031b1 : - 1031b1: 6a 00 push $0x0 - 1031b3: 6a b1 push $0xffffffb1 - 1031b5: 0f a8 push %gs - 1031b7: 0f a0 push %fs - 1031b9: 06 push %es - 1031ba: 1e push %ds - 1031bb: 60 pusha - 1031bc: 66 b8 10 00 mov $0x10,%ax - 1031c0: 8e d8 mov %eax,%ds - 1031c2: 8e c0 mov %eax,%es - 1031c4: 8e e0 mov %eax,%fs - 1031c6: 8e e8 mov %eax,%gs - 1031c8: 89 e0 mov %esp,%eax - 1031ca: 50 push %eax - -001031cb : - 1031cb: b8 04 3e 10 00 mov $0x103e04,%eax - 1031d0: ff d0 call *%eax - 1031d2: e9 11 e5 ff ff jmp 1016e8 - -001031d7 : - 1031d7: 6a 00 push $0x0 - 1031d9: 6a b2 push $0xffffffb2 - 1031db: 0f a8 push %gs - 1031dd: 0f a0 push %fs - 1031df: 06 push %es - 1031e0: 1e push %ds - 1031e1: 60 pusha - 1031e2: 66 b8 10 00 mov $0x10,%ax - 1031e6: 8e d8 mov %eax,%ds - 1031e8: 8e c0 mov %eax,%es - 1031ea: 8e e0 mov %eax,%fs - 1031ec: 8e e8 mov %eax,%gs - 1031ee: 89 e0 mov %esp,%eax - 1031f0: 50 push %eax - -001031f1 : - 1031f1: b8 04 3e 10 00 mov $0x103e04,%eax - 1031f6: ff d0 call *%eax - 1031f8: e9 eb e4 ff ff jmp 1016e8 - -001031fd : - 1031fd: 6a 00 push $0x0 - 1031ff: 6a b3 push $0xffffffb3 - 103201: 0f a8 push %gs - 103203: 0f a0 push %fs - 103205: 06 push %es - 103206: 1e push %ds - 103207: 60 pusha - 103208: 66 b8 10 00 mov $0x10,%ax - 10320c: 8e d8 mov %eax,%ds - 10320e: 8e c0 mov %eax,%es - 103210: 8e e0 mov %eax,%fs - 103212: 8e e8 mov %eax,%gs - 103214: 89 e0 mov %esp,%eax - 103216: 50 push %eax - -00103217 : - 103217: b8 04 3e 10 00 mov $0x103e04,%eax - 10321c: ff d0 call *%eax - 10321e: e9 c5 e4 ff ff jmp 1016e8 - -00103223 : - 103223: 6a 00 push $0x0 - 103225: 6a b4 push $0xffffffb4 - 103227: 0f a8 push %gs - 103229: 0f a0 push %fs - 10322b: 06 push %es - 10322c: 1e push %ds - 10322d: 60 pusha - 10322e: 66 b8 10 00 mov $0x10,%ax - 103232: 8e d8 mov %eax,%ds - 103234: 8e c0 mov %eax,%es - 103236: 8e e0 mov %eax,%fs - 103238: 8e e8 mov %eax,%gs - 10323a: 89 e0 mov %esp,%eax - 10323c: 50 push %eax - -0010323d : - 10323d: b8 04 3e 10 00 mov $0x103e04,%eax - 103242: ff d0 call *%eax - 103244: e9 9f e4 ff ff jmp 1016e8 - -00103249 : - 103249: 6a 00 push $0x0 - 10324b: 6a b5 push $0xffffffb5 - 10324d: 0f a8 push %gs - 10324f: 0f a0 push %fs - 103251: 06 push %es - 103252: 1e push %ds - 103253: 60 pusha - 103254: 66 b8 10 00 mov $0x10,%ax - 103258: 8e d8 mov %eax,%ds - 10325a: 8e c0 mov %eax,%es - 10325c: 8e e0 mov %eax,%fs - 10325e: 8e e8 mov %eax,%gs - 103260: 89 e0 mov %esp,%eax - 103262: 50 push %eax - -00103263 : - 103263: b8 04 3e 10 00 mov $0x103e04,%eax - 103268: ff d0 call *%eax - 10326a: e9 79 e4 ff ff jmp 1016e8 - -0010326f : - 10326f: 6a 00 push $0x0 - 103271: 6a b6 push $0xffffffb6 - 103273: 0f a8 push %gs - 103275: 0f a0 push %fs - 103277: 06 push %es - 103278: 1e push %ds - 103279: 60 pusha - 10327a: 66 b8 10 00 mov $0x10,%ax - 10327e: 8e d8 mov %eax,%ds - 103280: 8e c0 mov %eax,%es - 103282: 8e e0 mov %eax,%fs - 103284: 8e e8 mov %eax,%gs - 103286: 89 e0 mov %esp,%eax - 103288: 50 push %eax - -00103289 : - 103289: b8 04 3e 10 00 mov $0x103e04,%eax - 10328e: ff d0 call *%eax - 103290: e9 53 e4 ff ff jmp 1016e8 - -00103295 : - 103295: 6a 00 push $0x0 - 103297: 6a b7 push $0xffffffb7 - 103299: 0f a8 push %gs - 10329b: 0f a0 push %fs - 10329d: 06 push %es - 10329e: 1e push %ds - 10329f: 60 pusha - 1032a0: 66 b8 10 00 mov $0x10,%ax - 1032a4: 8e d8 mov %eax,%ds - 1032a6: 8e c0 mov %eax,%es - 1032a8: 8e e0 mov %eax,%fs - 1032aa: 8e e8 mov %eax,%gs - 1032ac: 89 e0 mov %esp,%eax - 1032ae: 50 push %eax - -001032af : - 1032af: b8 04 3e 10 00 mov $0x103e04,%eax - 1032b4: ff d0 call *%eax - 1032b6: e9 2d e4 ff ff jmp 1016e8 - -001032bb : - 1032bb: 6a 00 push $0x0 - 1032bd: 6a b8 push $0xffffffb8 - 1032bf: 0f a8 push %gs - 1032c1: 0f a0 push %fs - 1032c3: 06 push %es - 1032c4: 1e push %ds - 1032c5: 60 pusha - 1032c6: 66 b8 10 00 mov $0x10,%ax - 1032ca: 8e d8 mov %eax,%ds - 1032cc: 8e c0 mov %eax,%es - 1032ce: 8e e0 mov %eax,%fs - 1032d0: 8e e8 mov %eax,%gs - 1032d2: 89 e0 mov %esp,%eax - 1032d4: 50 push %eax - -001032d5 : - 1032d5: b8 04 3e 10 00 mov $0x103e04,%eax - 1032da: ff d0 call *%eax - 1032dc: e9 07 e4 ff ff jmp 1016e8 - -001032e1 : - 1032e1: 6a 00 push $0x0 - 1032e3: 6a b9 push $0xffffffb9 - 1032e5: 0f a8 push %gs - 1032e7: 0f a0 push %fs - 1032e9: 06 push %es - 1032ea: 1e push %ds - 1032eb: 60 pusha - 1032ec: 66 b8 10 00 mov $0x10,%ax - 1032f0: 8e d8 mov %eax,%ds - 1032f2: 8e c0 mov %eax,%es - 1032f4: 8e e0 mov %eax,%fs - 1032f6: 8e e8 mov %eax,%gs - 1032f8: 89 e0 mov %esp,%eax - 1032fa: 50 push %eax - -001032fb : - 1032fb: b8 04 3e 10 00 mov $0x103e04,%eax - 103300: ff d0 call *%eax - 103302: e9 e1 e3 ff ff jmp 1016e8 - -00103307 : - 103307: 6a 00 push $0x0 - 103309: 6a ba push $0xffffffba - 10330b: 0f a8 push %gs - 10330d: 0f a0 push %fs - 10330f: 06 push %es - 103310: 1e push %ds - 103311: 60 pusha - 103312: 66 b8 10 00 mov $0x10,%ax - 103316: 8e d8 mov %eax,%ds - 103318: 8e c0 mov %eax,%es - 10331a: 8e e0 mov %eax,%fs - 10331c: 8e e8 mov %eax,%gs - 10331e: 89 e0 mov %esp,%eax - 103320: 50 push %eax - -00103321 : - 103321: b8 04 3e 10 00 mov $0x103e04,%eax - 103326: ff d0 call *%eax - 103328: e9 bb e3 ff ff jmp 1016e8 - -0010332d : - 10332d: 6a 00 push $0x0 - 10332f: 6a bb push $0xffffffbb - 103331: 0f a8 push %gs - 103333: 0f a0 push %fs - 103335: 06 push %es - 103336: 1e push %ds - 103337: 60 pusha - 103338: 66 b8 10 00 mov $0x10,%ax - 10333c: 8e d8 mov %eax,%ds - 10333e: 8e c0 mov %eax,%es - 103340: 8e e0 mov %eax,%fs - 103342: 8e e8 mov %eax,%gs - 103344: 89 e0 mov %esp,%eax - 103346: 50 push %eax - -00103347 : - 103347: b8 04 3e 10 00 mov $0x103e04,%eax - 10334c: ff d0 call *%eax - 10334e: e9 95 e3 ff ff jmp 1016e8 - -00103353 : - 103353: 6a 00 push $0x0 - 103355: 6a bc push $0xffffffbc - 103357: 0f a8 push %gs - 103359: 0f a0 push %fs - 10335b: 06 push %es - 10335c: 1e push %ds - 10335d: 60 pusha - 10335e: 66 b8 10 00 mov $0x10,%ax - 103362: 8e d8 mov %eax,%ds - 103364: 8e c0 mov %eax,%es - 103366: 8e e0 mov %eax,%fs - 103368: 8e e8 mov %eax,%gs - 10336a: 89 e0 mov %esp,%eax - 10336c: 50 push %eax - -0010336d : - 10336d: b8 04 3e 10 00 mov $0x103e04,%eax - 103372: ff d0 call *%eax - 103374: e9 6f e3 ff ff jmp 1016e8 - -00103379 : - 103379: 6a 00 push $0x0 - 10337b: 6a bd push $0xffffffbd - 10337d: 0f a8 push %gs - 10337f: 0f a0 push %fs - 103381: 06 push %es - 103382: 1e push %ds - 103383: 60 pusha - 103384: 66 b8 10 00 mov $0x10,%ax - 103388: 8e d8 mov %eax,%ds - 10338a: 8e c0 mov %eax,%es - 10338c: 8e e0 mov %eax,%fs - 10338e: 8e e8 mov %eax,%gs - 103390: 89 e0 mov %esp,%eax - 103392: 50 push %eax - -00103393 : - 103393: b8 04 3e 10 00 mov $0x103e04,%eax - 103398: ff d0 call *%eax - 10339a: e9 49 e3 ff ff jmp 1016e8 - -0010339f : - 10339f: 6a 00 push $0x0 - 1033a1: 6a be push $0xffffffbe - 1033a3: 0f a8 push %gs - 1033a5: 0f a0 push %fs - 1033a7: 06 push %es - 1033a8: 1e push %ds - 1033a9: 60 pusha - 1033aa: 66 b8 10 00 mov $0x10,%ax - 1033ae: 8e d8 mov %eax,%ds - 1033b0: 8e c0 mov %eax,%es - 1033b2: 8e e0 mov %eax,%fs - 1033b4: 8e e8 mov %eax,%gs - 1033b6: 89 e0 mov %esp,%eax - 1033b8: 50 push %eax - -001033b9 : - 1033b9: b8 04 3e 10 00 mov $0x103e04,%eax - 1033be: ff d0 call *%eax - 1033c0: e9 23 e3 ff ff jmp 1016e8 - -001033c5 : - 1033c5: 6a 00 push $0x0 - 1033c7: 6a bf push $0xffffffbf - 1033c9: 0f a8 push %gs - 1033cb: 0f a0 push %fs - 1033cd: 06 push %es - 1033ce: 1e push %ds - 1033cf: 60 pusha - 1033d0: 66 b8 10 00 mov $0x10,%ax - 1033d4: 8e d8 mov %eax,%ds - 1033d6: 8e c0 mov %eax,%es - 1033d8: 8e e0 mov %eax,%fs - 1033da: 8e e8 mov %eax,%gs - 1033dc: 89 e0 mov %esp,%eax - 1033de: 50 push %eax - -001033df : - 1033df: b8 04 3e 10 00 mov $0x103e04,%eax - 1033e4: ff d0 call *%eax - 1033e6: e9 fd e2 ff ff jmp 1016e8 - -001033eb : - 1033eb: 6a 00 push $0x0 - 1033ed: 6a c0 push $0xffffffc0 - 1033ef: 0f a8 push %gs - 1033f1: 0f a0 push %fs - 1033f3: 06 push %es - 1033f4: 1e push %ds - 1033f5: 60 pusha - 1033f6: 66 b8 10 00 mov $0x10,%ax - 1033fa: 8e d8 mov %eax,%ds - 1033fc: 8e c0 mov %eax,%es - 1033fe: 8e e0 mov %eax,%fs - 103400: 8e e8 mov %eax,%gs - 103402: 89 e0 mov %esp,%eax - 103404: 50 push %eax - -00103405 : - 103405: b8 04 3e 10 00 mov $0x103e04,%eax - 10340a: ff d0 call *%eax - 10340c: e9 d7 e2 ff ff jmp 1016e8 - -00103411 : - 103411: 6a 00 push $0x0 - 103413: 6a c1 push $0xffffffc1 - 103415: 0f a8 push %gs - 103417: 0f a0 push %fs - 103419: 06 push %es - 10341a: 1e push %ds - 10341b: 60 pusha - 10341c: 66 b8 10 00 mov $0x10,%ax - 103420: 8e d8 mov %eax,%ds - 103422: 8e c0 mov %eax,%es - 103424: 8e e0 mov %eax,%fs - 103426: 8e e8 mov %eax,%gs - 103428: 89 e0 mov %esp,%eax - 10342a: 50 push %eax - -0010342b : - 10342b: b8 04 3e 10 00 mov $0x103e04,%eax - 103430: ff d0 call *%eax - 103432: e9 b1 e2 ff ff jmp 1016e8 - -00103437 : - 103437: 6a 00 push $0x0 - 103439: 6a c2 push $0xffffffc2 - 10343b: 0f a8 push %gs - 10343d: 0f a0 push %fs - 10343f: 06 push %es - 103440: 1e push %ds - 103441: 60 pusha - 103442: 66 b8 10 00 mov $0x10,%ax - 103446: 8e d8 mov %eax,%ds - 103448: 8e c0 mov %eax,%es - 10344a: 8e e0 mov %eax,%fs - 10344c: 8e e8 mov %eax,%gs - 10344e: 89 e0 mov %esp,%eax - 103450: 50 push %eax - -00103451 : - 103451: b8 04 3e 10 00 mov $0x103e04,%eax - 103456: ff d0 call *%eax - 103458: e9 8b e2 ff ff jmp 1016e8 - -0010345d : - 10345d: 6a 00 push $0x0 - 10345f: 6a c3 push $0xffffffc3 - 103461: 0f a8 push %gs - 103463: 0f a0 push %fs - 103465: 06 push %es - 103466: 1e push %ds - 103467: 60 pusha - 103468: 66 b8 10 00 mov $0x10,%ax - 10346c: 8e d8 mov %eax,%ds - 10346e: 8e c0 mov %eax,%es - 103470: 8e e0 mov %eax,%fs - 103472: 8e e8 mov %eax,%gs - 103474: 89 e0 mov %esp,%eax - 103476: 50 push %eax - -00103477 : - 103477: b8 04 3e 10 00 mov $0x103e04,%eax - 10347c: ff d0 call *%eax - 10347e: e9 65 e2 ff ff jmp 1016e8 - -00103483 : - 103483: 6a 00 push $0x0 - 103485: 6a c4 push $0xffffffc4 - 103487: 0f a8 push %gs - 103489: 0f a0 push %fs - 10348b: 06 push %es - 10348c: 1e push %ds - 10348d: 60 pusha - 10348e: 66 b8 10 00 mov $0x10,%ax - 103492: 8e d8 mov %eax,%ds - 103494: 8e c0 mov %eax,%es - 103496: 8e e0 mov %eax,%fs - 103498: 8e e8 mov %eax,%gs - 10349a: 89 e0 mov %esp,%eax - 10349c: 50 push %eax - -0010349d : - 10349d: b8 04 3e 10 00 mov $0x103e04,%eax - 1034a2: ff d0 call *%eax - 1034a4: e9 3f e2 ff ff jmp 1016e8 - -001034a9 : - 1034a9: 6a 00 push $0x0 - 1034ab: 6a c5 push $0xffffffc5 - 1034ad: 0f a8 push %gs - 1034af: 0f a0 push %fs - 1034b1: 06 push %es - 1034b2: 1e push %ds - 1034b3: 60 pusha - 1034b4: 66 b8 10 00 mov $0x10,%ax - 1034b8: 8e d8 mov %eax,%ds - 1034ba: 8e c0 mov %eax,%es - 1034bc: 8e e0 mov %eax,%fs - 1034be: 8e e8 mov %eax,%gs - 1034c0: 89 e0 mov %esp,%eax - 1034c2: 50 push %eax - -001034c3 : - 1034c3: b8 04 3e 10 00 mov $0x103e04,%eax - 1034c8: ff d0 call *%eax - 1034ca: e9 19 e2 ff ff jmp 1016e8 - -001034cf : - 1034cf: 6a 00 push $0x0 - 1034d1: 6a c6 push $0xffffffc6 - 1034d3: 0f a8 push %gs - 1034d5: 0f a0 push %fs - 1034d7: 06 push %es - 1034d8: 1e push %ds - 1034d9: 60 pusha - 1034da: 66 b8 10 00 mov $0x10,%ax - 1034de: 8e d8 mov %eax,%ds - 1034e0: 8e c0 mov %eax,%es - 1034e2: 8e e0 mov %eax,%fs - 1034e4: 8e e8 mov %eax,%gs - 1034e6: 89 e0 mov %esp,%eax - 1034e8: 50 push %eax - -001034e9 : - 1034e9: b8 04 3e 10 00 mov $0x103e04,%eax - 1034ee: ff d0 call *%eax - 1034f0: e9 f3 e1 ff ff jmp 1016e8 - -001034f5 : - 1034f5: 6a 00 push $0x0 - 1034f7: 6a c7 push $0xffffffc7 - 1034f9: 0f a8 push %gs - 1034fb: 0f a0 push %fs - 1034fd: 06 push %es - 1034fe: 1e push %ds - 1034ff: 60 pusha - 103500: 66 b8 10 00 mov $0x10,%ax - 103504: 8e d8 mov %eax,%ds - 103506: 8e c0 mov %eax,%es - 103508: 8e e0 mov %eax,%fs - 10350a: 8e e8 mov %eax,%gs - 10350c: 89 e0 mov %esp,%eax - 10350e: 50 push %eax - -0010350f : - 10350f: b8 04 3e 10 00 mov $0x103e04,%eax - 103514: ff d0 call *%eax - 103516: e9 cd e1 ff ff jmp 1016e8 - -0010351b : - 10351b: 6a 00 push $0x0 - 10351d: 6a c8 push $0xffffffc8 - 10351f: 0f a8 push %gs - 103521: 0f a0 push %fs - 103523: 06 push %es - 103524: 1e push %ds - 103525: 60 pusha - 103526: 66 b8 10 00 mov $0x10,%ax - 10352a: 8e d8 mov %eax,%ds - 10352c: 8e c0 mov %eax,%es - 10352e: 8e e0 mov %eax,%fs - 103530: 8e e8 mov %eax,%gs - 103532: 89 e0 mov %esp,%eax - 103534: 50 push %eax - -00103535 : - 103535: b8 04 3e 10 00 mov $0x103e04,%eax - 10353a: ff d0 call *%eax - 10353c: e9 a7 e1 ff ff jmp 1016e8 - -00103541 : - 103541: 6a 00 push $0x0 - 103543: 6a c9 push $0xffffffc9 - 103545: 0f a8 push %gs - 103547: 0f a0 push %fs - 103549: 06 push %es - 10354a: 1e push %ds - 10354b: 60 pusha - 10354c: 66 b8 10 00 mov $0x10,%ax - 103550: 8e d8 mov %eax,%ds - 103552: 8e c0 mov %eax,%es - 103554: 8e e0 mov %eax,%fs - 103556: 8e e8 mov %eax,%gs - 103558: 89 e0 mov %esp,%eax - 10355a: 50 push %eax - -0010355b : - 10355b: b8 04 3e 10 00 mov $0x103e04,%eax - 103560: ff d0 call *%eax - 103562: e9 81 e1 ff ff jmp 1016e8 - -00103567 : - 103567: 6a 00 push $0x0 - 103569: 6a ca push $0xffffffca - 10356b: 0f a8 push %gs - 10356d: 0f a0 push %fs - 10356f: 06 push %es - 103570: 1e push %ds - 103571: 60 pusha - 103572: 66 b8 10 00 mov $0x10,%ax - 103576: 8e d8 mov %eax,%ds - 103578: 8e c0 mov %eax,%es - 10357a: 8e e0 mov %eax,%fs - 10357c: 8e e8 mov %eax,%gs - 10357e: 89 e0 mov %esp,%eax - 103580: 50 push %eax - -00103581 : - 103581: b8 04 3e 10 00 mov $0x103e04,%eax - 103586: ff d0 call *%eax - 103588: e9 5b e1 ff ff jmp 1016e8 - -0010358d : - 10358d: 6a 00 push $0x0 - 10358f: 6a cb push $0xffffffcb - 103591: 0f a8 push %gs - 103593: 0f a0 push %fs - 103595: 06 push %es - 103596: 1e push %ds - 103597: 60 pusha - 103598: 66 b8 10 00 mov $0x10,%ax - 10359c: 8e d8 mov %eax,%ds - 10359e: 8e c0 mov %eax,%es - 1035a0: 8e e0 mov %eax,%fs - 1035a2: 8e e8 mov %eax,%gs - 1035a4: 89 e0 mov %esp,%eax - 1035a6: 50 push %eax - -001035a7 : - 1035a7: b8 04 3e 10 00 mov $0x103e04,%eax - 1035ac: ff d0 call *%eax - 1035ae: e9 35 e1 ff ff jmp 1016e8 - -001035b3 : - 1035b3: 6a 00 push $0x0 - 1035b5: 6a cc push $0xffffffcc - 1035b7: 0f a8 push %gs - 1035b9: 0f a0 push %fs - 1035bb: 06 push %es - 1035bc: 1e push %ds - 1035bd: 60 pusha - 1035be: 66 b8 10 00 mov $0x10,%ax - 1035c2: 8e d8 mov %eax,%ds - 1035c4: 8e c0 mov %eax,%es - 1035c6: 8e e0 mov %eax,%fs - 1035c8: 8e e8 mov %eax,%gs - 1035ca: 89 e0 mov %esp,%eax - 1035cc: 50 push %eax - -001035cd : - 1035cd: b8 04 3e 10 00 mov $0x103e04,%eax - 1035d2: ff d0 call *%eax - 1035d4: e9 0f e1 ff ff jmp 1016e8 - -001035d9 : - 1035d9: 6a 00 push $0x0 - 1035db: 6a cd push $0xffffffcd - 1035dd: 0f a8 push %gs - 1035df: 0f a0 push %fs - 1035e1: 06 push %es - 1035e2: 1e push %ds - 1035e3: 60 pusha - 1035e4: 66 b8 10 00 mov $0x10,%ax - 1035e8: 8e d8 mov %eax,%ds - 1035ea: 8e c0 mov %eax,%es - 1035ec: 8e e0 mov %eax,%fs - 1035ee: 8e e8 mov %eax,%gs - 1035f0: 89 e0 mov %esp,%eax - 1035f2: 50 push %eax - -001035f3 : - 1035f3: b8 04 3e 10 00 mov $0x103e04,%eax - 1035f8: ff d0 call *%eax - 1035fa: e9 e9 e0 ff ff jmp 1016e8 - -001035ff : - 1035ff: 6a 00 push $0x0 - 103601: 6a ce push $0xffffffce - 103603: 0f a8 push %gs - 103605: 0f a0 push %fs - 103607: 06 push %es - 103608: 1e push %ds - 103609: 60 pusha - 10360a: 66 b8 10 00 mov $0x10,%ax - 10360e: 8e d8 mov %eax,%ds - 103610: 8e c0 mov %eax,%es - 103612: 8e e0 mov %eax,%fs - 103614: 8e e8 mov %eax,%gs - 103616: 89 e0 mov %esp,%eax - 103618: 50 push %eax - -00103619 : - 103619: b8 04 3e 10 00 mov $0x103e04,%eax - 10361e: ff d0 call *%eax - 103620: e9 c3 e0 ff ff jmp 1016e8 - -00103625 : - 103625: 6a 00 push $0x0 - 103627: 6a cf push $0xffffffcf - 103629: 0f a8 push %gs - 10362b: 0f a0 push %fs - 10362d: 06 push %es - 10362e: 1e push %ds - 10362f: 60 pusha - 103630: 66 b8 10 00 mov $0x10,%ax - 103634: 8e d8 mov %eax,%ds - 103636: 8e c0 mov %eax,%es - 103638: 8e e0 mov %eax,%fs - 10363a: 8e e8 mov %eax,%gs - 10363c: 89 e0 mov %esp,%eax - 10363e: 50 push %eax - -0010363f : - 10363f: b8 04 3e 10 00 mov $0x103e04,%eax - 103644: ff d0 call *%eax - 103646: e9 9d e0 ff ff jmp 1016e8 - -0010364b : - 10364b: 6a 00 push $0x0 - 10364d: 6a d0 push $0xffffffd0 - 10364f: 0f a8 push %gs - 103651: 0f a0 push %fs - 103653: 06 push %es - 103654: 1e push %ds - 103655: 60 pusha - 103656: 66 b8 10 00 mov $0x10,%ax - 10365a: 8e d8 mov %eax,%ds - 10365c: 8e c0 mov %eax,%es - 10365e: 8e e0 mov %eax,%fs - 103660: 8e e8 mov %eax,%gs - 103662: 89 e0 mov %esp,%eax - 103664: 50 push %eax - -00103665 : - 103665: b8 04 3e 10 00 mov $0x103e04,%eax - 10366a: ff d0 call *%eax - 10366c: e9 77 e0 ff ff jmp 1016e8 - -00103671 : - 103671: 6a 00 push $0x0 - 103673: 6a d1 push $0xffffffd1 - 103675: 0f a8 push %gs - 103677: 0f a0 push %fs - 103679: 06 push %es - 10367a: 1e push %ds - 10367b: 60 pusha - 10367c: 66 b8 10 00 mov $0x10,%ax - 103680: 8e d8 mov %eax,%ds - 103682: 8e c0 mov %eax,%es - 103684: 8e e0 mov %eax,%fs - 103686: 8e e8 mov %eax,%gs - 103688: 89 e0 mov %esp,%eax - 10368a: 50 push %eax - -0010368b : - 10368b: b8 04 3e 10 00 mov $0x103e04,%eax - 103690: ff d0 call *%eax - 103692: e9 51 e0 ff ff jmp 1016e8 - -00103697 : - 103697: 6a 00 push $0x0 - 103699: 6a d2 push $0xffffffd2 - 10369b: 0f a8 push %gs - 10369d: 0f a0 push %fs - 10369f: 06 push %es - 1036a0: 1e push %ds - 1036a1: 60 pusha - 1036a2: 66 b8 10 00 mov $0x10,%ax - 1036a6: 8e d8 mov %eax,%ds - 1036a8: 8e c0 mov %eax,%es - 1036aa: 8e e0 mov %eax,%fs - 1036ac: 8e e8 mov %eax,%gs - 1036ae: 89 e0 mov %esp,%eax - 1036b0: 50 push %eax - -001036b1 : - 1036b1: b8 04 3e 10 00 mov $0x103e04,%eax - 1036b6: ff d0 call *%eax - 1036b8: e9 2b e0 ff ff jmp 1016e8 - -001036bd : - 1036bd: 6a 00 push $0x0 - 1036bf: 6a d3 push $0xffffffd3 - 1036c1: 0f a8 push %gs - 1036c3: 0f a0 push %fs - 1036c5: 06 push %es - 1036c6: 1e push %ds - 1036c7: 60 pusha - 1036c8: 66 b8 10 00 mov $0x10,%ax - 1036cc: 8e d8 mov %eax,%ds - 1036ce: 8e c0 mov %eax,%es - 1036d0: 8e e0 mov %eax,%fs - 1036d2: 8e e8 mov %eax,%gs - 1036d4: 89 e0 mov %esp,%eax - 1036d6: 50 push %eax - -001036d7 : - 1036d7: b8 04 3e 10 00 mov $0x103e04,%eax - 1036dc: ff d0 call *%eax - 1036de: e9 05 e0 ff ff jmp 1016e8 - -001036e3 : - 1036e3: 6a 00 push $0x0 - 1036e5: 6a d4 push $0xffffffd4 - 1036e7: 0f a8 push %gs - 1036e9: 0f a0 push %fs - 1036eb: 06 push %es - 1036ec: 1e push %ds - 1036ed: 60 pusha - 1036ee: 66 b8 10 00 mov $0x10,%ax - 1036f2: 8e d8 mov %eax,%ds - 1036f4: 8e c0 mov %eax,%es - 1036f6: 8e e0 mov %eax,%fs - 1036f8: 8e e8 mov %eax,%gs - 1036fa: 89 e0 mov %esp,%eax - 1036fc: 50 push %eax - -001036fd : - 1036fd: b8 04 3e 10 00 mov $0x103e04,%eax - 103702: ff d0 call *%eax - 103704: e9 df df ff ff jmp 1016e8 - -00103709 : - 103709: 6a 00 push $0x0 - 10370b: 6a d5 push $0xffffffd5 - 10370d: 0f a8 push %gs - 10370f: 0f a0 push %fs - 103711: 06 push %es - 103712: 1e push %ds - 103713: 60 pusha - 103714: 66 b8 10 00 mov $0x10,%ax - 103718: 8e d8 mov %eax,%ds - 10371a: 8e c0 mov %eax,%es - 10371c: 8e e0 mov %eax,%fs - 10371e: 8e e8 mov %eax,%gs - 103720: 89 e0 mov %esp,%eax - 103722: 50 push %eax - -00103723 : - 103723: b8 04 3e 10 00 mov $0x103e04,%eax - 103728: ff d0 call *%eax - 10372a: e9 b9 df ff ff jmp 1016e8 - -0010372f : - 10372f: 6a 00 push $0x0 - 103731: 6a d6 push $0xffffffd6 - 103733: 0f a8 push %gs - 103735: 0f a0 push %fs - 103737: 06 push %es - 103738: 1e push %ds - 103739: 60 pusha - 10373a: 66 b8 10 00 mov $0x10,%ax - 10373e: 8e d8 mov %eax,%ds - 103740: 8e c0 mov %eax,%es - 103742: 8e e0 mov %eax,%fs - 103744: 8e e8 mov %eax,%gs - 103746: 89 e0 mov %esp,%eax - 103748: 50 push %eax - -00103749 : - 103749: b8 04 3e 10 00 mov $0x103e04,%eax - 10374e: ff d0 call *%eax - 103750: e9 93 df ff ff jmp 1016e8 - -00103755 : - 103755: 6a 00 push $0x0 - 103757: 6a d7 push $0xffffffd7 - 103759: 0f a8 push %gs - 10375b: 0f a0 push %fs - 10375d: 06 push %es - 10375e: 1e push %ds - 10375f: 60 pusha - 103760: 66 b8 10 00 mov $0x10,%ax - 103764: 8e d8 mov %eax,%ds - 103766: 8e c0 mov %eax,%es - 103768: 8e e0 mov %eax,%fs - 10376a: 8e e8 mov %eax,%gs - 10376c: 89 e0 mov %esp,%eax - 10376e: 50 push %eax - -0010376f : - 10376f: b8 04 3e 10 00 mov $0x103e04,%eax - 103774: ff d0 call *%eax - 103776: e9 6d df ff ff jmp 1016e8 - -0010377b : - 10377b: 6a 00 push $0x0 - 10377d: 6a d8 push $0xffffffd8 - 10377f: 0f a8 push %gs - 103781: 0f a0 push %fs - 103783: 06 push %es - 103784: 1e push %ds - 103785: 60 pusha - 103786: 66 b8 10 00 mov $0x10,%ax - 10378a: 8e d8 mov %eax,%ds - 10378c: 8e c0 mov %eax,%es - 10378e: 8e e0 mov %eax,%fs - 103790: 8e e8 mov %eax,%gs - 103792: 89 e0 mov %esp,%eax - 103794: 50 push %eax - -00103795 : - 103795: b8 04 3e 10 00 mov $0x103e04,%eax - 10379a: ff d0 call *%eax - 10379c: e9 47 df ff ff jmp 1016e8 - -001037a1 : - 1037a1: 6a 00 push $0x0 - 1037a3: 6a d9 push $0xffffffd9 - 1037a5: 0f a8 push %gs - 1037a7: 0f a0 push %fs - 1037a9: 06 push %es - 1037aa: 1e push %ds - 1037ab: 60 pusha - 1037ac: 66 b8 10 00 mov $0x10,%ax - 1037b0: 8e d8 mov %eax,%ds - 1037b2: 8e c0 mov %eax,%es - 1037b4: 8e e0 mov %eax,%fs - 1037b6: 8e e8 mov %eax,%gs - 1037b8: 89 e0 mov %esp,%eax - 1037ba: 50 push %eax - -001037bb : - 1037bb: b8 04 3e 10 00 mov $0x103e04,%eax - 1037c0: ff d0 call *%eax - 1037c2: e9 21 df ff ff jmp 1016e8 - -001037c7 : - 1037c7: 6a 00 push $0x0 - 1037c9: 6a da push $0xffffffda - 1037cb: 0f a8 push %gs - 1037cd: 0f a0 push %fs - 1037cf: 06 push %es - 1037d0: 1e push %ds - 1037d1: 60 pusha - 1037d2: 66 b8 10 00 mov $0x10,%ax - 1037d6: 8e d8 mov %eax,%ds - 1037d8: 8e c0 mov %eax,%es - 1037da: 8e e0 mov %eax,%fs - 1037dc: 8e e8 mov %eax,%gs - 1037de: 89 e0 mov %esp,%eax - 1037e0: 50 push %eax - -001037e1 : - 1037e1: b8 04 3e 10 00 mov $0x103e04,%eax - 1037e6: ff d0 call *%eax - 1037e8: e9 fb de ff ff jmp 1016e8 - -001037ed : - 1037ed: 6a 00 push $0x0 - 1037ef: 6a db push $0xffffffdb - 1037f1: 0f a8 push %gs - 1037f3: 0f a0 push %fs - 1037f5: 06 push %es - 1037f6: 1e push %ds - 1037f7: 60 pusha - 1037f8: 66 b8 10 00 mov $0x10,%ax - 1037fc: 8e d8 mov %eax,%ds - 1037fe: 8e c0 mov %eax,%es - 103800: 8e e0 mov %eax,%fs - 103802: 8e e8 mov %eax,%gs - 103804: 89 e0 mov %esp,%eax - 103806: 50 push %eax - -00103807 : - 103807: b8 04 3e 10 00 mov $0x103e04,%eax - 10380c: ff d0 call *%eax - 10380e: e9 d5 de ff ff jmp 1016e8 - -00103813 : - 103813: 6a 00 push $0x0 - 103815: 6a dc push $0xffffffdc - 103817: 0f a8 push %gs - 103819: 0f a0 push %fs - 10381b: 06 push %es - 10381c: 1e push %ds - 10381d: 60 pusha - 10381e: 66 b8 10 00 mov $0x10,%ax - 103822: 8e d8 mov %eax,%ds - 103824: 8e c0 mov %eax,%es - 103826: 8e e0 mov %eax,%fs - 103828: 8e e8 mov %eax,%gs - 10382a: 89 e0 mov %esp,%eax - 10382c: 50 push %eax - -0010382d : - 10382d: b8 04 3e 10 00 mov $0x103e04,%eax - 103832: ff d0 call *%eax - 103834: e9 af de ff ff jmp 1016e8 - -00103839 : - 103839: 6a 00 push $0x0 - 10383b: 6a dd push $0xffffffdd - 10383d: 0f a8 push %gs - 10383f: 0f a0 push %fs - 103841: 06 push %es - 103842: 1e push %ds - 103843: 60 pusha - 103844: 66 b8 10 00 mov $0x10,%ax - 103848: 8e d8 mov %eax,%ds - 10384a: 8e c0 mov %eax,%es - 10384c: 8e e0 mov %eax,%fs - 10384e: 8e e8 mov %eax,%gs - 103850: 89 e0 mov %esp,%eax - 103852: 50 push %eax - -00103853 : - 103853: b8 04 3e 10 00 mov $0x103e04,%eax - 103858: ff d0 call *%eax - 10385a: e9 89 de ff ff jmp 1016e8 - -0010385f : - 10385f: 6a 00 push $0x0 - 103861: 6a de push $0xffffffde - 103863: 0f a8 push %gs - 103865: 0f a0 push %fs - 103867: 06 push %es - 103868: 1e push %ds - 103869: 60 pusha - 10386a: 66 b8 10 00 mov $0x10,%ax - 10386e: 8e d8 mov %eax,%ds - 103870: 8e c0 mov %eax,%es - 103872: 8e e0 mov %eax,%fs - 103874: 8e e8 mov %eax,%gs - 103876: 89 e0 mov %esp,%eax - 103878: 50 push %eax - -00103879 : - 103879: b8 04 3e 10 00 mov $0x103e04,%eax - 10387e: ff d0 call *%eax - 103880: e9 63 de ff ff jmp 1016e8 - -00103885 : - 103885: 6a 00 push $0x0 - 103887: 6a df push $0xffffffdf - 103889: 0f a8 push %gs - 10388b: 0f a0 push %fs - 10388d: 06 push %es - 10388e: 1e push %ds - 10388f: 60 pusha - 103890: 66 b8 10 00 mov $0x10,%ax - 103894: 8e d8 mov %eax,%ds - 103896: 8e c0 mov %eax,%es - 103898: 8e e0 mov %eax,%fs - 10389a: 8e e8 mov %eax,%gs - 10389c: 89 e0 mov %esp,%eax - 10389e: 50 push %eax - -0010389f : - 10389f: b8 04 3e 10 00 mov $0x103e04,%eax - 1038a4: ff d0 call *%eax - 1038a6: e9 3d de ff ff jmp 1016e8 - -001038ab : - 1038ab: 6a 00 push $0x0 - 1038ad: 6a e0 push $0xffffffe0 - 1038af: 0f a8 push %gs - 1038b1: 0f a0 push %fs - 1038b3: 06 push %es - 1038b4: 1e push %ds - 1038b5: 60 pusha - 1038b6: 66 b8 10 00 mov $0x10,%ax - 1038ba: 8e d8 mov %eax,%ds - 1038bc: 8e c0 mov %eax,%es - 1038be: 8e e0 mov %eax,%fs - 1038c0: 8e e8 mov %eax,%gs - 1038c2: 89 e0 mov %esp,%eax - 1038c4: 50 push %eax - -001038c5 : - 1038c5: b8 04 3e 10 00 mov $0x103e04,%eax - 1038ca: ff d0 call *%eax - 1038cc: e9 17 de ff ff jmp 1016e8 - -001038d1 : - 1038d1: 6a 00 push $0x0 - 1038d3: 6a e1 push $0xffffffe1 - 1038d5: 0f a8 push %gs - 1038d7: 0f a0 push %fs - 1038d9: 06 push %es - 1038da: 1e push %ds - 1038db: 60 pusha - 1038dc: 66 b8 10 00 mov $0x10,%ax - 1038e0: 8e d8 mov %eax,%ds - 1038e2: 8e c0 mov %eax,%es - 1038e4: 8e e0 mov %eax,%fs - 1038e6: 8e e8 mov %eax,%gs - 1038e8: 89 e0 mov %esp,%eax - 1038ea: 50 push %eax - -001038eb : - 1038eb: b8 04 3e 10 00 mov $0x103e04,%eax - 1038f0: ff d0 call *%eax - 1038f2: e9 f1 dd ff ff jmp 1016e8 - -001038f7 : - 1038f7: 6a 00 push $0x0 - 1038f9: 6a e2 push $0xffffffe2 - 1038fb: 0f a8 push %gs - 1038fd: 0f a0 push %fs - 1038ff: 06 push %es - 103900: 1e push %ds - 103901: 60 pusha - 103902: 66 b8 10 00 mov $0x10,%ax - 103906: 8e d8 mov %eax,%ds - 103908: 8e c0 mov %eax,%es - 10390a: 8e e0 mov %eax,%fs - 10390c: 8e e8 mov %eax,%gs - 10390e: 89 e0 mov %esp,%eax - 103910: 50 push %eax - -00103911 : - 103911: b8 04 3e 10 00 mov $0x103e04,%eax - 103916: ff d0 call *%eax - 103918: e9 cb dd ff ff jmp 1016e8 - -0010391d : - 10391d: 6a 00 push $0x0 - 10391f: 6a e3 push $0xffffffe3 - 103921: 0f a8 push %gs - 103923: 0f a0 push %fs - 103925: 06 push %es - 103926: 1e push %ds - 103927: 60 pusha - 103928: 66 b8 10 00 mov $0x10,%ax - 10392c: 8e d8 mov %eax,%ds - 10392e: 8e c0 mov %eax,%es - 103930: 8e e0 mov %eax,%fs - 103932: 8e e8 mov %eax,%gs - 103934: 89 e0 mov %esp,%eax - 103936: 50 push %eax - -00103937 : - 103937: b8 04 3e 10 00 mov $0x103e04,%eax - 10393c: ff d0 call *%eax - 10393e: e9 a5 dd ff ff jmp 1016e8 - -00103943 : - 103943: 6a 00 push $0x0 - 103945: 6a e4 push $0xffffffe4 - 103947: 0f a8 push %gs - 103949: 0f a0 push %fs - 10394b: 06 push %es - 10394c: 1e push %ds - 10394d: 60 pusha - 10394e: 66 b8 10 00 mov $0x10,%ax - 103952: 8e d8 mov %eax,%ds - 103954: 8e c0 mov %eax,%es - 103956: 8e e0 mov %eax,%fs - 103958: 8e e8 mov %eax,%gs - 10395a: 89 e0 mov %esp,%eax - 10395c: 50 push %eax - -0010395d : - 10395d: b8 04 3e 10 00 mov $0x103e04,%eax - 103962: ff d0 call *%eax - 103964: e9 7f dd ff ff jmp 1016e8 - -00103969 : - 103969: 6a 00 push $0x0 - 10396b: 6a e5 push $0xffffffe5 - 10396d: 0f a8 push %gs - 10396f: 0f a0 push %fs - 103971: 06 push %es - 103972: 1e push %ds - 103973: 60 pusha - 103974: 66 b8 10 00 mov $0x10,%ax - 103978: 8e d8 mov %eax,%ds - 10397a: 8e c0 mov %eax,%es - 10397c: 8e e0 mov %eax,%fs - 10397e: 8e e8 mov %eax,%gs - 103980: 89 e0 mov %esp,%eax - 103982: 50 push %eax - -00103983 : - 103983: b8 04 3e 10 00 mov $0x103e04,%eax - 103988: ff d0 call *%eax - 10398a: e9 59 dd ff ff jmp 1016e8 - -0010398f : - 10398f: 6a 00 push $0x0 - 103991: 6a e6 push $0xffffffe6 - 103993: 0f a8 push %gs - 103995: 0f a0 push %fs - 103997: 06 push %es - 103998: 1e push %ds - 103999: 60 pusha - 10399a: 66 b8 10 00 mov $0x10,%ax - 10399e: 8e d8 mov %eax,%ds - 1039a0: 8e c0 mov %eax,%es - 1039a2: 8e e0 mov %eax,%fs - 1039a4: 8e e8 mov %eax,%gs - 1039a6: 89 e0 mov %esp,%eax - 1039a8: 50 push %eax - -001039a9 : - 1039a9: b8 04 3e 10 00 mov $0x103e04,%eax - 1039ae: ff d0 call *%eax - 1039b0: e9 33 dd ff ff jmp 1016e8 - -001039b5 : - 1039b5: 6a 00 push $0x0 - 1039b7: 6a e7 push $0xffffffe7 - 1039b9: 0f a8 push %gs - 1039bb: 0f a0 push %fs - 1039bd: 06 push %es - 1039be: 1e push %ds - 1039bf: 60 pusha - 1039c0: 66 b8 10 00 mov $0x10,%ax - 1039c4: 8e d8 mov %eax,%ds - 1039c6: 8e c0 mov %eax,%es - 1039c8: 8e e0 mov %eax,%fs - 1039ca: 8e e8 mov %eax,%gs - 1039cc: 89 e0 mov %esp,%eax - 1039ce: 50 push %eax - -001039cf : - 1039cf: b8 04 3e 10 00 mov $0x103e04,%eax - 1039d4: ff d0 call *%eax - 1039d6: e9 0d dd ff ff jmp 1016e8 - -001039db : - 1039db: 6a 00 push $0x0 - 1039dd: 6a e8 push $0xffffffe8 - 1039df: 0f a8 push %gs - 1039e1: 0f a0 push %fs - 1039e3: 06 push %es - 1039e4: 1e push %ds - 1039e5: 60 pusha - 1039e6: 66 b8 10 00 mov $0x10,%ax - 1039ea: 8e d8 mov %eax,%ds - 1039ec: 8e c0 mov %eax,%es - 1039ee: 8e e0 mov %eax,%fs - 1039f0: 8e e8 mov %eax,%gs - 1039f2: 89 e0 mov %esp,%eax - 1039f4: 50 push %eax - -001039f5 : - 1039f5: b8 04 3e 10 00 mov $0x103e04,%eax - 1039fa: ff d0 call *%eax - 1039fc: e9 e7 dc ff ff jmp 1016e8 - -00103a01 : - 103a01: 6a 00 push $0x0 - 103a03: 6a e9 push $0xffffffe9 - 103a05: 0f a8 push %gs - 103a07: 0f a0 push %fs - 103a09: 06 push %es - 103a0a: 1e push %ds - 103a0b: 60 pusha - 103a0c: 66 b8 10 00 mov $0x10,%ax - 103a10: 8e d8 mov %eax,%ds - 103a12: 8e c0 mov %eax,%es - 103a14: 8e e0 mov %eax,%fs - 103a16: 8e e8 mov %eax,%gs - 103a18: 89 e0 mov %esp,%eax - 103a1a: 50 push %eax - -00103a1b : - 103a1b: b8 04 3e 10 00 mov $0x103e04,%eax - 103a20: ff d0 call *%eax - 103a22: e9 c1 dc ff ff jmp 1016e8 - -00103a27 : - 103a27: 6a 00 push $0x0 - 103a29: 6a ea push $0xffffffea - 103a2b: 0f a8 push %gs - 103a2d: 0f a0 push %fs - 103a2f: 06 push %es - 103a30: 1e push %ds - 103a31: 60 pusha - 103a32: 66 b8 10 00 mov $0x10,%ax - 103a36: 8e d8 mov %eax,%ds - 103a38: 8e c0 mov %eax,%es - 103a3a: 8e e0 mov %eax,%fs - 103a3c: 8e e8 mov %eax,%gs - 103a3e: 89 e0 mov %esp,%eax - 103a40: 50 push %eax - -00103a41 : - 103a41: b8 04 3e 10 00 mov $0x103e04,%eax - 103a46: ff d0 call *%eax - 103a48: e9 9b dc ff ff jmp 1016e8 - -00103a4d : - 103a4d: 6a 00 push $0x0 - 103a4f: 6a eb push $0xffffffeb - 103a51: 0f a8 push %gs - 103a53: 0f a0 push %fs - 103a55: 06 push %es - 103a56: 1e push %ds - 103a57: 60 pusha - 103a58: 66 b8 10 00 mov $0x10,%ax - 103a5c: 8e d8 mov %eax,%ds - 103a5e: 8e c0 mov %eax,%es - 103a60: 8e e0 mov %eax,%fs - 103a62: 8e e8 mov %eax,%gs - 103a64: 89 e0 mov %esp,%eax - 103a66: 50 push %eax - -00103a67 : - 103a67: b8 04 3e 10 00 mov $0x103e04,%eax - 103a6c: ff d0 call *%eax - 103a6e: e9 75 dc ff ff jmp 1016e8 - -00103a73 : - 103a73: 6a 00 push $0x0 - 103a75: 6a ec push $0xffffffec - 103a77: 0f a8 push %gs - 103a79: 0f a0 push %fs - 103a7b: 06 push %es - 103a7c: 1e push %ds - 103a7d: 60 pusha - 103a7e: 66 b8 10 00 mov $0x10,%ax - 103a82: 8e d8 mov %eax,%ds - 103a84: 8e c0 mov %eax,%es - 103a86: 8e e0 mov %eax,%fs - 103a88: 8e e8 mov %eax,%gs - 103a8a: 89 e0 mov %esp,%eax - 103a8c: 50 push %eax - -00103a8d : - 103a8d: b8 04 3e 10 00 mov $0x103e04,%eax - 103a92: ff d0 call *%eax - 103a94: e9 4f dc ff ff jmp 1016e8 - -00103a99 : - 103a99: 6a 00 push $0x0 - 103a9b: 6a ed push $0xffffffed - 103a9d: 0f a8 push %gs - 103a9f: 0f a0 push %fs - 103aa1: 06 push %es - 103aa2: 1e push %ds - 103aa3: 60 pusha - 103aa4: 66 b8 10 00 mov $0x10,%ax - 103aa8: 8e d8 mov %eax,%ds - 103aaa: 8e c0 mov %eax,%es - 103aac: 8e e0 mov %eax,%fs - 103aae: 8e e8 mov %eax,%gs - 103ab0: 89 e0 mov %esp,%eax - 103ab2: 50 push %eax - -00103ab3 : - 103ab3: b8 04 3e 10 00 mov $0x103e04,%eax - 103ab8: ff d0 call *%eax - 103aba: e9 29 dc ff ff jmp 1016e8 - -00103abf : - 103abf: 6a 00 push $0x0 - 103ac1: 6a ee push $0xffffffee - 103ac3: 0f a8 push %gs - 103ac5: 0f a0 push %fs - 103ac7: 06 push %es - 103ac8: 1e push %ds - 103ac9: 60 pusha - 103aca: 66 b8 10 00 mov $0x10,%ax - 103ace: 8e d8 mov %eax,%ds - 103ad0: 8e c0 mov %eax,%es - 103ad2: 8e e0 mov %eax,%fs - 103ad4: 8e e8 mov %eax,%gs - 103ad6: 89 e0 mov %esp,%eax - 103ad8: 50 push %eax - -00103ad9 : - 103ad9: b8 04 3e 10 00 mov $0x103e04,%eax - 103ade: ff d0 call *%eax - 103ae0: e9 03 dc ff ff jmp 1016e8 - -00103ae5 : - 103ae5: 6a 00 push $0x0 - 103ae7: 6a ef push $0xffffffef - 103ae9: 0f a8 push %gs - 103aeb: 0f a0 push %fs - 103aed: 06 push %es - 103aee: 1e push %ds - 103aef: 60 pusha - 103af0: 66 b8 10 00 mov $0x10,%ax - 103af4: 8e d8 mov %eax,%ds - 103af6: 8e c0 mov %eax,%es - 103af8: 8e e0 mov %eax,%fs - 103afa: 8e e8 mov %eax,%gs - 103afc: 89 e0 mov %esp,%eax - 103afe: 50 push %eax - -00103aff : - 103aff: b8 04 3e 10 00 mov $0x103e04,%eax - 103b04: ff d0 call *%eax - 103b06: e9 dd db ff ff jmp 1016e8 - -00103b0b : - 103b0b: 6a 00 push $0x0 - 103b0d: 6a f0 push $0xfffffff0 - 103b0f: 0f a8 push %gs - 103b11: 0f a0 push %fs - 103b13: 06 push %es - 103b14: 1e push %ds - 103b15: 60 pusha - 103b16: 66 b8 10 00 mov $0x10,%ax - 103b1a: 8e d8 mov %eax,%ds - 103b1c: 8e c0 mov %eax,%es - 103b1e: 8e e0 mov %eax,%fs - 103b20: 8e e8 mov %eax,%gs - 103b22: 89 e0 mov %esp,%eax - 103b24: 50 push %eax - -00103b25 : - 103b25: b8 04 3e 10 00 mov $0x103e04,%eax - 103b2a: ff d0 call *%eax - 103b2c: e9 b7 db ff ff jmp 1016e8 - -00103b31 : - 103b31: 6a 00 push $0x0 - 103b33: 6a f1 push $0xfffffff1 - 103b35: 0f a8 push %gs - 103b37: 0f a0 push %fs - 103b39: 06 push %es - 103b3a: 1e push %ds - 103b3b: 60 pusha - 103b3c: 66 b8 10 00 mov $0x10,%ax - 103b40: 8e d8 mov %eax,%ds - 103b42: 8e c0 mov %eax,%es - 103b44: 8e e0 mov %eax,%fs - 103b46: 8e e8 mov %eax,%gs - 103b48: 89 e0 mov %esp,%eax - 103b4a: 50 push %eax - -00103b4b : - 103b4b: b8 04 3e 10 00 mov $0x103e04,%eax - 103b50: ff d0 call *%eax - 103b52: e9 91 db ff ff jmp 1016e8 - -00103b57 : - 103b57: 6a 00 push $0x0 - 103b59: 6a f2 push $0xfffffff2 - 103b5b: 0f a8 push %gs - 103b5d: 0f a0 push %fs - 103b5f: 06 push %es - 103b60: 1e push %ds - 103b61: 60 pusha - 103b62: 66 b8 10 00 mov $0x10,%ax - 103b66: 8e d8 mov %eax,%ds - 103b68: 8e c0 mov %eax,%es - 103b6a: 8e e0 mov %eax,%fs - 103b6c: 8e e8 mov %eax,%gs - 103b6e: 89 e0 mov %esp,%eax - 103b70: 50 push %eax - -00103b71 : - 103b71: b8 04 3e 10 00 mov $0x103e04,%eax - 103b76: ff d0 call *%eax - 103b78: e9 6b db ff ff jmp 1016e8 - -00103b7d : - 103b7d: 6a 00 push $0x0 - 103b7f: 6a f3 push $0xfffffff3 - 103b81: 0f a8 push %gs - 103b83: 0f a0 push %fs - 103b85: 06 push %es - 103b86: 1e push %ds - 103b87: 60 pusha - 103b88: 66 b8 10 00 mov $0x10,%ax - 103b8c: 8e d8 mov %eax,%ds - 103b8e: 8e c0 mov %eax,%es - 103b90: 8e e0 mov %eax,%fs - 103b92: 8e e8 mov %eax,%gs - 103b94: 89 e0 mov %esp,%eax - 103b96: 50 push %eax - -00103b97 : - 103b97: b8 04 3e 10 00 mov $0x103e04,%eax - 103b9c: ff d0 call *%eax - 103b9e: e9 45 db ff ff jmp 1016e8 - -00103ba3 : - 103ba3: 6a 00 push $0x0 - 103ba5: 6a f4 push $0xfffffff4 - 103ba7: 0f a8 push %gs - 103ba9: 0f a0 push %fs - 103bab: 06 push %es - 103bac: 1e push %ds - 103bad: 60 pusha - 103bae: 66 b8 10 00 mov $0x10,%ax - 103bb2: 8e d8 mov %eax,%ds - 103bb4: 8e c0 mov %eax,%es - 103bb6: 8e e0 mov %eax,%fs - 103bb8: 8e e8 mov %eax,%gs - 103bba: 89 e0 mov %esp,%eax - 103bbc: 50 push %eax - -00103bbd : - 103bbd: b8 04 3e 10 00 mov $0x103e04,%eax - 103bc2: ff d0 call *%eax - 103bc4: e9 1f db ff ff jmp 1016e8 - -00103bc9 : - 103bc9: 6a 00 push $0x0 - 103bcb: 6a f5 push $0xfffffff5 - 103bcd: 0f a8 push %gs - 103bcf: 0f a0 push %fs - 103bd1: 06 push %es - 103bd2: 1e push %ds - 103bd3: 60 pusha - 103bd4: 66 b8 10 00 mov $0x10,%ax - 103bd8: 8e d8 mov %eax,%ds - 103bda: 8e c0 mov %eax,%es - 103bdc: 8e e0 mov %eax,%fs - 103bde: 8e e8 mov %eax,%gs - 103be0: 89 e0 mov %esp,%eax - 103be2: 50 push %eax - -00103be3 : - 103be3: b8 04 3e 10 00 mov $0x103e04,%eax - 103be8: ff d0 call *%eax - 103bea: e9 f9 da ff ff jmp 1016e8 - -00103bef : - 103bef: 6a 00 push $0x0 - 103bf1: 6a f6 push $0xfffffff6 - 103bf3: 0f a8 push %gs - 103bf5: 0f a0 push %fs - 103bf7: 06 push %es - 103bf8: 1e push %ds - 103bf9: 60 pusha - 103bfa: 66 b8 10 00 mov $0x10,%ax - 103bfe: 8e d8 mov %eax,%ds - 103c00: 8e c0 mov %eax,%es - 103c02: 8e e0 mov %eax,%fs - 103c04: 8e e8 mov %eax,%gs - 103c06: 89 e0 mov %esp,%eax - 103c08: 50 push %eax - -00103c09 : - 103c09: b8 04 3e 10 00 mov $0x103e04,%eax - 103c0e: ff d0 call *%eax - 103c10: e9 d3 da ff ff jmp 1016e8 - -00103c15 : - 103c15: 6a 00 push $0x0 - 103c17: 6a f7 push $0xfffffff7 - 103c19: 0f a8 push %gs - 103c1b: 0f a0 push %fs - 103c1d: 06 push %es - 103c1e: 1e push %ds - 103c1f: 60 pusha - 103c20: 66 b8 10 00 mov $0x10,%ax - 103c24: 8e d8 mov %eax,%ds - 103c26: 8e c0 mov %eax,%es - 103c28: 8e e0 mov %eax,%fs - 103c2a: 8e e8 mov %eax,%gs - 103c2c: 89 e0 mov %esp,%eax - 103c2e: 50 push %eax - -00103c2f : - 103c2f: b8 04 3e 10 00 mov $0x103e04,%eax - 103c34: ff d0 call *%eax - 103c36: e9 ad da ff ff jmp 1016e8 - -00103c3b : - 103c3b: 6a 00 push $0x0 - 103c3d: 6a f8 push $0xfffffff8 - 103c3f: 0f a8 push %gs - 103c41: 0f a0 push %fs - 103c43: 06 push %es - 103c44: 1e push %ds - 103c45: 60 pusha - 103c46: 66 b8 10 00 mov $0x10,%ax - 103c4a: 8e d8 mov %eax,%ds - 103c4c: 8e c0 mov %eax,%es - 103c4e: 8e e0 mov %eax,%fs - 103c50: 8e e8 mov %eax,%gs - 103c52: 89 e0 mov %esp,%eax - 103c54: 50 push %eax - -00103c55 : - 103c55: b8 04 3e 10 00 mov $0x103e04,%eax - 103c5a: ff d0 call *%eax - 103c5c: e9 87 da ff ff jmp 1016e8 - -00103c61 : - 103c61: 6a 00 push $0x0 - 103c63: 6a f9 push $0xfffffff9 - 103c65: 0f a8 push %gs - 103c67: 0f a0 push %fs - 103c69: 06 push %es - 103c6a: 1e push %ds - 103c6b: 60 pusha - 103c6c: 66 b8 10 00 mov $0x10,%ax - 103c70: 8e d8 mov %eax,%ds - 103c72: 8e c0 mov %eax,%es - 103c74: 8e e0 mov %eax,%fs - 103c76: 8e e8 mov %eax,%gs - 103c78: 89 e0 mov %esp,%eax - 103c7a: 50 push %eax - -00103c7b : - 103c7b: b8 04 3e 10 00 mov $0x103e04,%eax - 103c80: ff d0 call *%eax - 103c82: e9 61 da ff ff jmp 1016e8 - -00103c87 : - 103c87: 6a 00 push $0x0 - 103c89: 6a fa push $0xfffffffa - 103c8b: 0f a8 push %gs - 103c8d: 0f a0 push %fs - 103c8f: 06 push %es - 103c90: 1e push %ds - 103c91: 60 pusha - 103c92: 66 b8 10 00 mov $0x10,%ax - 103c96: 8e d8 mov %eax,%ds - 103c98: 8e c0 mov %eax,%es - 103c9a: 8e e0 mov %eax,%fs - 103c9c: 8e e8 mov %eax,%gs - 103c9e: 89 e0 mov %esp,%eax - 103ca0: 50 push %eax - -00103ca1 : - 103ca1: b8 04 3e 10 00 mov $0x103e04,%eax - 103ca6: ff d0 call *%eax - 103ca8: e9 3b da ff ff jmp 1016e8 - -00103cad : - 103cad: 6a 00 push $0x0 - 103caf: 6a fb push $0xfffffffb - 103cb1: 0f a8 push %gs - 103cb3: 0f a0 push %fs - 103cb5: 06 push %es - 103cb6: 1e push %ds - 103cb7: 60 pusha - 103cb8: 66 b8 10 00 mov $0x10,%ax - 103cbc: 8e d8 mov %eax,%ds - 103cbe: 8e c0 mov %eax,%es - 103cc0: 8e e0 mov %eax,%fs - 103cc2: 8e e8 mov %eax,%gs - 103cc4: 89 e0 mov %esp,%eax - 103cc6: 50 push %eax - -00103cc7 : - 103cc7: b8 04 3e 10 00 mov $0x103e04,%eax - 103ccc: ff d0 call *%eax - 103cce: e9 15 da ff ff jmp 1016e8 - -00103cd3 : - 103cd3: 6a 00 push $0x0 - 103cd5: 6a fc push $0xfffffffc - 103cd7: 0f a8 push %gs - 103cd9: 0f a0 push %fs - 103cdb: 06 push %es - 103cdc: 1e push %ds - 103cdd: 60 pusha - 103cde: 66 b8 10 00 mov $0x10,%ax - 103ce2: 8e d8 mov %eax,%ds - 103ce4: 8e c0 mov %eax,%es - 103ce6: 8e e0 mov %eax,%fs - 103ce8: 8e e8 mov %eax,%gs - 103cea: 89 e0 mov %esp,%eax - 103cec: 50 push %eax - -00103ced : - 103ced: b8 04 3e 10 00 mov $0x103e04,%eax - 103cf2: ff d0 call *%eax - 103cf4: e9 ef d9 ff ff jmp 1016e8 - -00103cf9 : - 103cf9: 6a 00 push $0x0 - 103cfb: 6a fd push $0xfffffffd - 103cfd: 0f a8 push %gs - 103cff: 0f a0 push %fs - 103d01: 06 push %es - 103d02: 1e push %ds - 103d03: 60 pusha - 103d04: 66 b8 10 00 mov $0x10,%ax - 103d08: 8e d8 mov %eax,%ds - 103d0a: 8e c0 mov %eax,%es - 103d0c: 8e e0 mov %eax,%fs - 103d0e: 8e e8 mov %eax,%gs - 103d10: 89 e0 mov %esp,%eax - 103d12: 50 push %eax - -00103d13 : - 103d13: b8 04 3e 10 00 mov $0x103e04,%eax - 103d18: ff d0 call *%eax - 103d1a: e9 c9 d9 ff ff jmp 1016e8 - -00103d1f : - 103d1f: 6a 00 push $0x0 - 103d21: 6a fe push $0xfffffffe - 103d23: 0f a8 push %gs - 103d25: 0f a0 push %fs - 103d27: 06 push %es - 103d28: 1e push %ds - 103d29: 60 pusha - 103d2a: 66 b8 10 00 mov $0x10,%ax - 103d2e: 8e d8 mov %eax,%ds - 103d30: 8e c0 mov %eax,%es - 103d32: 8e e0 mov %eax,%fs - 103d34: 8e e8 mov %eax,%gs - 103d36: 89 e0 mov %esp,%eax - 103d38: 50 push %eax - -00103d39 : - 103d39: b8 04 3e 10 00 mov $0x103e04,%eax - 103d3e: ff d0 call *%eax - 103d40: e9 a3 d9 ff ff jmp 1016e8 - -00103d45 : - 103d45: 6a 00 push $0x0 - 103d47: 6a ff push $0xffffffff - 103d49: 0f a8 push %gs - 103d4b: 0f a0 push %fs - 103d4d: 06 push %es - 103d4e: 1e push %ds - 103d4f: 60 pusha - 103d50: 66 b8 10 00 mov $0x10,%ax - 103d54: 8e d8 mov %eax,%ds - 103d56: 8e c0 mov %eax,%es - 103d58: 8e e0 mov %eax,%fs - 103d5a: 8e e8 mov %eax,%gs - 103d5c: 89 e0 mov %esp,%eax - 103d5e: 50 push %eax - -00103d5f : - 103d5f: b8 04 3e 10 00 mov $0x103e04,%eax - 103d64: ff d0 call *%eax - 103d66: e9 7d d9 ff ff jmp 1016e8 - ... - -00103d6c : -/** - * printf/kprintf helper - */ -static int kprintf_help(unsigned c, void **ptr) -{ - 103d6c: 55 push %ebp - 103d6d: 89 e5 mov %esp,%ebp - 103d6f: 83 ec 14 sub $0x14,%esp - /** - * Leave this for now - */ - ptr = ptr; - - putch(c); - 103d72: ff 75 08 pushl 0x8(%ebp) - 103d75: e8 86 0d 00 00 call 104b00 - return 0; -} - 103d7a: 31 c0 xor %eax,%eax - 103d7c: c9 leave - 103d7d: c3 ret - 103d7e: 89 f6 mov %esi,%esi - -00103d80 : - -/** - * Format output and print it to stdout (vtty0) - * Just like on any other operating system - */ -/*void printf(const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - (void)do_printf(fmt, args, kprintf_help, NULL); - va_end(args); -}*/ - -void kprintf(const char *fmt, ...) -{ - 103d80: 55 push %ebp - 103d81: 89 e5 mov %esp,%ebp - 103d83: 83 ec 08 sub $0x8,%esp - va_list args; - - va_start(args, fmt); - (void)do_printf(fmt, args, kprintf_help, NULL); - 103d86: 6a 00 push $0x0 - 103d88: 68 6c 3d 10 00 push $0x103d6c - 103d8d: 8d 45 0c lea 0xc(%ebp),%eax - 103d90: 50 push %eax - 103d91: ff 75 08 pushl 0x8(%ebp) - 103d94: e8 37 0f 00 00 call 104cd0 - va_end(args); -} - 103d99: c9 leave - 103d9a: c3 ret - 103d9b: 90 nop - -00103d9c : - -/** - * Format output and print it to stdout (vtty0) - * Just like on any other operating system - */ -void printk(const char *fmt, ...) -{ - 103d9c: 55 push %ebp - 103d9d: 89 e5 mov %esp,%ebp - 103d9f: 83 ec 08 sub $0x8,%esp - va_list args; - - /** - * TODO - * - * Select vtty0 - */ - va_start(args, fmt); - (void)do_printf(fmt, args, kprintf_help, NULL); - 103da2: 6a 00 push $0x0 - 103da4: 68 6c 3d 10 00 push $0x103d6c - 103da9: 8d 45 0c lea 0xc(%ebp),%eax - 103dac: 50 push %eax - 103dad: ff 75 08 pushl 0x8(%ebp) - 103db0: e8 1b 0f 00 00 call 104cd0 - va_end(args); -} - 103db5: c9 leave - 103db6: c3 ret - 103db7: 90 nop - -00103db8 : - -/** - * Oh yeah, the fun function ;) - */ -void panic(const char *fmt, ...) -{ - 103db8: 55 push %ebp - 103db9: 89 e5 mov %esp,%ebp - 103dbb: 53 push %ebx - 103dbc: 50 push %eax - va_list args; - - disable(); /* interrupts off */ - 103dbd: e8 06 0f 00 00 call 104cc8 - va_start(args, fmt); - _vc[0].attrib = 15; - printf("\n\npanic: "); - 103dc2: 83 ec 0c sub $0xc,%esp - 103dc5: 68 cd 58 10 00 push $0x1058cd - 103dca: c7 05 f8 a2 19 00 0f movl $0xf,0x19a2f8 - 103dd1: 00 00 00 - 103dd4: e8 fb 12 00 00 call 1050d4 - (void)do_printf(fmt, args, kprintf_help, NULL); - 103dd9: 6a 00 push $0x0 - 103ddb: 68 6c 3d 10 00 push $0x103d6c - 103de0: 8d 5d 0c lea 0xc(%ebp),%ebx - 103de3: 53 push %ebx - 103de4: ff 75 08 pushl 0x8(%ebp) - 103de7: e8 e4 0e 00 00 call 104cd0 - - printf("\n\nSystem halted."); - 103dec: 83 c4 14 add $0x14,%esp - 103def: 68 d7 58 10 00 push $0x1058d7 - 103df4: e8 db 12 00 00 call 1050d4 - __asm__ __volatile__ ("hlt"); - 103df9: f4 hlt - - while(1) - 103dfa: 83 c4 10 add $0x10,%esp - 103dfd: 8d 76 00 lea 0x0(%esi),%esi - 103e00: eb fe jmp 103e00 - 103e02: 89 f6 mov %esi,%esi - -00103e04 : - /* freeze */; -} - -/** - * Called when a kernel fault is detected. This does not - * (normally) get called when something goes awry in - * user-space, therefore it is designed for kernel-space - */ -void fault(regs_t *regs) -{ - 103e04: 55 push %ebp - 103e05: 89 e5 mov %esp,%ebp - 103e07: 53 push %ebx - 103e08: 52 push %edx - 103e09: 8b 5d 08 mov 0x8(%ebp),%ebx - struct exception - { - char *message; - int signal; - int processor; - }; - - static const struct exception ex[] = - { - {"Divide error", SIGFPE, 86}, - {"Debug exception", SIGTRAP, 86}, - {"Nonmaskable interrupt (NMI)", SIGBUS, 86}, - {"Breakpoint (INT3)", SIGEMT, 86}, - {"Overflow (INTO)", SIGFPE, 186}, - {"Bounds check", SIGFPE, 186}, - {"Invalid opcode", SIGILL, 186}, - {"Coprocessor not available", SIGFPE, 186}, - {"Double fault", SIGBUS, 286}, - {"Coprocessor segment overrun", SIGSEGV, 286}, - {"Invalid TSS", SIGSEGV, 286}, - {"Segment not present", SIGSEGV, 286}, - {"Stack exception", SIGSEGV, 286}, - {"General Protection Fault", SIGSEGV, 286}, - {"Page fault", SIGSEGV, 386}, - {NULL, SIGILL, 0}, - {"Coprocessor error", SIGFPE, 386}, - {"Alignment check",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"??",0,0}, - {"IRQ0",0,0}, - {"IRQ1",0,0}, - {"IRQ2",0,0}, - {"IRQ3",0,0}, - {"IRQ4",0,0}, - {"IRQ5",0,0}, - {"IRQ6",0,0}, - {"IRQ7",0,0}, - {"IRQ8",0,0}, - {"IRQ9",0,0}, - {"IRQ10",0,0}, - {"IRQ11",0,0}, - {"IRQ12",0,0}, - {"IRQ13",0,0}, - {"IRQ14",0,0}, - {"IRQ15",0,0}, - {"syscall",0,0} - }; - - - switch(regs->which_int) - 103e0c: 83 7b 30 20 cmpl $0x20,0x30(%ebx) - 103e10: 74 6e je 103e80 - { - /** - * this handler installed at compile-time - * Keyboard handler is installed at run-time (see below) - */ - case 0x20: /* timer IRQ 0 */ - //blink(); - /** - * reset hardware interrupt at 8259 chip - */ - outportb(0x20, 0x20); - break; - default: - _vc[0].attrib = 15; - printf("\n\npanic: Exception 0x%08X", regs->which_int); - 103e12: 83 ec 08 sub $0x8,%esp - 103e15: c7 05 f8 a2 19 00 0f movl $0xf,0x19a2f8 - 103e1c: 00 00 00 - 103e1f: ff 73 30 pushl 0x30(%ebx) - 103e22: 68 79 5a 10 00 push $0x105a79 - 103e27: e8 a8 12 00 00 call 1050d4 - if(regs->which_int <= sizeof(ex) / sizeof(ex[0].message)) - 103e2c: 8b 43 30 mov 0x30(%ebx),%eax - 103e2f: 83 c4 10 add $0x10,%esp - 103e32: 3d 93 00 00 00 cmp $0x93,%eax - 103e37: 76 2b jbe 103e64 - printf(" (%s)", ex[regs->which_int].message); - printf("\n"); - 103e39: 83 ec 0c sub $0xc,%esp - 103e3c: 68 f8 5a 10 00 push $0x105af8 - 103e41: e8 8e 12 00 00 call 1050d4 - dump_regs(regs); - 103e46: 89 1c 24 mov %ebx,(%esp,1) - 103e49: e8 7e c3 ff ff call 1001cc - printf("\n\nSystem halted."); - 103e4e: c7 04 24 d7 58 10 00 movl $0x1058d7,(%esp,1) - 103e55: e8 7a 12 00 00 call 1050d4 - __asm__ __volatile__ ("hlt"); - 103e5a: f4 hlt - break; - 103e5b: 83 c4 10 add $0x10,%esp - } -} - 103e5e: 8b 5d fc mov 0xfffffffc(%ebp),%ebx - 103e61: c9 leave - 103e62: c3 ret - 103e63: 90 nop - 103e64: 83 ec 08 sub $0x8,%esp - 103e67: 8d 04 40 lea (%eax,%eax,2),%eax - 103e6a: ff 34 85 00 5b 10 00 pushl 0x105b00(,%eax,4) - 103e71: 68 93 5a 10 00 push $0x105a93 - 103e76: e8 59 12 00 00 call 1050d4 - 103e7b: 83 c4 10 add $0x10,%esp - 103e7e: eb b9 jmp 103e39 - 103e80: 83 ec 08 sub $0x8,%esp - 103e83: 6a 20 push $0x20 - 103e85: 6a 20 push $0x20 - 103e87: e8 28 12 00 00 call 1050b4 - 103e8c: eb cd jmp 103e5b - 103e8e: 89 f6 mov %esi,%esi - -00103e90 : - -/** - * ?? - */ -static void init_8259s(void) -{ - 103e90: 55 push %ebp - 103e91: 89 e5 mov %esp,%ebp - 103e93: 83 ec 10 sub $0x10,%esp - static const unsigned irq0_int = 0x20, irq8_int = 0x28; - - /** - * Initialization Control Word #1 (ICW1) - */ - outportb(0x20, 0x11); - 103e96: 6a 11 push $0x11 - 103e98: 6a 20 push $0x20 - 103e9a: e8 15 12 00 00 call 1050b4 - outportb(0xA0, 0x11); - 103e9f: 59 pop %ecx - 103ea0: 58 pop %eax - 103ea1: 6a 11 push $0x11 - 103ea3: 68 a0 00 00 00 push $0xa0 - 103ea8: e8 07 12 00 00 call 1050b4 - - /** - * ICW2: - * route IRQs 0-7 to INTs 20h-27h - */ - outportb(0x21, irq0_int); - 103ead: 58 pop %eax - 103eae: 5a pop %edx - 103eaf: 6a 20 push $0x20 - 103eb1: 6a 21 push $0x21 - 103eb3: e8 fc 11 00 00 call 1050b4 - - /** - * route IRQs 8-15 to INTs 28h-2Fh - */ - outportb(0xA1, irq8_int); - 103eb8: 59 pop %ecx - 103eb9: 58 pop %eax - 103eba: 6a 28 push $0x28 - 103ebc: 68 a1 00 00 00 push $0xa1 - 103ec1: e8 ee 11 00 00 call 1050b4 - - /** - * ICW3 - */ - outportb(0x21, 0x04); - 103ec6: 58 pop %eax - 103ec7: 5a pop %edx - 103ec8: 6a 04 push $0x4 - 103eca: 6a 21 push $0x21 - 103ecc: e8 e3 11 00 00 call 1050b4 - outportb(0xA1, 0x02); - 103ed1: 59 pop %ecx - 103ed2: 58 pop %eax - 103ed3: 6a 02 push $0x2 - 103ed5: 68 a1 00 00 00 push $0xa1 - 103eda: e8 d5 11 00 00 call 1050b4 - - /** - * ICW4 - */ - outportb(0x21, 0x01); - 103edf: 58 pop %eax - 103ee0: 5a pop %edx - 103ee1: 6a 01 push $0x1 - 103ee3: 6a 21 push $0x21 - 103ee5: e8 ca 11 00 00 call 1050b4 - outportb(0xA1, 0x01); - 103eea: 59 pop %ecx - 103eeb: 58 pop %eax - 103eec: 6a 01 push $0x1 - 103eee: 68 a1 00 00 00 push $0xa1 - 103ef3: e8 bc 11 00 00 call 1050b4 - - /** - * enable IRQ0 (timer) and IRQ1 (keyboard) - */ - outportb(0x21, ~0x03); - 103ef8: 58 pop %eax - 103ef9: 5a pop %edx - 103efa: 6a fc push $0xfffffffc - 103efc: 6a 21 push $0x21 - 103efe: e8 b1 11 00 00 call 1050b4 - outportb(0xA1, ~0x00); - 103f03: 59 pop %ecx - 103f04: 58 pop %eax - 103f05: 6a ff push $0xffffffff - 103f07: 68 a1 00 00 00 push $0xa1 - 103f0c: e8 a3 11 00 00 call 1050b4 -} - 103f11: c9 leave - 103f12: c3 ret - 103f13: 90 nop - -00103f14 : - -/** - * MinGW32 - */ -#ifdef __WIN32__ -#if __GNUC__<3 -#error Do not use MinGW GCC 2.x with NASM -#endif - int __main(void) { return 0; } - void _alloca(void) { } -#endif - -/** - * malloc, realloc, free, etc - */ -static char *g_heap_bot, *g_kbrk, *g_heap_top; -static void dump_heap(void) -{ - 103f14: 55 push %ebp - 103f15: 89 e5 mov %esp,%ebp - 103f17: 57 push %edi - 103f18: 56 push %esi - 103f19: 53 push %ebx - 103f1a: 83 ec 18 sub $0x18,%esp - unsigned blks_used = 0, blks_free = 0; - size_t bytes_used = 0, bytes_free = 0; - malloc_t *m; - int total; - - kprintf("===============================================\n"); - 103f1d: 68 60 5d 10 00 push $0x105d60 - 103f22: c7 45 f0 00 00 00 00 movl $0x0,0xfffffff0(%ebp) - 103f29: c7 45 ec 00 00 00 00 movl $0x0,0xffffffec(%ebp) - 103f30: e8 4b fe ff ff call 103d80 - for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) - 103f35: 8b 1d e0 36 18 00 mov 0x1836e0,%ebx - 103f3b: 31 ff xor %edi,%edi - 103f3d: 31 f6 xor %esi,%esi - 103f3f: 83 c4 10 add $0x10,%esp - 103f42: 85 db test %ebx,%ebx - 103f44: 74 39 je 103f7f - 103f46: 89 f6 mov %esi,%esi - { - printk("block %5p: %6u bytes %s\n", m, - 103f48: f6 43 09 80 testb $0x80,0x9(%ebx) - 103f4c: 0f 84 be 00 00 00 je 104010 - 103f52: b8 99 5a 10 00 mov $0x105a99,%eax - 103f57: 50 push %eax - 103f58: ff 33 pushl (%ebx) - 103f5a: 53 push %ebx - 103f5b: 68 9e 5a 10 00 push $0x105a9e - 103f60: e8 37 fe ff ff call 103d9c - m->size, m->used ? "used" : "free"); - if(m->used) - 103f65: 83 c4 10 add $0x10,%esp - 103f68: f6 43 09 80 testb $0x80,0x9(%ebx) - 103f6c: 0f 84 92 00 00 00 je 104004 - { - blks_used++; - bytes_used += m->size; - 103f72: 8b 03 mov (%ebx),%eax - 103f74: 47 inc %edi - 103f75: 01 45 f0 add %eax,0xfffffff0(%ebp) - 103f78: 8b 5b 04 mov 0x4(%ebx),%ebx - 103f7b: 85 db test %ebx,%ebx - 103f7d: 75 c9 jne 103f48 - } - else - { - blks_free++; - bytes_free += m->size; - } - } - kprintf("blocks: %6u used, %6u free, %6u total\n", blks_used, - 103f7f: 8d 1c 3e lea (%esi,%edi,1),%ebx - 103f82: 53 push %ebx - 103f83: 56 push %esi - 103f84: 57 push %edi - 103f85: 68 a0 5d 10 00 push $0x105da0 - 103f8a: e8 f1 fd ff ff call 103d80 - blks_free, blks_used + blks_free); - kprintf(" bytes: %6u used, %6u free, %6u total\n", bytes_used, - 103f8f: 8b 75 f0 mov 0xfffffff0(%ebp),%esi - 103f92: 03 75 ec add 0xffffffec(%ebp),%esi - 103f95: 56 push %esi - 103f96: ff 75 ec pushl 0xffffffec(%ebp) - 103f99: ff 75 f0 pushl 0xfffffff0(%ebp) - 103f9c: 68 e0 5d 10 00 push $0x105de0 - 103fa1: e8 da fd ff ff call 103d80 - bytes_free, bytes_used + bytes_free); - kprintf("g_heap_bot=0x%p, g_kbrk=0x%p, g_heap_top=0x%p\n", - 103fa6: 83 c4 20 add $0x20,%esp - 103fa9: ff 35 e8 36 18 00 pushl 0x1836e8 - 103faf: ff 35 e4 36 18 00 pushl 0x1836e4 - 103fb5: ff 35 e0 36 18 00 pushl 0x1836e0 - 103fbb: 68 20 5e 10 00 push $0x105e20 - 103fc0: e8 bb fd ff ff call 103d80 - g_heap_bot, g_kbrk, g_heap_top); - total = (bytes_used + bytes_free) + - 103fc5: 8d 1c 5b lea (%ebx,%ebx,2),%ebx - (blks_used + blks_free) * sizeof(malloc_t); - if(total != g_kbrk - g_heap_bot) - 103fc8: a1 e4 36 18 00 mov 0x1836e4,%eax - 103fcd: 8d 1c 9e lea (%esi,%ebx,4),%ebx - 103fd0: 2b 05 e0 36 18 00 sub 0x1836e0,%eax - 103fd6: 83 c4 10 add $0x10,%esp - 103fd9: 39 c3 cmp %eax,%ebx - 103fdb: 74 10 je 103fed - kprintf("*** some heap memory is not accounted for\n"); - 103fdd: 83 ec 0c sub $0xc,%esp - 103fe0: 68 60 5e 10 00 push $0x105e60 - 103fe5: e8 96 fd ff ff call 103d80 - 103fea: 83 c4 10 add $0x10,%esp - kprintf("===============================================\n"); - 103fed: 83 ec 0c sub $0xc,%esp - 103ff0: 68 60 5d 10 00 push $0x105d60 - 103ff5: e8 86 fd ff ff call 103d80 -} - 103ffa: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 103ffd: 5b pop %ebx - 103ffe: 5e pop %esi - 103fff: 5f pop %edi - 104000: c9 leave - 104001: c3 ret - 104002: 89 f6 mov %esi,%esi - 104004: 8b 03 mov (%ebx),%eax - 104006: 46 inc %esi - 104007: 01 45 ec add %eax,0xffffffec(%ebp) - 10400a: e9 69 ff ff ff jmp 103f78 - 10400f: 90 nop - 104010: b8 b7 5a 10 00 mov $0x105ab7,%eax - 104015: e9 3d ff ff ff jmp 103f57 - 10401a: 89 f6 mov %esi,%esi - -0010401c : - -void dumpheapk(void) -{ - 10401c: 55 push %ebp - 10401d: 89 e5 mov %esp,%ebp - dump_heap(); - 10401f: c9 leave - 104020: e9 ef fe ff ff jmp 103f14 - 104025: 8d 76 00 lea 0x0(%esi),%esi - -00104028 : -} - -/** - * POSIX sbrk() looks like this - * void *sbrk(int incr); - * - * Mine is a bit different so I can signal the calling function - * if more memory than desired was allocated (e.g. in a system with paging) - * If your kbrk()/sbrk() always allocates the amount of memory you ask for, - * this code can be easily changed. - * - * int brk( void *sbrk( void *kbrk( - * function void *adr); int delta); int *delta); - * ---------------------- ------------ ------------ ------------- - * POSIX? yes yes NO - * return value if error -1 -1 NULL - * get break value . sbrk(0) int x=0; kbrk(&x); - * set break value to X brk(X) sbrk(X - sbrk(0)) int x=X, y=0; kbrk(&x) - kbrk(&y); - * enlarge heap by N bytes . sbrk(+N) int x=N; kbrk(&x); - * shrink heap by N bytes . sbrk(-N) int x=-N; kbrk(&x); - * can you tell if you're - * given more memory - * than you wanted? no no yes - */ -static void *kbrk(int *delta) -{ - static char heap[HEAP_SIZE]; - char *new_brk, *old_brk; - - /** - * heap doesn't exist yet - */ - if(g_heap_bot == NULL) - 104028: 8b 0d e0 36 18 00 mov 0x1836e0,%ecx - 10402e: 55 push %ebp - 10402f: 85 c9 test %ecx,%ecx - 104031: 89 e5 mov %esp,%ebp - 104033: 53 push %ebx - 104034: 75 1f jne 104055 - { - g_heap_bot = g_kbrk = heap; - 104036: b9 c0 95 10 00 mov $0x1095c0,%ecx - 10403b: c7 05 e4 36 18 00 c0 movl $0x1095c0,0x1836e4 - 104042: 95 10 00 - 104045: 89 0d e0 36 18 00 mov %ecx,0x1836e0 - g_heap_top = g_heap_bot + HEAP_SIZE; - 10404b: c7 05 e8 36 18 00 e0 movl $0x1836e0,0x1836e8 - 104052: 36 18 00 - } - new_brk = g_kbrk + (*delta); - 104055: 8b 1d e4 36 18 00 mov 0x1836e4,%ebx - 10405b: 8b 45 08 mov 0x8(%ebp),%eax - 10405e: 89 da mov %ebx,%edx - 104060: 03 10 add (%eax),%edx - - /** - * too low: return NULL - */ - if(new_brk < g_heap_bot) - 104062: 31 c0 xor %eax,%eax - 104064: 39 ca cmp %ecx,%edx - 104066: 72 10 jb 104078 - return NULL; - - /** - * too high: return NULL - */ - if(new_brk >= g_heap_top) - 104068: 3b 15 e8 36 18 00 cmp 0x1836e8,%edx - 10406e: 73 08 jae 104078 - return NULL; - - /** - * success: adjust brk value... - */ - old_brk = g_kbrk; - g_kbrk = new_brk; - 104070: 89 15 e4 36 18 00 mov %edx,0x1836e4 - - /** - * ...return actual delta... (for this sbrk(), they are the same) - * (*delta) = (*delta); - * ...return old brk value - */ - return old_brk; - 104076: 89 d8 mov %ebx,%eax -} - 104078: 8b 1c 24 mov (%esp,1),%ebx - 10407b: c9 leave - 10407c: c3 ret - 10407d: 8d 76 00 lea 0x0(%esi),%esi - -00104080 : - -/** - * malloc() and free() use g_heap_bot, but not g_kbrk nor g_heap_top - */ -void *kmalloc(size_t size) -{ - 104080: 55 push %ebp - 104081: 89 e5 mov %esp,%ebp - 104083: 57 push %edi - 104084: 56 push %esi - 104085: 53 push %ebx - 104086: 83 ec 0c sub $0xc,%esp - 104089: 8b 7d 08 mov 0x8(%ebp),%edi - unsigned total_size; - malloc_t *m, *n; - int delta; - - if(size == 0) - 10408c: 31 c0 xor %eax,%eax - 10408e: 85 ff test %edi,%edi - 104090: 0f 84 af 00 00 00 je 104145 - return NULL; - total_size = size + sizeof(malloc_t); - - /** - * search heap for free block (FIRST FIT) - */ - m = (malloc_t *)g_heap_bot; - 104096: 8b 1d e0 36 18 00 mov 0x1836e0,%ebx - - /** - * g_heap_bot == 0 == NULL if heap does not yet exist - */ - if(m != NULL) - 10409c: 85 db test %ebx,%ebx - 10409e: 8d 77 0c lea 0xc(%edi),%esi - 1040a1: 74 35 je 1040d8 - { - if(m->magic != MALLOC_MAGIC) - 1040a3: 0f b7 43 08 movzwl 0x8(%ebx),%eax - 1040a7: 25 ff 7f 00 00 and $0x7fff,%eax - 1040ac: 3d 92 6d 00 00 cmp $0x6d92,%eax - 1040b1: 0f 85 e5 00 00 00 jne 10419c - { - /*printf("*** kernel heap is corrupt in kmalloc()\n");*/ - panic("kernel heap is corrupt in malloc()"); - return NULL; - } - for(; m->next != NULL; m = m->next) - 1040b7: 8b 43 04 mov 0x4(%ebx),%eax - 1040ba: 85 c0 test %eax,%eax - 1040bc: 74 1a je 1040d8 - 1040be: 89 f6 mov %esi,%esi - { - if(m->used) - 1040c0: 8a 53 09 mov 0x9(%ebx),%dl - 1040c3: f6 c2 80 test $0x80,%dl - 1040c6: 0f 84 8c 00 00 00 je 104158 - 1040cc: 89 c3 mov %eax,%ebx - 1040ce: 8b 40 04 mov 0x4(%eax),%eax - 1040d1: 85 c0 test %eax,%eax - 1040d3: 75 eb jne 1040c0 - 1040d5: 8d 76 00 lea 0x0(%esi),%esi - continue; - - /** - * size == m->size is a perfect fit - */ - if(size == m->size) - m->used = 1; - else - { - /** - * otherwise, we need an extra sizeof(malloc_t) bytes for the header - * of a second, free block - */ - if(total_size > m->size) - continue; - - /** - * create a new, smaller free block after this one - */ - n = (malloc_t *)((char *)m + total_size); - n->size = m->size - total_size; - n->next = m->next; - n->magic = MALLOC_MAGIC; - n->used = 0; - - /** - * reduce the size of this block and mark it used - */ - m->size = size; - m->next = n; - m->used = 1; - } - return (char *)m + sizeof(malloc_t); - } - } - - /** - * use kbrk() to enlarge (or create!) heap - */ - delta = total_size; - n = kbrk(&delta); - 1040d8: 83 ec 0c sub $0xc,%esp - 1040db: 8d 45 f0 lea 0xfffffff0(%ebp),%eax - 1040de: 50 push %eax - 1040df: 89 75 f0 mov %esi,0xfffffff0(%ebp) - 1040e2: e8 41 ff ff ff call 104028 - 1040e7: 89 c2 mov %eax,%edx - - /** - * uh-oh - */ - if(n == NULL) - 1040e9: 83 c4 10 add $0x10,%esp - 1040ec: 31 c0 xor %eax,%eax - 1040ee: 85 d2 test %edx,%edx - 1040f0: 74 53 je 104145 - return NULL; - - if(m != NULL) - 1040f2: 85 db test %ebx,%ebx - 1040f4: 74 03 je 1040f9 - m->next = n; - 1040f6: 89 53 04 mov %edx,0x4(%ebx) - - n->size = size; - n->magic = MALLOC_MAGIC; - 1040f9: 66 8b 42 08 mov 0x8(%edx),%ax - 1040fd: 25 00 80 ff ff and $0xffff8000,%eax - 104102: 0d 92 6d 00 00 or $0x6d92,%eax - 104107: 66 89 42 08 mov %ax,0x8(%edx) - n->used = 1; - 10410b: 80 4a 09 80 orb $0x80,0x9(%edx) - - /** - * did kbrk() return the exact amount of memory we wanted? - * cast to make "gcc -Wall -W ..." shut the hell up - */ - if((int)total_size == delta) - 10410f: 8b 45 f0 mov 0xfffffff0(%ebp),%eax - 104112: 39 c6 cmp %eax,%esi - 104114: 89 3a mov %edi,(%edx) - 104116: 74 35 je 10414d - n->next = NULL; - else - { - - /** - * it returned more than we wanted (it will never return less): - * create a new, free block - */ - m = (malloc_t *)((char *)n + total_size); - m->size = delta - total_size - sizeof(malloc_t); - 104118: 29 f0 sub %esi,%eax - 10411a: 8d 1c 16 lea (%esi,%edx,1),%ebx - 10411d: 83 e8 0c sub $0xc,%eax - 104120: 89 03 mov %eax,(%ebx) - m->next = NULL; - m->magic = MALLOC_MAGIC; - 104122: 66 8b 43 08 mov 0x8(%ebx),%ax - 104126: 25 00 80 ff ff and $0xffff8000,%eax - 10412b: 0d 92 6d 00 00 or $0x6d92,%eax - 104130: 66 89 43 08 mov %ax,0x8(%ebx) - 104134: c7 43 04 00 00 00 00 movl $0x0,0x4(%ebx) - m->used = 0; - 10413b: 80 63 09 7f andb $0x7f,0x9(%ebx) - - n->next = m; - 10413f: 89 5a 04 mov %ebx,0x4(%edx) - } - return (char *)n + sizeof(malloc_t); - 104142: 8d 42 0c lea 0xc(%edx),%eax -} - 104145: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 104148: 5b pop %ebx - 104149: 5e pop %esi - 10414a: 5f pop %edi - 10414b: c9 leave - 10414c: c3 ret - 10414d: c7 42 04 00 00 00 00 movl $0x0,0x4(%edx) - 104154: eb ec jmp 104142 - 104156: 89 f6 mov %esi,%esi - 104158: 8b 0b mov (%ebx),%ecx - 10415a: 39 cf cmp %ecx,%edi - 10415c: 74 36 je 104194 - 10415e: 39 ce cmp %ecx,%esi - 104160: 0f 87 66 ff ff ff ja 1040cc - 104166: 8d 14 1e lea (%esi,%ebx,1),%edx - 104169: 89 42 04 mov %eax,0x4(%edx) - 10416c: 66 8b 42 08 mov 0x8(%edx),%ax - 104170: 25 00 80 ff ff and $0xffff8000,%eax - 104175: 0d 92 6d 00 00 or $0x6d92,%eax - 10417a: 66 89 42 08 mov %ax,0x8(%edx) - 10417e: 29 f1 sub %esi,%ecx - 104180: 80 62 09 7f andb $0x7f,0x9(%edx) - 104184: 89 0a mov %ecx,(%edx) - 104186: 89 53 04 mov %edx,0x4(%ebx) - 104189: 89 3b mov %edi,(%ebx) - 10418b: 80 4b 09 80 orb $0x80,0x9(%ebx) - 10418f: 8d 43 0c lea 0xc(%ebx),%eax - 104192: eb b1 jmp 104145 - 104194: 83 ca 80 or $0xffffff80,%edx - 104197: 88 53 09 mov %dl,0x9(%ebx) - 10419a: eb f3 jmp 10418f - 10419c: 83 ec 0c sub $0xc,%esp - 10419f: 68 a0 5e 10 00 push $0x105ea0 - 1041a4: e8 0f fc ff ff call 103db8 - 1041a9: 31 c0 xor %eax,%eax - 1041ab: eb 98 jmp 104145 - 1041ad: 8d 76 00 lea 0x0(%esi),%esi - -001041b0 : - -void kfree(void *blk) -{ - 1041b0: 55 push %ebp - 1041b1: 89 e5 mov %esp,%ebp - 1041b3: 56 push %esi - 1041b4: 53 push %ebx - 1041b5: 8b 5d 08 mov 0x8(%ebp),%ebx - malloc_t *m, *n; - - /** - * get address of header - */ - m = (malloc_t *)((char *)blk - sizeof(malloc_t)); - 1041b8: 8d 4b f4 lea 0xfffffff4(%ebx),%ecx - if(m->magic != MALLOC_MAGIC) - 1041bb: 0f b7 41 08 movzwl 0x8(%ecx),%eax - 1041bf: 25 ff 7f 00 00 and $0x7fff,%eax - 1041c4: 3d 92 6d 00 00 cmp $0x6d92,%eax - 1041c9: 74 15 je 1041e0 - { - /*printf("*** attempt to kfree() block at 0x%p with bad magic value\n", blk);*/ - panic("attempt to free() block at 0x%p with bad magic value", blk); - 1041cb: 83 ec 08 sub $0x8,%esp - 1041ce: 53 push %ebx - 1041cf: 68 e0 5e 10 00 push $0x105ee0 - 1041d4: e8 df fb ff ff call 103db8 - return; - } - - /** - * find this block in the heap - */ - n = (malloc_t *)g_heap_bot; - if(n->magic != MALLOC_MAGIC) - { - /*printf("*** kernel heap is corrupt in kfree()\n");*/ - panic("kernel heap is corrupt in free()"); - return; - } - for(; n != NULL; n = n->next) - { - if(n == m) - break; - } - - /** - * not found? bad pointer or no heap or something else? - */ - if(n == NULL) - { - /*printf("*** attempt to kfree() block at 0x%p that is not in the heap\n", blk);*/ - panic("attempt to free() block at 0x%p that is not in the heap", blk); - return; - } - - /** - * free the block - */ - m->used = 0; - - /** - * coalesce adjacent free blocks - * Hard to spell, hard to do - */ - for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) - { - while(!m->used && m->next != NULL && !m->next->used) - { - /** - * resize this block - */ - m->size += sizeof(malloc_t) + m->next->size; - - /** - * merge with next block - */ - m->next = m->next->next; - } - } -} - 1041d9: 8d 65 f8 lea 0xfffffff8(%ebp),%esp - 1041dc: 5b pop %ebx - 1041dd: 5e pop %esi - 1041de: c9 leave - 1041df: c3 ret - 1041e0: 8b 15 e0 36 18 00 mov 0x1836e0,%edx - 1041e6: 0f b7 42 08 movzwl 0x8(%edx),%eax - 1041ea: 25 ff 7f 00 00 and $0x7fff,%eax - 1041ef: 3d 92 6d 00 00 cmp $0x6d92,%eax - 1041f4: 74 12 je 104208 - 1041f6: c7 45 08 20 5f 10 00 movl $0x105f20,0x8(%ebp) - 1041fd: 8d 65 f8 lea 0xfffffff8(%ebp),%esp - 104200: 5b pop %ebx - 104201: 5e pop %esi - 104202: c9 leave - 104203: e9 b0 fb ff ff jmp 103db8 - 104208: 85 d2 test %edx,%edx - 10420a: 74 0b je 104217 - 10420c: 39 ca cmp %ecx,%edx - 10420e: 74 12 je 104222 - 104210: 8b 52 04 mov 0x4(%edx),%edx - 104213: 85 d2 test %edx,%edx - 104215: 75 f5 jne 10420c - 104217: 83 ec 08 sub $0x8,%esp - 10421a: 53 push %ebx - 10421b: 68 60 5f 10 00 push $0x105f60 - 104220: eb b2 jmp 1041d4 - 104222: 85 d2 test %edx,%edx - 104224: 74 f1 je 104217 - 104226: 80 61 09 7f andb $0x7f,0x9(%ecx) - 10422a: 8b 0d e0 36 18 00 mov 0x1836e0,%ecx - 104230: 85 c9 test %ecx,%ecx - 104232: 74 a5 je 1041d9 - 104234: f6 41 09 80 testb $0x80,0x9(%ecx) - 104238: 75 46 jne 104280 - 10423a: 8b 51 04 mov 0x4(%ecx),%edx - 10423d: 85 d2 test %edx,%edx - 10423f: 89 d3 mov %edx,%ebx - 104241: 74 31 je 104274 - 104243: f6 42 09 80 testb $0x80,0x9(%edx) - 104247: 75 2b jne 104274 - 104249: 31 f6 xor %esi,%esi - 10424b: 90 nop - 10424c: 8b 03 mov (%ebx),%eax - 10424e: 03 01 add (%ecx),%eax - 104250: 83 c0 0c add $0xc,%eax - 104253: 89 01 mov %eax,(%ecx) - 104255: 85 f6 test %esi,%esi - 104257: 8b 43 04 mov 0x4(%ebx),%eax - 10425a: 89 41 04 mov %eax,0x4(%ecx) - 10425d: 89 c2 mov %eax,%edx - 10425f: 75 13 jne 104274 - 104261: 31 d2 xor %edx,%edx - 104263: 85 c0 test %eax,%eax - 104265: 74 0d je 104274 - 104267: f6 40 09 80 testb $0x80,0x9(%eax) - 10426b: 89 c3 mov %eax,%ebx - 10426d: 74 dd je 10424c - 10426f: 89 c2 mov %eax,%edx - 104271: 8d 76 00 lea 0x0(%esi),%esi - 104274: 85 d2 test %edx,%edx - 104276: 89 d1 mov %edx,%ecx - 104278: 75 ba jne 104234 - 10427a: e9 5a ff ff ff jmp 1041d9 - 10427f: 90 nop - 104280: 8b 51 04 mov 0x4(%ecx),%edx - 104283: eb ef jmp 104274 - 104285: 8d 76 00 lea 0x0(%esi),%esi - -00104288 : - -void testheap(void) -{ - 104288: 55 push %ebp - 104289: 89 e5 mov %esp,%ebp - 10428b: 83 ec 14 sub $0x14,%esp - //int i; - //char *t; - //kprintf("before char *t = kmalloc((size_t *)25):\n"); - //dump_heap(); - //t = kmalloc(25); - //strcpy(t, "123456789012345678901234"); - //kprintf("after char *t = kmalloc((size_t *)25):\n"); - //dump_heap(); - //kfree(t); - //kprintf("after kfree(t):\n"); - //dump_heap(); - //kprintf("before char *t = kmalloc((size_t *)25):\n"); - - kprintf("Unable to run testheap -- kmalloc() is broken.\n"); - 10428e: 68 a0 5f 10 00 push $0x105fa0 - 104293: e8 e8 fa ff ff call 103d80 -} - 104298: c9 leave - 104299: c3 ret - 10429a: 89 f6 mov %esi,%esi - -0010429c : - -void *krealloc(void *blk, size_t size) -{ - 10429c: 55 push %ebp - 10429d: 89 e5 mov %esp,%ebp - 10429f: 57 push %edi - 1042a0: 56 push %esi - 1042a1: 53 push %ebx - 1042a2: 83 ec 0c sub $0xc,%esp - 1042a5: 8b 5d 0c mov 0xc(%ebp),%ebx - void *new_blk; - malloc_t *m; - - /** - * size == 0: free block - */ - if(size == 0) - 1042a8: 85 db test %ebx,%ebx - 1042aa: 8b 75 08 mov 0x8(%ebp),%esi - 1042ad: 75 1d jne 1042cc - { - if(blk != NULL) - 1042af: 85 f6 test %esi,%esi - 1042b1: 74 0c je 1042bf - kfree(blk); - 1042b3: 83 ec 0c sub $0xc,%esp - 1042b6: 56 push %esi - 1042b7: e8 f4 fe ff ff call 1041b0 - 1042bc: 83 c4 10 add $0x10,%esp - new_blk = NULL; - 1042bf: 31 ff xor %edi,%edi - } - else - { - /** - * allocate new block - */ - new_blk = kmalloc(size); - - /** - * if allocation OK, and if old block exists, copy old block to new - */ - if(new_blk != NULL && blk != NULL) - { - m = (malloc_t *)((char *)blk - sizeof(malloc_t)); - if(m->magic != MALLOC_MAGIC) - { - /*printf("*** attempt to krealloc() block at 0x%p with bad magic value\n", blk);*/ - panic("attempt to realloc() block at 0x%p with bad magic value", blk); - return NULL; - } - - /** - * copy minimum of old and new block sizes - */ - if(size > m->size) - size = m->size; - memcpy(new_blk, blk, size); - - /** - * free the old block - */ - kfree(blk); - } - } - return new_blk; - 1042c1: 89 f8 mov %edi,%eax -} - 1042c3: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 1042c6: 5b pop %ebx - 1042c7: 5e pop %esi - 1042c8: 5f pop %edi - 1042c9: c9 leave - 1042ca: c3 ret - 1042cb: 90 nop - 1042cc: 83 ec 0c sub $0xc,%esp - 1042cf: 53 push %ebx - 1042d0: e8 ab fd ff ff call 104080 - 1042d5: 83 c4 10 add $0x10,%esp - 1042d8: 85 c0 test %eax,%eax - 1042da: 89 c7 mov %eax,%edi - 1042dc: 74 e3 je 1042c1 - 1042de: 85 f6 test %esi,%esi - 1042e0: 74 df je 1042c1 - 1042e2: 0f b7 46 fc movzwl 0xfffffffc(%esi),%eax - 1042e6: 25 ff 7f 00 00 and $0x7fff,%eax - 1042eb: 3d 92 6d 00 00 cmp $0x6d92,%eax - 1042f0: 75 1f jne 104311 - 1042f2: 8b 46 f4 mov 0xfffffff4(%esi),%eax - 1042f5: 39 c3 cmp %eax,%ebx - 1042f7: 76 02 jbe 1042fb - 1042f9: 89 c3 mov %eax,%ebx - 1042fb: 50 push %eax - 1042fc: 53 push %ebx - 1042fd: 56 push %esi - 1042fe: 57 push %edi - 1042ff: e8 58 0d 00 00 call 10505c - 104304: 89 34 24 mov %esi,(%esp,1) - 104307: e8 a4 fe ff ff call 1041b0 - 10430c: 83 c4 10 add $0x10,%esp - 10430f: eb b0 jmp 1042c1 - 104311: 83 ec 08 sub $0x8,%esp - 104314: 56 push %esi - 104315: 68 e0 5f 10 00 push $0x105fe0 - 10431a: e8 99 fa ff ff call 103db8 - 10431f: 31 c0 xor %eax,%eax - 104321: eb a0 jmp 1042c3 - 104323: 90 nop - -00104324
: - -void keyboardISR(void); - -int main(void) -{ - 104324: 55 push %ebp - 104325: 89 e5 mov %esp,%ebp - 104327: 83 ec 08 sub $0x8,%esp - 10432a: 83 e4 f0 and $0xfffffff0,%esp - /** - * keyboard interrupt init - */ - vector_t v; - unsigned i; - - init_video(); - 10432d: e8 e6 07 00 00 call 104b18 - init_keyboard(); - 104332: e8 45 d2 ff ff call 10157c - init_8259s(); - 104337: e8 54 fb ff ff call 103e90 - - /** - * XXX: - * i know this is a very ugly way of doing this, - * however it is the only way it can be done for now. - * in the future, i will implement a kprintf function - * whose sole purpose will be writing boot messages. - * - * Also, the color codes need to be mapped to constants - * in order to make using them a hell of a lot easier. - */ - - klog("init", "Installing keyboard interrupt handler", K_KLOG_PENDING, &_vc[0]); - 10433c: 68 e0 a2 19 00 push $0x19a2e0 - 104341: 6a 01 push $0x1 - 104343: 68 20 60 10 00 push $0x106020 - 104348: 68 bc 5a 10 00 push $0x105abc - 10434d: e8 ae bc ff ff call 100000 - /* we don't save the old vector */ - v.eip = (unsigned)keyboard_irq; - v.access_byte = 0x8E; /* present, ring 0, '386 interrupt gate */ - setvect(&v, 0x21); - 104352: 58 pop %eax - 104353: 5a pop %edx - 104354: 8d 45 f8 lea 0xfffffff8(%ebp),%eax - 104357: 6a 21 push $0x21 - 104359: 50 push %eax - 10435a: c7 45 fc 1c 13 10 00 movl $0x10131c,0xfffffffc(%ebp) - 104361: c7 45 f8 8e 00 00 00 movl $0x8e,0xfffffff8(%ebp) - 104368: e8 c4 d3 ff ff call 101731 <_setvect> - klog(NULL, NULL, K_KLOG_SUCCESS, &_vc[0]); - 10436d: 68 e0 a2 19 00 push $0x19a2e0 - 104372: 6a 00 push $0x0 - 104374: 6a 00 push $0x0 - 104376: 6a 00 push $0x0 - 104378: e8 83 bc ff ff call 100000 - - /*init_tasks();*/ - - klog("init", "Enabling hardware interrupts", K_KLOG_PENDING, &_vc[0]); - 10437d: 83 c4 20 add $0x20,%esp - 104380: 68 e0 a2 19 00 push $0x19a2e0 - 104385: 6a 01 push $0x1 - 104387: 68 c1 5a 10 00 push $0x105ac1 - 10438c: 68 bc 5a 10 00 push $0x105abc - 104391: e8 6a bc ff ff call 100000 - enable(); - 104396: e8 71 0c 00 00 call 10500c - /*for(i = 0; i < 0xFFFFFFF; i++);*/ - klog(NULL, NULL, K_KLOG_SUCCESS, &_vc[0]); - 10439b: 68 e0 a2 19 00 push $0x19a2e0 - 1043a0: 6a 00 push $0x0 - 1043a2: 6a 00 push $0x0 - 1043a4: 6a 00 push $0x0 - 1043a6: e8 55 bc ff ff call 100000 - - /** - * Initialize memory management - */ - /*_mm_init();*/ - - /** - * finished init, time for some gooey ;) - */ - printf(" _ _ _ _ ____ _____ ___ "); - 1043ab: 83 c4 14 add $0x14,%esp - 1043ae: 68 60 60 10 00 push $0x106060 - 1043b3: e8 1c 0d 00 00 call 1050d4 - printf(" ( )_( )( \\/ )( _ \\( _ )/ __) "); - 1043b8: c7 04 24 c0 60 10 00 movl $0x1060c0,(%esp,1) - 1043bf: e8 10 0d 00 00 call 1050d4 - printf(" ) _ ( \\ / ) _ < )(_)( \\__ \\ "); - 1043c4: c7 04 24 20 61 10 00 movl $0x106120,(%esp,1) - 1043cb: e8 04 0d 00 00 call 1050d4 - printf(" (_) (_) (__) (____/(_____)(___/ \n"); - 1043d0: c7 04 24 80 61 10 00 movl $0x106180,(%esp,1) - 1043d7: e8 f8 0c 00 00 call 1050d4 - - printf(" Hybrid Operating System (HybOS) \n"); - 1043dc: c7 04 24 e0 61 10 00 movl $0x1061e0,(%esp,1) - 1043e3: e8 ec 0c 00 00 call 1050d4 - - /** - * XXX: debug only - */ - printf("ALT + F1 - F8 for virtual terminals\n"); - 1043e8: c7 04 24 40 62 10 00 movl $0x106240,(%esp,1) - 1043ef: e8 e0 0c 00 00 call 1050d4 - printf("Three finger salute to restart\n"); - 1043f4: c7 04 24 80 62 10 00 movl $0x106280,(%esp,1) - 1043fb: e8 d4 0c 00 00 call 1050d4 - printf("More work needs to be done\n"); - 104400: c7 04 24 de 5a 10 00 movl $0x105ade,(%esp,1) - 104407: e8 c8 0c 00 00 call 1050d4 - printf("$ "); - 10440c: c7 04 24 d6 54 10 00 movl $0x1054d6,(%esp,1) - 104413: e8 bc 0c 00 00 call 1050d4 - - /** - * fork (kfork()) control over to a shell - */ - /*init_shell();*/ - - /** - * idle task/thread - */ - while(1) - 104418: 83 c4 10 add $0x10,%esp - 10441b: 90 nop - { - schedule(); - 10441c: e8 47 01 00 00 call 104568 - 104421: eb f9 jmp 10441c - ... - -00104424 <_mm_init>: -void _mm_page_copy_dword(uint32_t dest, uint32_t src); -void _mm_virtual_init(void); - -void _mm_init(void) -{ - 104424: 55 push %ebp - 104425: 89 e5 mov %esp,%ebp - 104427: 83 ec 08 sub $0x8,%esp - klog("init", "Initializing memory management", K_KLOG_PENDING, &_vc[0]); - 10442a: 68 e0 a2 19 00 push $0x19a2e0 - 10442f: 6a 01 push $0x1 - 104431: 68 a0 62 10 00 push $0x1062a0 - 104436: 68 bc 5a 10 00 push $0x105abc - 10443b: e8 c0 bb ff ff call 100000 - _mm_physical_init(); - 104440: e8 17 00 00 00 call 10445c <_mm_physical_init> - _mm_virtual_init(); - 104445: e8 ce 00 00 00 call 104518 <_mm_virtual_init> - klog((void *)0, (void *)0, K_KLOG_SUCCESS, &_vc[0]); - 10444a: 68 e0 a2 19 00 push $0x19a2e0 - 10444f: 6a 00 push $0x0 - 104451: 6a 00 push $0x0 - 104453: 6a 00 push $0x0 - 104455: e8 a6 bb ff ff call 100000 -} - 10445a: c9 leave - 10445b: c3 ret - -0010445c <_mm_physical_init>: - -void _mm_physical_init(void) -{ - 10445c: 55 push %ebp - 10445d: 89 e5 mov %esp,%ebp - unsigned i; - unsigned size = 16 * 1024 * 1024; - - size /= PAGESIZE; - size++; - size /= 32; - - buffer = (unsigned *)0x40000; - 10445f: ba 00 00 04 00 mov $0x40000,%edx - 104464: c7 05 84 72 19 00 00 movl $0x40000,0x197284 - 10446b: 00 04 00 - bufferIterator = (unsigned *)0x40000; - 10446e: c7 05 80 72 19 00 00 movl $0x40000,0x197280 - 104475: 00 04 00 - - for(i = 0; i < 72; i++) - 104478: 31 c0 xor %eax,%eax - 10447a: 89 f6 mov %esi,%esi - buffer[i] = 0xFFFFFFFF; - 10447c: c7 04 82 ff ff ff ff movl $0xffffffff,(%edx,%eax,4) - 104483: 40 inc %eax - 104484: 83 f8 47 cmp $0x47,%eax - 104487: 76 f3 jbe 10447c <_mm_physical_init+0x20> - 104489: b8 48 00 00 00 mov $0x48,%eax - 10448e: 89 f6 mov %esi,%esi - - for(i = 72; i < size; i++) - buffer[i] = 0x00000000; - 104490: c7 04 82 00 00 00 00 movl $0x0,(%edx,%eax,4) - 104497: 40 inc %eax - 104498: 3d 80 00 00 00 cmp $0x80,%eax - 10449d: 72 f1 jb 104490 <_mm_physical_init+0x34> -} - 10449f: c9 leave - 1044a0: c3 ret - 1044a1: 8d 76 00 lea 0x0(%esi),%esi - -001044a4 <_mm_physical_alloc>: - -unsigned _mm_physical_alloc(void) -{ - 1044a4: 55 push %ebp - 1044a5: 89 e5 mov %esp,%ebp - 1044a7: 56 push %esi - 1044a8: 53 push %ebx - unsigned mask = 0x00000001; - unsigned bit = 0; - - /** - * Search for a free space - */ - while(*bufferIterator == 0xFFFFFFFF) - 1044a9: 8b 15 80 72 19 00 mov 0x197280,%edx - 1044af: 31 f6 xor %esi,%esi - 1044b1: 83 3a ff cmpl $0xffffffff,(%edx) - 1044b4: b9 01 00 00 00 mov $0x1,%ecx - 1044b9: 74 1f je 1044da <_mm_physical_alloc+0x36> - bufferIterator++; - - /** - * Search for a bit that indicates a free page - */ - while(*bufferIterator & mask) - 1044bb: 8b 02 mov (%edx),%eax - 1044bd: a8 01 test $0x1,%al - 1044bf: 74 0a je 1044cb <_mm_physical_alloc+0x27> - 1044c1: 8d 76 00 lea 0x0(%esi),%esi - { - mask <<= 1; - 1044c4: d1 e1 shl %ecx - bit++; - 1044c6: 46 inc %esi - 1044c7: 85 c1 test %eax,%ecx - 1044c9: 75 f9 jne 1044c4 <_mm_physical_alloc+0x20> - } - - *bufferIterator |= mask; - 1044cb: 09 0a or %ecx,(%edx) - - return 32 * (bufferIterator - buffer) + bit; -} - 1044cd: 5b pop %ebx - 1044ce: 2b 15 84 72 19 00 sub 0x197284,%edx - 1044d4: 8d 04 d6 lea (%esi,%edx,8),%eax - 1044d7: 5e pop %esi - 1044d8: c9 leave - 1044d9: c3 ret - 1044da: 8d 42 04 lea 0x4(%edx),%eax - 1044dd: 8d 76 00 lea 0x0(%esi),%esi - 1044e0: 89 c2 mov %eax,%edx - 1044e2: 8d 40 04 lea 0x4(%eax),%eax - 1044e5: 83 78 fc ff cmpl $0xffffffff,0xfffffffc(%eax) - 1044e9: 74 f5 je 1044e0 <_mm_physical_alloc+0x3c> - 1044eb: 89 15 80 72 19 00 mov %edx,0x197280 - 1044f1: eb c8 jmp 1044bb <_mm_physical_alloc+0x17> - 1044f3: 90 nop - -001044f4 <_mm_physical_free>: - -void _mm_physical_free(unsigned page) -{ - 1044f4: 55 push %ebp - 1044f5: 89 e5 mov %esp,%ebp - 1044f7: 8b 4d 08 mov 0x8(%ebp),%ecx - 1044fa: 53 push %ebx - buffer[page >> 5] &= ~(1 << (page & 0x1F)); /* confused yet?!? */ - 1044fb: b8 fe ff ff ff mov $0xfffffffe,%eax - 104500: 89 cb mov %ecx,%ebx - 104502: 83 e1 1f and $0x1f,%ecx - 104505: c1 eb 05 shr $0x5,%ebx - 104508: 8b 15 84 72 19 00 mov 0x197284,%edx - 10450e: d3 c0 rol %cl,%eax - 104510: 21 04 9a and %eax,(%edx,%ebx,4) -} - 104513: 8b 1c 24 mov (%esp,1),%ebx - 104516: c9 leave - 104517: c3 ret - -00104518 <_mm_virtual_init>: - -void _mm_virtual_init(void) -{ - 104518: 55 push %ebp - 104519: 89 e5 mov %esp,%ebp - 10451b: c9 leave - 10451c: c3 ret - 10451d: 8d 76 00 lea 0x0(%esi),%esi - -00104520 <_mm_page_copy_byte>: -} - -void _mm_page_copy_byte(uint32_t dest, uint32_t src) -{ - 104520: 55 push %ebp - 104521: 89 e5 mov %esp,%ebp - 104523: 57 push %edi - 104524: 56 push %esi - 104525: 8b 7d 08 mov 0x8(%ebp),%edi - 104528: 8b 75 0c mov 0xc(%ebp),%esi - __asm__ __volatile__ - 10452b: b9 00 00 10 00 mov $0x100000,%ecx - 104530: fc cld - 104531: f3 a4 repz movsb %ds:(%esi),%es:(%edi) - ( - "cld;" - "rep; movsb;" - : - : "c" (1024*1024), "D" (dest), "S" (src) - : "memory" - ); -} - 104533: 5e pop %esi - 104534: 5f pop %edi - 104535: c9 leave - 104536: c3 ret - 104537: 90 nop - -00104538 <_mm_page_copy_word>: - -void _mm_page_copy_word(uint32_t dest, uint32_t src) -{ - 104538: 55 push %ebp - 104539: 89 e5 mov %esp,%ebp - 10453b: 57 push %edi - 10453c: 56 push %esi - 10453d: 8b 7d 08 mov 0x8(%ebp),%edi - 104540: 8b 75 0c mov 0xc(%ebp),%esi - __asm__ __volatile__ - 104543: b9 00 00 08 00 mov $0x80000,%ecx - 104548: fc cld - 104549: f3 66 a5 repz movsw %ds:(%esi),%es:(%edi) - ( - "cld;" - "rep; movsw;" - : - : "c" (512*1024), "D" (dest), "S" (src) - : "memory" - ); -} - 10454c: 5e pop %esi - 10454d: 5f pop %edi - 10454e: c9 leave - 10454f: c3 ret - -00104550 <_mm_page_copy_dword>: - -void _mm_page_copy_dword(uint32_t dest, uint32_t src) -{ - 104550: 55 push %ebp - 104551: 89 e5 mov %esp,%ebp - 104553: 57 push %edi - 104554: 56 push %esi - 104555: 8b 7d 08 mov 0x8(%ebp),%edi - 104558: 8b 75 0c mov 0xc(%ebp),%esi - __asm__ __volatile__ - 10455b: b9 00 00 04 00 mov $0x40000,%ecx - 104560: fc cld - 104561: f3 a5 repz movsl %ds:(%esi),%es:(%edi) - ( - "cld;" - "rep; movsl;" - : - : "c" (256*1024), "D" (dest), "S" (src) - : "memory" - ); -} - 104563: 5e pop %esi - 104564: 5f pop %edi - 104565: c9 leave - 104566: c3 ret - ... - -00104568 : - * schedule() - * - */ -void schedule(void) -{ - 104568: 55 push %ebp - 104569: 89 e5 mov %esp,%ebp - 10456b: 83 ec 08 sub $0x8,%esp - static unsigned current; - - /** - * If setjmp() returns non-zero it means that we came here through - * hyperspace from our call to longjmp() below, so just return - */ -/** UBU - if(setjmp(_curr_task->state) != 0) - return; -**/ - - /** - * Try to find the next runnable task - */ - do - 10456e: 8b 15 00 37 18 00 mov 0x183700,%edx - { - current++; - 104574: 42 inc %edx - if(current >= MAX_TASK) - 104575: 83 fa 0f cmp $0xf,%edx - 104578: 89 d0 mov %edx,%eax - 10457a: 76 04 jbe 104580 - current = 0; - 10457c: 31 c0 xor %eax,%eax - 10457e: 31 d2 xor %edx,%edx - _curr_task = _tasks + current; - 104580: 8d 04 40 lea (%eax,%eax,2),%eax - 104583: c1 e0 04 shl $0x4,%eax - 104586: 05 20 37 18 00 add $0x183720,%eax - } while(_curr_task->status != TS_RUNNABLE); - 10458b: 83 78 2c 01 cmpl $0x1,0x2c(%eax) - 10458f: 75 e3 jne 104574 - - /** - * Jump to the new task - */ - longjmp(_curr_task->state, 1); - 104591: 83 ec 08 sub $0x8,%esp - 104594: a3 a0 a2 19 00 mov %eax,0x19a2a0 - 104599: 6a 01 push $0x1 - 10459b: 83 c0 04 add $0x4,%eax - 10459e: 50 push %eax - 10459f: 89 15 00 37 18 00 mov %edx,0x183700 - 1045a5: e8 76 0a 00 00 call 105020 - 1045aa: 89 f6 mov %esi,%esi - -001045ac : -} -/***************************************************************************** -*****************************************************************************/ -#define NUM_TASKS 0 - -/** - * init_tasks() - * - */ -void init_tasks(void) -{ - 1045ac: 55 push %ebp - 1045ad: 89 e5 mov %esp,%ebp - 1045af: 83 ec 08 sub $0x8,%esp - static unsigned char stacks[NUM_TASKS][USER_STACK_SIZE]; - /*static unsigned entry[NUM_TASKS] = - { - 0, (unsigned)task1, - (unsigned)task2, (unsigned)task3, - (unsigned)task4 - };*/ - static unsigned entry[NUM_TASKS]; - - unsigned adr, i; - - klog("init", "task handler", K_KLOG_PENDING, &_vc[0]); - 1045b2: 68 e0 a2 19 00 push $0x19a2e0 - 1045b7: 6a 01 push $0x1 - 1045b9: 68 c4 62 10 00 push $0x1062c4 - 1045be: 68 bc 5a 10 00 push $0x105abc - 1045c3: e8 38 ba ff ff call 100000 - - /** - * For user taskes, initialize the saved state - */ - for(i = 1; i < NUM_TASKS; i++) - 1045c8: 83 c4 10 add $0x10,%esp - { - (void)setjmp(_tasks[i].state); - - /** - * especially the stack pointer - */ - adr = (unsigned)(stacks[i] + USER_STACK_SIZE); - _tasks[i].state[0].JMPBUF_SP = adr; - - /** - * and program counter - */ - _tasks[i].state[0].JMPBUF_IP = entry[i]; - - /** - * enable interrupts (by setting EFLAGS value) - */ - _tasks[i].state[0].JMPBUF_FLAGS = 0x200; - - /** - * allocate a virtual console to this task - */ - _tasks[i].vc = _vc + i; - - /** - * and mark it as runnable - */ - _tasks[i].status = TS_RUNNABLE; - } - - /** - * mark task 0 runnable (idle task) - */ - _tasks[0].status = TS_RUNNABLE; - 1045cb: c7 05 4c 37 18 00 01 movl $0x1,0x18374c - 1045d2: 00 00 00 - - /** - * set _curr_task so schedule() will save state - * of task 0 - */ - _curr_task = _tasks + 0; - - klog(NULL, NULL, K_KLOG_SUCCESS, &_vc[0]); - 1045d5: 68 e0 a2 19 00 push $0x19a2e0 - 1045da: 6a 00 push $0x0 - 1045dc: 6a 00 push $0x0 - 1045de: 6a 00 push $0x0 - 1045e0: c7 05 a0 a2 19 00 20 movl $0x183720,0x19a2a0 - 1045e7: 37 18 00 - 1045ea: e8 11 ba ff ff call 100000 -} - 1045ef: c9 leave - 1045f0: c3 ret - 1045f1: 00 00 add %al,(%eax) - ... - -001045f4 : - * write() - * - */ -static int write(const unsigned char *str, unsigned len) -{ - 1045f4: 55 push %ebp - 1045f5: 89 e5 mov %esp,%ebp - 1045f7: 57 push %edi - 1045f8: 56 push %esi - 1045f9: 53 push %ebx - 1045fa: 83 ec 0c sub $0xc,%esp - 1045fd: 8b 7d 0c mov 0xc(%ebp),%edi - unsigned i; - - for(i = 0; i < len; i++) - 104600: 31 f6 xor %esi,%esi - 104602: 39 fe cmp %edi,%esi - 104604: 8b 5d 08 mov 0x8(%ebp),%ebx - 104607: 72 0b jb 104614 - { - putch_help(_curr_task->vc, *str); - str++; - } - return i; -} - 104609: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 10460c: 5b pop %ebx - 10460d: 89 f0 mov %esi,%eax - 10460f: 5e pop %esi - 104610: 5f pop %edi - 104611: c9 leave - 104612: c3 ret - 104613: 90 nop - 104614: 83 ec 08 sub $0x8,%esp - 104617: 0f b6 03 movzbl (%ebx),%eax - 10461a: 50 push %eax - 10461b: a1 a0 a2 19 00 mov 0x19a2a0,%eax - 104620: ff 30 pushl (%eax) - 104622: 46 inc %esi - 104623: e8 68 02 00 00 call 104890 - 104628: 43 inc %ebx - 104629: 83 c4 10 add $0x10,%esp - 10462c: 39 fe cmp %edi,%esi - 10462e: 72 e4 jb 104614 - 104630: eb d7 jmp 104609 - 104632: 89 f6 mov %esi,%esi - -00104634 : - -/** - * yield() - * - */ -static void yield(void) -{ - 104634: 55 push %ebp - 104635: 89 e5 mov %esp,%ebp - schedule(); - 104637: c9 leave - 104638: e9 2b ff ff ff jmp 104568 - 10463d: 8d 76 00 lea 0x0(%esi),%esi - -00104640 : -} - -#define WAIT 0xFFFFFL - -/** - * wait() - */ -static void wait(void) -{ - 104640: 55 push %ebp - 104641: 89 e5 mov %esp,%ebp - unsigned long wait; - - for(wait = WAIT; wait != 0; wait--) - 104643: b8 ff ff 0f 00 mov $0xfffff,%eax - 104648: 48 dec %eax - 104649: 75 fd jne 104648 - /* nothing */; -} - 10464b: c9 leave - 10464c: c3 ret - 10464d: 8d 76 00 lea 0x0(%esi),%esi - -00104650 : - -/** - * task1() - * - */ -void task1(void) -{ - 104650: 55 push %ebp - 104651: 89 e5 mov %esp,%ebp - 104653: 83 ec 08 sub $0x8,%esp - 104656: 89 f6 mov %esi,%esi - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - 104658: e8 e3 ff ff ff call 104640 - while(1) - { - /* so we can process other events */ - yield(); - 10465d: e8 d2 ff ff ff call 104634 - wait(); - 104662: eb f4 jmp 104658 - -00104664 : - } -} - -/** - * task2() - * - */ -void task2(void) -{ - 104664: 55 push %ebp - 104665: 89 e5 mov %esp,%ebp - 104667: 83 ec 08 sub $0x8,%esp - 10466a: 89 f6 mov %esi,%esi - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - 10466c: e8 cf ff ff ff call 104640 - while(1) - { - yield(); - 104671: e8 be ff ff ff call 104634 - wait(); - 104676: eb f4 jmp 10466c - -00104678 : - } -} - -/** - * task3() - * - */ -void task3(void) -{ - 104678: 55 push %ebp - 104679: 89 e5 mov %esp,%ebp - 10467b: 83 ec 08 sub $0x8,%esp - 10467e: 89 f6 mov %esi,%esi - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - 104680: e8 bb ff ff ff call 104640 - while(1) - { - yield(); - 104685: e8 aa ff ff ff call 104634 - wait(); - 10468a: eb f4 jmp 104680 - -0010468c : - } -} - -/** - * task4() - * - */ -void task4(void) -{ - 10468c: 55 push %ebp - 10468d: 89 e5 mov %esp,%ebp - 10468f: 83 ec 08 sub $0x8,%esp - 104692: 89 f6 mov %esi,%esi - //static const unsigned char msg_a[] = "root@hybos $ "; -/**/ - - //write(msg_a, sizeof(msg_a)); - wait(); - 104694: e8 a7 ff ff ff call 104640 - while(1) - { - yield(); - 104699: e8 96 ff ff ff call 104634 - wait(); - 10469e: eb f4 jmp 104694 - -001046a0 : - * blink() - * - */ -void blink(void) -{ - 1046a0: 55 push %ebp - (*(unsigned char *)_vga_fb_adr)++; - 1046a1: a1 28 3a 18 00 mov 0x183a28,%eax - 1046a6: 89 e5 mov %esp,%ebp - 1046a8: fe 00 incb (%eax) -} - 1046aa: c9 leave - 1046ab: c3 ret - -001046ac : - -/** - * get_current_vc() - * - */ -unsigned get_current_vc() -{ - 1046ac: 55 push %ebp - 1046ad: 89 e5 mov %esp,%ebp - return curr_vtty; - 1046af: a1 c0 a2 19 00 mov 0x19a2c0,%eax -} - 1046b4: c9 leave - 1046b5: c3 ret - 1046b6: 89 f6 mov %esi,%esi - -001046b8 : - -/** - * scroll() - * - */ -static void scroll(console_t *con) -{ - 1046b8: 55 push %ebp - 1046b9: 89 e5 mov %esp,%ebp - 1046bb: 57 push %edi - 1046bc: 56 push %esi - 1046bd: 53 push %ebx - 1046be: 83 ec 0c sub $0xc,%esp - unsigned short *fb_adr; - unsigned blank, temp; - - blank = 0x20 | ((unsigned)con->attrib << 8); - 1046c1: 8b 45 08 mov 0x8(%ebp),%eax - 1046c4: 8b 70 18 mov 0x18(%eax),%esi - 1046c7: c1 e6 08 shl $0x8,%esi - fb_adr = con->fb_adr; - 1046ca: 8b 78 30 mov 0x30(%eax),%edi - - /** - * scroll up - */ - if(con->csr_y >= _vc_height) - 1046cd: 8b 15 34 3a 18 00 mov 0x183a34,%edx - 1046d3: 8b 40 20 mov 0x20(%eax),%eax - 1046d6: 83 ce 20 or $0x20,%esi - 1046d9: 39 d0 cmp %edx,%eax - 1046db: 73 0b jae 1046e8 - { - temp = con->csr_y - _vc_height + 1; - memcpy(fb_adr, fb_adr + temp * _vc_width, - (_vc_height - temp) * _vc_width * 2); - - /** - * blank bottom line of screen - */ - memsetw(fb_adr + (_vc_height - temp) * _vc_width, - blank, _vc_width); - con->csr_y = _vc_height - 1; - } - - //for(i = 0; i < 0x1000000; i++) ; -} - 1046dd: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 1046e0: 5b pop %ebx - 1046e1: 5e pop %esi - 1046e2: 5f pop %edi - 1046e3: c9 leave - 1046e4: c3 ret - 1046e5: 8d 76 00 lea 0x0(%esi),%esi - 1046e8: 29 d0 sub %edx,%eax - 1046ea: 8d 58 01 lea 0x1(%eax),%ebx - 1046ed: 29 da sub %ebx,%edx - 1046ef: 50 push %eax - 1046f0: a1 30 3a 18 00 mov 0x183a30,%eax - 1046f5: 0f af d0 imul %eax,%edx - 1046f8: d1 e2 shl %edx - 1046fa: 0f af c3 imul %ebx,%eax - 1046fd: 52 push %edx - 1046fe: 8d 04 47 lea (%edi,%eax,2),%eax - 104701: 50 push %eax - 104702: 57 push %edi - 104703: e8 54 09 00 00 call 10505c - 104708: a1 34 3a 18 00 mov 0x183a34,%eax - 10470d: 83 c4 0c add $0xc,%esp - 104710: 29 d8 sub %ebx,%eax - 104712: ff 35 30 3a 18 00 pushl 0x183a30 - 104718: 0f af 05 30 3a 18 00 imul 0x183a30,%eax - 10471f: 56 push %esi - 104720: 8d 04 47 lea (%edi,%eax,2),%eax - 104723: 50 push %eax - 104724: e8 5f 09 00 00 call 105088 - 104729: a1 34 3a 18 00 mov 0x183a34,%eax - 10472e: 48 dec %eax - 10472f: 8b 55 08 mov 0x8(%ebp),%edx - 104732: 89 42 20 mov %eax,0x20(%edx) - 104735: 83 c4 10 add $0x10,%esp - 104738: eb a3 jmp 1046dd - 10473a: 89 f6 mov %esi,%esi - -0010473c : - -/** - * set_attrib() - * - */ -static void set_attrib(console_t *con, unsigned att) -{ - 10473c: 55 push %ebp - 10473d: 89 e5 mov %esp,%ebp - 10473f: 8b 4d 0c mov 0xc(%ebp),%ecx - 104742: 53 push %ebx - static const unsigned ansi_to_vga[] = - { - 0, 4, 2, 6, 1, 5, 3, 7 - }; - - unsigned new_att; - - new_att = con->attrib; - if(att == 0) - 104743: 85 c9 test %ecx,%ecx - 104745: 8b 5d 08 mov 0x8(%ebp),%ebx - 104748: 8b 53 18 mov 0x18(%ebx),%edx - 10474b: 75 0b jne 104758 - new_att &= ~0x08; /* bold off */ - 10474d: 83 e2 f7 and $0xfffffff7,%edx - else if(att == 1) - new_att |= 0x08; /* bold on */ - else if(att >= 30 && att <= 37) - { - att = ansi_to_vga[att - 30]; - new_att = (new_att & ~0x07) | att;/* fg color */ - } - else if(att >= 40 && att <= 47) - { - att = ansi_to_vga[att - 40] << 4; - new_att = (new_att & ~0x70) | att;/* bg color */ - } - con->attrib = new_att; - 104750: 89 53 18 mov %edx,0x18(%ebx) -} - 104753: 8b 1c 24 mov (%esp,1),%ebx - 104756: c9 leave - 104757: c3 ret - 104758: 83 f9 01 cmp $0x1,%ecx - 10475b: 74 33 je 104790 - 10475d: 8d 41 e2 lea 0xffffffe2(%ecx),%eax - 104760: 83 f8 07 cmp $0x7,%eax - 104763: 77 0f ja 104774 - 104765: 83 e2 f8 and $0xfffffff8,%edx - 104768: 0b 14 8d 68 62 10 00 or 0x106268(,%ecx,4),%edx - 10476f: eb df jmp 104750 - 104771: 8d 76 00 lea 0x0(%esi),%esi - 104774: 8d 41 d8 lea 0xffffffd8(%ecx),%eax - 104777: 83 f8 07 cmp $0x7,%eax - 10477a: 77 d4 ja 104750 - 10477c: 8b 04 8d 40 62 10 00 mov 0x106240(,%ecx,4),%eax - 104783: c1 e0 04 shl $0x4,%eax - 104786: 83 e2 8f and $0xffffff8f,%edx - 104789: 09 c2 or %eax,%edx - 10478b: eb c3 jmp 104750 - 10478d: 8d 76 00 lea 0x0(%esi),%esi - 104790: 83 ca 08 or $0x8,%edx - 104793: eb bb jmp 104750 - 104795: 8d 76 00 lea 0x0(%esi),%esi - -00104798 : - -/** - * move_csr() - * - */ -static void move_csr(void) -{ - 104798: 55 push %ebp - 104799: 89 e5 mov %esp,%ebp - 10479b: 53 push %ebx - 10479c: 83 ec 0c sub $0xc,%esp - unsigned temp; - - temp = (_curr_vc->csr_y * _vc_width + _curr_vc->csr_x) + - 10479f: a1 24 3a 18 00 mov 0x183a24,%eax - 1047a4: 8b 1d 30 3a 18 00 mov 0x183a30,%ebx - 1047aa: 0f af 58 20 imul 0x20(%eax),%ebx - 1047ae: 03 58 1c add 0x1c(%eax),%ebx - 1047b1: 8b 40 30 mov 0x30(%eax),%eax - 1047b4: 2b 05 28 3a 18 00 sub 0x183a28,%eax - (_curr_vc->fb_adr - _vga_fb_adr); - outportb(_crtc_io_adr + 0, 14); - 1047ba: 6a 0e push $0xe - 1047bc: d1 f8 sar %eax - 1047be: ff 35 2c 3a 18 00 pushl 0x183a2c - 1047c4: 01 c3 add %eax,%ebx - 1047c6: e8 e9 08 00 00 call 1050b4 - outportb(_crtc_io_adr + 1, temp >> 8); - 1047cb: 59 pop %ecx - 1047cc: 58 pop %eax - 1047cd: 89 d8 mov %ebx,%eax - 1047cf: c1 e8 08 shr $0x8,%eax - 1047d2: 50 push %eax - 1047d3: a1 2c 3a 18 00 mov 0x183a2c,%eax - 1047d8: 40 inc %eax - 1047d9: 50 push %eax - 1047da: e8 d5 08 00 00 call 1050b4 - outportb(_crtc_io_adr + 0, 15); - 1047df: 58 pop %eax - 1047e0: 5a pop %edx - 1047e1: 6a 0f push $0xf - 1047e3: ff 35 2c 3a 18 00 pushl 0x183a2c - 1047e9: e8 c6 08 00 00 call 1050b4 - outportb(_crtc_io_adr + 1, temp); - 1047ee: 5a pop %edx - 1047ef: 59 pop %ecx - 1047f0: a1 2c 3a 18 00 mov 0x183a2c,%eax - 1047f5: 53 push %ebx - 1047f6: 40 inc %eax - 1047f7: 50 push %eax - 1047f8: e8 b7 08 00 00 call 1050b4 -} - 1047fd: 8b 5d fc mov 0xfffffffc(%ebp),%ebx - 104800: c9 leave - 104801: c3 ret - 104802: 89 f6 mov %esi,%esi - -00104804 : - - -/** - * select_vc() - * - */ -void select_vc(unsigned which_vc) -{ - 104804: 55 push %ebp - 104805: 89 e5 mov %esp,%ebp - 104807: 56 push %esi - 104808: 53 push %ebx - 104809: 8b 75 08 mov 0x8(%ebp),%esi - unsigned i; - - if(which_vc >= _num_vcs) - 10480c: 3b 35 20 3a 18 00 cmp 0x183a20,%esi - 104812: 72 08 jb 10481c - return; - _curr_vc = _vc + which_vc; - i = _curr_vc->fb_adr - _vga_fb_adr; - outportb(_crtc_io_adr + 0, 12); - outportb(_crtc_io_adr + 1, i >> 8); - outportb(_crtc_io_adr + 0, 13); - outportb(_crtc_io_adr + 1, i); - - curr_vtty = which_vc; - - move_csr(); -} - 104814: 8d 65 f8 lea 0xfffffff8(%ebp),%esp - 104817: 5b pop %ebx - 104818: 5e pop %esi - 104819: c9 leave - 10481a: c3 ret - 10481b: 90 nop - 10481c: 8d 04 76 lea (%esi,%esi,2),%eax - 10481f: 8d 04 86 lea (%esi,%eax,4),%eax - 104822: 8d 04 85 e0 a2 19 00 lea 0x19a2e0(,%eax,4),%eax - 104829: 8b 58 30 mov 0x30(%eax),%ebx - 10482c: 83 ec 08 sub $0x8,%esp - 10482f: a3 24 3a 18 00 mov %eax,0x183a24 - 104834: 2b 1d 28 3a 18 00 sub 0x183a28,%ebx - 10483a: 6a 0c push $0xc - 10483c: d1 fb sar %ebx - 10483e: ff 35 2c 3a 18 00 pushl 0x183a2c - 104844: e8 6b 08 00 00 call 1050b4 - 104849: 58 pop %eax - 10484a: 89 d8 mov %ebx,%eax - 10484c: 5a pop %edx - 10484d: c1 e8 08 shr $0x8,%eax - 104850: 50 push %eax - 104851: a1 2c 3a 18 00 mov 0x183a2c,%eax - 104856: 40 inc %eax - 104857: 50 push %eax - 104858: e8 57 08 00 00 call 1050b4 - 10485d: 59 pop %ecx - 10485e: 58 pop %eax - 10485f: 6a 0d push $0xd - 104861: ff 35 2c 3a 18 00 pushl 0x183a2c - 104867: e8 48 08 00 00 call 1050b4 - 10486c: 58 pop %eax - 10486d: 5a pop %edx - 10486e: 53 push %ebx - 10486f: a1 2c 3a 18 00 mov 0x183a2c,%eax - 104874: 40 inc %eax - 104875: 50 push %eax - 104876: e8 39 08 00 00 call 1050b4 - 10487b: 89 35 c0 a2 19 00 mov %esi,0x19a2c0 - 104881: 83 c4 10 add $0x10,%esp - 104884: 8d 65 f8 lea 0xfffffff8(%ebp),%esp - 104887: 5b pop %ebx - 104888: 5e pop %esi - 104889: c9 leave - 10488a: e9 09 ff ff ff jmp 104798 - 10488f: 90 nop - -00104890 : - -/** - * putch_help() - * - */ -void putch_help(console_t *con, unsigned c) -{ - 104890: 55 push %ebp - 104891: 89 e5 mov %esp,%ebp - 104893: 57 push %edi - 104894: 56 push %esi - 104895: 53 push %ebx - 104896: 83 ec 0c sub $0xc,%esp - 104899: 8b 5d 08 mov 0x8(%ebp),%ebx - unsigned short *fb_adr; - unsigned att; - - att = (unsigned)con->attrib << 8; - 10489c: 8b 73 18 mov 0x18(%ebx),%esi - fb_adr = con->fb_adr; - - /** - * state machine to handle escape sequences - * - * ESC - */ - if(con->esc == 1) - 10489f: 8b 43 14 mov 0x14(%ebx),%eax - 1048a2: c1 e6 08 shl $0x8,%esi - 1048a5: 83 f8 01 cmp $0x1,%eax - 1048a8: 8b 4d 0c mov 0xc(%ebp),%ecx - 1048ab: 8b 7b 30 mov 0x30(%ebx),%edi - 1048ae: 0f 84 30 02 00 00 je 104ae4 - { - if(c == '[') - { - con->esc++; - con->esc1 = 0; - return; - } - /* else fall-through: zero esc and print c */ - } - - /** - * ESC[ - */ - else if(con->esc == 2) - 1048b4: 83 f8 02 cmp $0x2,%eax - 1048b7: 0f 84 a3 01 00 00 je 104a60 - { - if(isdigit(c)) - { - con->esc1 = con->esc1 * 10 + c - '0'; - return; - } - else if(c == ';') - { - con->esc++; - con->esc2 = 0; - return; - } - - /** - * ESC[2J (clear screen) - */ - else if(c == 'J') - { - if(con->esc1 == 2) - { - memsetw(fb_adr, ' ' | att, - _vc_height * _vc_width); - con->csr_x = con->csr_y = 0; - } - } - - /** - * ESC[num1m (set attribute num1) - */ - else if(c == 'm') - set_attrib(con, con->esc1); - con->esc = 0; /* anything else with one numeric arg */ - return; - } - - /** - * ESC[num1 - */ - else if(con->esc == 3) - 1048bd: 83 f8 03 cmp $0x3,%eax - 1048c0: 0f 84 22 01 00 00 je 1049e8 - { - if(isdigit(c)) - { - con->esc2 = con->esc2 * 10 + c - '0'; - return; - } - else if(c == ';') - { - con->esc++; /* ESC[num1;num2; */ - con->esc3 = 0; - return; - } - - /** - * ESC[num1;num2H (move cursor to num1,num2) - */ - else if(c == 'H') - { - if(con->esc2 < _vc_width) - con->csr_x = con->esc2; - if(con->esc1 < _vc_height) - con->csr_y = con->esc1; - } - - /** - * ESC[num1;num2m (set attributes num1,num2) - */ - else if(c == 'm') - { - set_attrib(con, con->esc1); - set_attrib(con, con->esc2); - } - con->esc = 0; - return; - } - /** - * ESC[num1;num2;num3 - */ - else if(con->esc == 4) - 1048c6: 83 f8 04 cmp $0x4,%eax - 1048c9: 0f 84 c9 00 00 00 je 104998 - { - if(isdigit(c)) - { - con->esc3 = con->esc3 * 10 + c - '0'; - return; - } - /** - * ESC[num1;num2;num3m (set attributes num1,num2,num3) - */ - else if(c == 'm') - { - set_attrib(con, con->esc1); - set_attrib(con, con->esc2); - set_attrib(con, con->esc3); - } - con->esc = 0; - return; - } - con->esc = 0; - - /** - * escape character - */ - if(c == 0x1B) - 1048cf: 83 f9 1b cmp $0x1b,%ecx - 1048d2: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) - 1048d9: 0f 84 ad 00 00 00 je 10498c - { - con->esc = 1; - return; - } - /** - * backspace - */ - if(c == 0x08) - 1048df: 83 f9 08 cmp $0x8,%ecx - 1048e2: 0f 84 9a 00 00 00 je 104982 - { - if(con->csr_x != 0) - con->csr_x--; - } - /** - * tab - */ - else if(c == 0x09) - 1048e8: 83 f9 09 cmp $0x9,%ecx - 1048eb: 0f 84 83 00 00 00 je 104974 - con->csr_x = (con->csr_x + 8) & ~(8 - 1); - /** - * carriage return - */ - else if(c == '\r') /* 0x0D */ - 1048f1: 83 f9 0d cmp $0xd,%ecx - 1048f4: 74 75 je 10496b - con->csr_x = 0; - /** - * line feed - */ -/* else if(c == '\n') *//* 0x0A */ -/* con->csr_y++;*/ - /** - * CR/LF - */ - else if(c == '\n') /* ### - 0x0A again */ - 1048f6: 83 f9 0a cmp $0xa,%ecx - 1048f9: 74 62 je 10495d - { - con->csr_x = 0; - con->csr_y++; - } - /** - * printable ASCII - */ - else if(c >= ' ') - 1048fb: 83 f9 1f cmp $0x1f,%ecx - 1048fe: 76 58 jbe 104958 - { - unsigned short *where; - - where = fb_adr + (con->csr_y * _vc_width + con->csr_x); - 104900: a1 30 3a 18 00 mov 0x183a30,%eax - 104905: 8b 53 1c mov 0x1c(%ebx),%edx - 104908: 0f af 43 20 imul 0x20(%ebx),%eax - 10490c: 01 d0 add %edx,%eax - *where = (c | att); - 10490e: 09 f1 or %esi,%ecx - con->csr_x++; - 104910: 42 inc %edx - 104911: 66 89 0c 47 mov %cx,(%edi,%eax,2) - 104915: 89 d0 mov %edx,%eax - 104917: 89 53 1c mov %edx,0x1c(%ebx) - 10491a: 89 f6 mov %esi,%esi - } - if(con->csr_x >= _vc_width) - 10491c: 3b 05 30 3a 18 00 cmp 0x183a30,%eax - 104922: 72 0a jb 10492e - { - con->csr_x = 0; - 104924: c7 43 1c 00 00 00 00 movl $0x0,0x1c(%ebx) - con->csr_y++; - 10492b: ff 43 20 incl 0x20(%ebx) - } - scroll(con); - 10492e: 83 ec 0c sub $0xc,%esp - 104931: 53 push %ebx - 104932: e8 81 fd ff ff call 1046b8 - - /** - * move cursor only if the VC we're writing is the current VC - */ - if(_curr_vc == con) - 104937: 83 c4 10 add $0x10,%esp - 10493a: 39 1d 24 3a 18 00 cmp %ebx,0x183a24 - 104940: 74 0a je 10494c - 104942: 89 f6 mov %esi,%esi - move_csr(); -} - 104944: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 104947: 5b pop %ebx - 104948: 5e pop %esi - 104949: 5f pop %edi - 10494a: c9 leave - 10494b: c3 ret - 10494c: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 10494f: 5b pop %ebx - 104950: 5e pop %esi - 104951: 5f pop %edi - 104952: c9 leave - 104953: e9 40 fe ff ff jmp 104798 - 104958: 8b 43 1c mov 0x1c(%ebx),%eax - 10495b: eb bf jmp 10491c - 10495d: c7 43 1c 00 00 00 00 movl $0x0,0x1c(%ebx) - 104964: ff 43 20 incl 0x20(%ebx) - 104967: 31 c0 xor %eax,%eax - 104969: eb b1 jmp 10491c - 10496b: c7 43 1c 00 00 00 00 movl $0x0,0x1c(%ebx) - 104972: eb f3 jmp 104967 - 104974: 8b 43 1c mov 0x1c(%ebx),%eax - 104977: 83 c0 08 add $0x8,%eax - 10497a: 83 e0 f8 and $0xfffffff8,%eax - 10497d: 89 43 1c mov %eax,0x1c(%ebx) - 104980: eb 9a jmp 10491c - 104982: 8b 43 1c mov 0x1c(%ebx),%eax - 104985: 85 c0 test %eax,%eax - 104987: 74 93 je 10491c - 104989: 48 dec %eax - 10498a: eb f1 jmp 10497d - 10498c: c7 43 14 01 00 00 00 movl $0x1,0x14(%ebx) - 104993: eb af jmp 104944 - 104995: 8d 76 00 lea 0x0(%esi),%esi - 104998: f6 81 41 78 10 00 04 testb $0x4,0x107841(%ecx) - 10499f: 74 0f je 1049b0 - 1049a1: 8b 43 2c mov 0x2c(%ebx),%eax - 1049a4: 8d 04 80 lea (%eax,%eax,4),%eax - 1049a7: 8d 44 41 d0 lea 0xffffffd0(%ecx,%eax,2),%eax - 1049ab: 89 43 2c mov %eax,0x2c(%ebx) - 1049ae: eb 94 jmp 104944 - 1049b0: 83 f9 6d cmp $0x6d,%ecx - 1049b3: 74 0c je 1049c1 - 1049b5: 8d 76 00 lea 0x0(%esi),%esi - 1049b8: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) - 1049bf: eb 83 jmp 104944 - 1049c1: 83 ec 08 sub $0x8,%esp - 1049c4: ff 73 24 pushl 0x24(%ebx) - 1049c7: 53 push %ebx - 1049c8: e8 6f fd ff ff call 10473c - 1049cd: 5f pop %edi - 1049ce: 58 pop %eax - 1049cf: ff 73 28 pushl 0x28(%ebx) - 1049d2: 53 push %ebx - 1049d3: e8 64 fd ff ff call 10473c - 1049d8: 59 pop %ecx - 1049d9: 5e pop %esi - 1049da: ff 73 2c pushl 0x2c(%ebx) - 1049dd: 53 push %ebx - 1049de: e8 59 fd ff ff call 10473c - 1049e3: 83 c4 10 add $0x10,%esp - 1049e6: eb d0 jmp 1049b8 - 1049e8: f6 81 41 78 10 00 04 testb $0x4,0x107841(%ecx) - 1049ef: 74 12 je 104a03 - 1049f1: 8b 43 28 mov 0x28(%ebx),%eax - 1049f4: 8d 04 80 lea (%eax,%eax,4),%eax - 1049f7: 8d 44 41 d0 lea 0xffffffd0(%ecx,%eax,2),%eax - 1049fb: 89 43 28 mov %eax,0x28(%ebx) - 1049fe: e9 41 ff ff ff jmp 104944 - 104a03: 83 f9 3b cmp $0x3b,%ecx - 104a06: 74 42 je 104a4a - 104a08: 83 f9 48 cmp $0x48,%ecx - 104a0b: 74 18 je 104a25 - 104a0d: 83 f9 6d cmp $0x6d,%ecx - 104a10: 75 a6 jne 1049b8 - 104a12: 83 ec 08 sub $0x8,%esp - 104a15: ff 73 24 pushl 0x24(%ebx) - 104a18: 53 push %ebx - 104a19: e8 1e fd ff ff call 10473c - 104a1e: 58 pop %eax - 104a1f: 5a pop %edx - 104a20: ff 73 28 pushl 0x28(%ebx) - 104a23: eb b8 jmp 1049dd - 104a25: 8b 43 28 mov 0x28(%ebx),%eax - 104a28: 3b 05 30 3a 18 00 cmp 0x183a30,%eax - 104a2e: 73 03 jae 104a33 - 104a30: 89 43 1c mov %eax,0x1c(%ebx) - 104a33: 8b 43 24 mov 0x24(%ebx),%eax - 104a36: 3b 05 34 3a 18 00 cmp 0x183a34,%eax - 104a3c: 0f 83 76 ff ff ff jae 1049b8 - 104a42: 89 43 20 mov %eax,0x20(%ebx) - 104a45: e9 6e ff ff ff jmp 1049b8 - 104a4a: c7 43 14 04 00 00 00 movl $0x4,0x14(%ebx) - 104a51: c7 43 2c 00 00 00 00 movl $0x0,0x2c(%ebx) - 104a58: e9 e7 fe ff ff jmp 104944 - 104a5d: 8d 76 00 lea 0x0(%esi),%esi - 104a60: f6 81 41 78 10 00 04 testb $0x4,0x107841(%ecx) - 104a67: 74 13 je 104a7c - 104a69: 8b 43 24 mov 0x24(%ebx),%eax - 104a6c: 8d 04 80 lea (%eax,%eax,4),%eax - 104a6f: 8d 44 41 d0 lea 0xffffffd0(%ecx,%eax,2),%eax - 104a73: 89 43 24 mov %eax,0x24(%ebx) - 104a76: e9 c9 fe ff ff jmp 104944 - 104a7b: 90 nop - 104a7c: 83 f9 3b cmp $0x3b,%ecx - 104a7f: 74 4e je 104acf - 104a81: 83 f9 4a cmp $0x4a,%ecx - 104a84: 74 14 je 104a9a - 104a86: 83 f9 6d cmp $0x6d,%ecx - 104a89: 0f 85 29 ff ff ff jne 1049b8 - 104a8f: 83 ec 08 sub $0x8,%esp - 104a92: ff 73 24 pushl 0x24(%ebx) - 104a95: e9 43 ff ff ff jmp 1049dd - 104a9a: 83 7b 24 02 cmpl $0x2,0x24(%ebx) - 104a9e: 0f 85 14 ff ff ff jne 1049b8 - 104aa4: 51 push %ecx - 104aa5: a1 30 3a 18 00 mov 0x183a30,%eax - 104aaa: 0f af 05 34 3a 18 00 imul 0x183a34,%eax - 104ab1: 50 push %eax - 104ab2: 83 ce 20 or $0x20,%esi - 104ab5: 56 push %esi - 104ab6: 57 push %edi - 104ab7: e8 cc 05 00 00 call 105088 - 104abc: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) - 104ac3: c7 43 1c 00 00 00 00 movl $0x0,0x1c(%ebx) - 104aca: e9 14 ff ff ff jmp 1049e3 - 104acf: c7 43 14 03 00 00 00 movl $0x3,0x14(%ebx) - 104ad6: c7 43 28 00 00 00 00 movl $0x0,0x28(%ebx) - 104add: e9 62 fe ff ff jmp 104944 - 104ae2: 89 f6 mov %esi,%esi - 104ae4: 83 f9 5b cmp $0x5b,%ecx - 104ae7: 0f 85 e2 fd ff ff jne 1048cf - 104aed: c7 43 14 02 00 00 00 movl $0x2,0x14(%ebx) - 104af4: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) - 104afb: e9 44 fe ff ff jmp 104944 - -00104b00 : - -/** - * putch() - * - */ -void putch(unsigned c) -{ - 104b00: 55 push %ebp - 104b01: 89 e5 mov %esp,%ebp - 104b03: 83 ec 10 sub $0x10,%esp -/* all kernel messages to VC #0 */ -// putch_help(_vc + 0, c); -/* all kernel messages to current VC */ - putch_help(_curr_vc, c); - 104b06: ff 75 08 pushl 0x8(%ebp) - 104b09: ff 35 24 3a 18 00 pushl 0x183a24 - 104b0f: e8 7c fd ff ff call 104890 -} - 104b14: c9 leave - 104b15: c3 ret - 104b16: 89 f6 mov %esi,%esi - -00104b18 : - -/** - * init_video() - * - */ -void init_video(void) -{ - 104b18: 55 push %ebp - 104b19: 89 e5 mov %esp,%ebp - 104b1b: 56 push %esi - 104b1c: 53 push %ebx - unsigned i; - - /** - * check for monochrome or color VGA emulation - */ - if((inportb(VGA_MISC_READ) & 0x01) != 0) - 104b1d: 83 ec 0c sub $0xc,%esp - 104b20: 68 cc 03 00 00 push $0x3cc - 104b25: e8 ea 04 00 00 call 105014 - 104b2a: 83 c4 10 add $0x10,%esp - 104b2d: a8 01 test $0x1,%al - 104b2f: 0f 84 78 01 00 00 je 104cad - { - _vga_fb_adr = (unsigned short *)0xB8000L; - 104b35: c7 05 28 3a 18 00 00 movl $0xb8000,0x183a28 - 104b3c: 80 0b 00 - _crtc_io_adr = 0x3D4; - 104b3f: c7 05 2c 3a 18 00 d4 movl $0x3d4,0x183a2c - 104b46: 03 00 00 - } - else - { - _vga_fb_adr = (unsigned short *)0xB0000L; - _crtc_io_adr = 0x3B4; - } - - /** - * read current screen size from BIOS data segment (addresses 400-4FF) - */ - _vc_width = *(unsigned short *)0x44A; - _vc_height = *(unsigned char *)0x484 + 1; - 104b49: 0f b6 05 84 04 00 00 movzbl 0x484,%eax - 104b50: 40 inc %eax - 104b51: 0f b7 15 4a 04 00 00 movzwl 0x44a,%edx - 104b58: 89 15 30 3a 18 00 mov %edx,0x183a30 - - /** - * figure out how many VCs we can have with 32K of display memory. - * Use INTEGER division to round down. - */ - _num_vcs = 32768L / (_vc_width * _vc_height * 2); - 104b5e: 0f af d0 imul %eax,%edx - 104b61: d1 e2 shl %edx - 104b63: 89 d1 mov %edx,%ecx - 104b65: a3 34 3a 18 00 mov %eax,0x183a34 - 104b6a: 31 d2 xor %edx,%edx - 104b6c: b8 00 80 00 00 mov $0x8000,%eax - 104b71: f7 f1 div %ecx - if(_num_vcs > MAX_VC) - 104b73: 83 f8 0c cmp $0xc,%eax - 104b76: a3 20 3a 18 00 mov %eax,0x183a20 - 104b7b: 76 0a jbe 104b87 - _num_vcs = MAX_VC; - 104b7d: c7 05 20 3a 18 00 0c movl $0xc,0x183a20 - 104b84: 00 00 00 - - /** - * init VCs, with a different foreground color for each - */ - for(i = 0; i < _num_vcs; i++) - 104b87: 31 f6 xor %esi,%esi - 104b89: 3b 35 20 3a 18 00 cmp 0x183a20,%esi - 104b8f: 73 53 jae 104be4 - 104b91: bb e0 a2 19 00 mov $0x19a2e0,%ebx - 104b96: 89 f6 mov %esi,%esi - { - _curr_vc = _vc + i; - //_curr_vc->attrib = i + 1; - - /* terminal foreground color */ - _curr_vc->attrib = 7; - _curr_vc->fb_adr = _vga_fb_adr + - 104b98: a1 34 3a 18 00 mov 0x183a34,%eax - 104b9d: 0f af 05 30 3a 18 00 imul 0x183a30,%eax - 104ba4: 8b 15 28 3a 18 00 mov 0x183a28,%edx - 104baa: 0f af c6 imul %esi,%eax - _vc_width * _vc_height * i; - - /** - * ESC[2J clears the screen - */ - //kprintf("\x1B[2J this is VC#%u (of 0-%u)\n", - // i, _num_vcs - 1); - printf("\x1B[2J"); - 104bad: 83 ec 0c sub $0xc,%esp - 104bb0: 8d 04 42 lea (%edx,%eax,2),%eax - 104bb3: c7 43 18 07 00 00 00 movl $0x7,0x18(%ebx) - 104bba: 89 43 30 mov %eax,0x30(%ebx) - 104bbd: 68 00 63 10 00 push $0x106300 - 104bc2: 89 1d 24 3a 18 00 mov %ebx,0x183a24 - 104bc8: e8 07 05 00 00 call 1050d4 - - if(i != 0) - 104bcd: 83 c4 10 add $0x10,%esp - 104bd0: 85 f6 test %esi,%esi - 104bd2: 0f 85 c0 00 00 00 jne 104c98 - 104bd8: 46 inc %esi - 104bd9: 83 c3 34 add $0x34,%ebx - 104bdc: 3b 35 20 3a 18 00 cmp 0x183a20,%esi - 104be2: 72 b4 jb 104b98 - printf("$ "); - } - select_vc(0); - 104be4: 83 ec 0c sub $0xc,%esp - 104be7: 6a 00 push $0x0 - 104be9: e8 16 fc ff ff call 104804 - curr_vtty = 0; - - _curr_vc->attrib = 8; - 104bee: a1 24 3a 18 00 mov 0x183a24,%eax - 104bf3: c7 05 c0 a2 19 00 00 movl $0x0,0x19a2c0 - 104bfa: 00 00 00 - 104bfd: c7 40 18 08 00 00 00 movl $0x8,0x18(%eax) - printf("[ "); - 104c04: c7 04 24 b6 51 10 00 movl $0x1051b6,(%esp,1) - 104c0b: e8 c4 04 00 00 call 1050d4 - _curr_vc->attrib = 15; - 104c10: a1 24 3a 18 00 mov 0x183a24,%eax - 104c15: c7 40 18 0f 00 00 00 movl $0xf,0x18(%eax) - printf("init: video %5s emulation, %2ux%2u, framebuffer at 0x%1X ", - 104c1c: 5b pop %ebx - 104c1d: ff 35 28 3a 18 00 pushl 0x183a28 - 104c23: ff 35 34 3a 18 00 pushl 0x183a34 - 104c29: 81 3d 2c 3a 18 00 d4 cmpl $0x3d4,0x183a2c - 104c30: 03 00 00 - 104c33: ff 35 30 3a 18 00 pushl 0x183a30 - 104c39: 74 54 je 104c8f - 104c3b: b8 05 63 10 00 mov $0x106305,%eax - 104c40: 50 push %eax - 104c41: 68 40 63 10 00 push $0x106340 - 104c46: e8 89 04 00 00 call 1050d4 - (_crtc_io_adr == 0x3D4) ? "color" : "mono", - _vc_width, _vc_height, _vga_fb_adr); - _curr_vc->attrib = 8; - printf("]................"); - 104c4b: 83 c4 14 add $0x14,%esp - 104c4e: a1 24 3a 18 00 mov 0x183a24,%eax - 104c53: c7 40 18 08 00 00 00 movl $0x8,0x18(%eax) - 104c5a: 68 0a 63 10 00 push $0x10630a - 104c5f: e8 70 04 00 00 call 1050d4 - _curr_vc->attrib = 2; - 104c64: a1 24 3a 18 00 mov 0x183a24,%eax - 104c69: c7 40 18 02 00 00 00 movl $0x2,0x18(%eax) - printf("Ok"); - 104c70: c7 04 24 d9 54 10 00 movl $0x1054d9,(%esp,1) - 104c77: e8 58 04 00 00 call 1050d4 - _curr_vc->attrib = 7; - 104c7c: a1 24 3a 18 00 mov 0x183a24,%eax - 104c81: c7 40 18 07 00 00 00 movl $0x7,0x18(%eax) -} - 104c88: 8d 65 f8 lea 0xfffffff8(%ebp),%esp - 104c8b: 5b pop %ebx - 104c8c: 5e pop %esi - 104c8d: c9 leave - 104c8e: c3 ret - 104c8f: b8 1c 63 10 00 mov $0x10631c,%eax - 104c94: eb aa jmp 104c40 - 104c96: 89 f6 mov %esi,%esi - 104c98: 83 ec 0c sub $0xc,%esp - 104c9b: 68 d6 54 10 00 push $0x1054d6 - 104ca0: e8 2f 04 00 00 call 1050d4 - 104ca5: 83 c4 10 add $0x10,%esp - 104ca8: e9 2b ff ff ff jmp 104bd8 - 104cad: c7 05 28 3a 18 00 00 movl $0xb0000,0x183a28 - 104cb4: 00 0b 00 - 104cb7: c7 05 2c 3a 18 00 b4 movl $0x3b4,0x183a2c - 104cbe: 03 00 00 - 104cc1: e9 83 fe ff ff jmp 104b49 - ... - -00104cc8 : -/***************************************************************************** -*****************************************************************************/ -unsigned disable(void) -{ - 104cc8: 55 push %ebp - 104cc9: 89 e5 mov %esp,%ebp - unsigned ret_val; - - __asm__ __volatile__("pushfl\n" - 104ccb: 9c pushf - 104ccc: 58 pop %eax - 104ccd: fa cli - "popl %0\n" - "cli" - : "=a"(ret_val) - :); - return ret_val; -} - 104cce: c9 leave - 104ccf: c3 ret - -00104cd0 : -2^32-1 in base 8 has 11 digits (add 5 for trailing NUL and for slop) */ -#define PR_BUFLEN 16 - -int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr) -{ - 104cd0: 55 push %ebp - 104cd1: 89 e5 mov %esp,%ebp - 104cd3: 57 push %edi - 104cd4: 56 push %esi - 104cd5: 53 push %ebx - 104cd6: 83 ec 2c sub $0x2c,%esp - 104cd9: 8b 75 08 mov 0x8(%ebp),%esi - unsigned state, flags, radix, actual_wd, count, given_wd; - unsigned char *where, buf[PR_BUFLEN]; - long num; - - state = flags = count = given_wd = 0; - 104cdc: c7 45 cc 00 00 00 00 movl $0x0,0xffffffcc(%ebp) - 104ce3: c7 45 d0 00 00 00 00 movl $0x0,0xffffffd0(%ebp) - 104cea: c7 45 d4 00 00 00 00 movl $0x0,0xffffffd4(%ebp) -/* begin scanning format specifier list */ - for(; *fmt; fmt++) - 104cf1: 8a 0e mov (%esi),%cl - 104cf3: 31 db xor %ebx,%ebx - 104cf5: 84 c9 test %cl,%cl - 104cf7: 74 38 je 104d31 - 104cf9: 8d 76 00 lea 0x0(%esi),%esi - { - switch(state) - 104cfc: 83 fb 04 cmp $0x4,%ebx - 104cff: 0f 87 d7 01 00 00 ja 104edc - 104d05: ff 24 9d 7c 63 10 00 jmp *0x10637c(,%ebx,4) - { -/* STATE 0: AWAITING % */ - case 0: - if(*fmt != '%') /* not %... */ - 104d0c: 80 f9 25 cmp $0x25,%cl - 104d0f: 74 2b je 104d3c - { - fn(*fmt, &ptr); /* ...just echo it */ - 104d11: 83 ec 08 sub $0x8,%esp - 104d14: 8d 45 14 lea 0x14(%ebp),%eax - 104d17: 50 push %eax - 104d18: 0f be c1 movsbl %cl,%eax - 104d1b: 50 push %eax - 104d1c: ff 55 10 call *0x10(%ebp) - count++; - 104d1f: ff 45 d0 incl 0xffffffd0(%ebp) - break; - } -/* found %, get next char and advance state to check if next char is a flag */ - state++; - fmt++; - /* FALL THROUGH */ -/* STATE 1: AWAITING FLAGS (%-0) */ - case 1: - if(*fmt == '%') /* %% */ - { - fn(*fmt, &ptr); - count++; - state = flags = given_wd = 0; - break; - 104d22: 83 c4 10 add $0x10,%esp - 104d25: 8d 76 00 lea 0x0(%esi),%esi - 104d28: 46 inc %esi - 104d29: 8a 06 mov (%esi),%al - 104d2b: 84 c0 test %al,%al - 104d2d: 88 c1 mov %al,%cl - 104d2f: 75 cb jne 104cfc - } - if(*fmt == '-') - { - if(flags & PR_LJ)/* %-- is illegal */ - state = flags = given_wd = 0; - else - flags |= PR_LJ; - break; - } -/* not a flag char: advance state to check if it's field width */ - state++; -/* check now for '%0...' */ - if(*fmt == '0') - { - flags |= PR_LZ; - fmt++; - } - /* FALL THROUGH */ -/* STATE 2: AWAITING (NUMERIC) FIELD WIDTH */ - case 2: - if(*fmt >= '0' && *fmt <= '9') - { - given_wd = 10 * given_wd + - (*fmt - '0'); - break; - } -/* not field width: advance state to check if it's a modifier */ - state++; - /* FALL THROUGH */ -/* STATE 3: AWAITING MODIFIER CHARS (FNlh) */ - case 3: - if(*fmt == 'F') - { - flags |= PR_FP; - break; - } - if(*fmt == 'N') - break; - if(*fmt == 'l') - { - flags |= PR_32; - break; - } - if(*fmt == 'h') - { - flags |= PR_16; - break; - } -/* not modifier: advance state to check if it's a conversion char */ - state++; - /* FALL THROUGH */ -/* STATE 4: AWAITING CONVERSION CHARS (Xxpndiuocs) */ - case 4: - where = buf + PR_BUFLEN - 1; - *where = '\0'; - switch(*fmt) - { - case 'X': - flags |= PR_CA; - /* FALL THROUGH */ -/* xxx - far pointers (%Fp, %Fn) not yet supported */ - case 'x': - case 'p': - case 'n': - radix = 16; - goto DO_NUM; - case 'd': - case 'i': - flags |= PR_SG; - /* FALL THROUGH */ - case 'u': - radix = 10; - goto DO_NUM; - case 'o': - radix = 8; -/* load the value to be printed. l=long=32 bits: */ -DO_NUM: if(flags & PR_32) - num = va_arg(args, unsigned long); -/* h=short=16 bits (signed or unsigned) */ - else if(flags & PR_16) - { - if(flags & PR_SG) - num = va_arg(args, short); - else - num = va_arg(args, unsigned short); - } -/* no h nor l: sizeof(int) bits (signed or unsigned) */ - else - { - if(flags & PR_SG) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } -/* take care of sign */ - if(flags & PR_SG) - { - if(num < 0) - { - flags |= PR_WS; - num = -num; - } - } -/* convert binary to octal/decimal/hex ASCII -OK, I found my mistake. The math here is _always_ unsigned */ - do - { - unsigned long temp; - - temp = (unsigned long)num % radix; - where--; - if(temp < 10) - *where = temp + '0'; - else if(flags & PR_CA) - *where = temp - 10 + 'A'; - else - *where = temp - 10 + 'a'; - num = (unsigned long)num / radix; - } - while(num != 0); - goto EMIT; - case 'c': -/* disallow pad-left-with-zeroes for %c */ - flags &= ~PR_LZ; - where--; - *where = (unsigned char)va_arg(args, - unsigned char); - actual_wd = 1; - goto EMIT2; - case 's': -/* disallow pad-left-with-zeroes for %s */ - flags &= ~PR_LZ; - where = va_arg(args, unsigned char *); -EMIT: - actual_wd = strlen(where); - if(flags & PR_WS) - actual_wd++; -/* if we pad left with ZEROES, do the sign now */ - if((flags & (PR_WS | PR_LZ)) == - (PR_WS | PR_LZ)) - { - fn('-', &ptr); - count++; - } -/* pad on left with spaces or zeroes (for right justify) */ -EMIT2: if((flags & PR_LJ) == 0) - { - while(given_wd > actual_wd) - { - fn(flags & PR_LZ ? '0' : - ' ', &ptr); - count++; - given_wd--; - } - } -/* if we pad left with SPACES, do the sign now */ - if((flags & (PR_WS | PR_LZ)) == PR_WS) - { - fn('-', &ptr); - count++; - } -/* emit string/char/converted number */ - while(*where != '\0') - { - fn(*where++, &ptr); - count++; - } -/* pad on right with spaces (for left justify) */ - if(given_wd < actual_wd) - given_wd = 0; - else given_wd -= actual_wd; - for(; given_wd; given_wd--) - { - fn(' ', &ptr); - count++; - } - break; - default: - break; - } - default: - state = flags = given_wd = 0; - break; - } - } - return count; -} - 104d31: 8b 45 d0 mov 0xffffffd0(%ebp),%eax - 104d34: 8d 65 f4 lea 0xfffffff4(%ebp),%esp - 104d37: 5b pop %ebx - 104d38: 5e pop %esi - 104d39: 5f pop %edi - 104d3a: c9 leave - 104d3b: c3 ret - 104d3c: 46 inc %esi - 104d3d: 43 inc %ebx - 104d3e: 8a 0e mov (%esi),%cl - 104d40: 80 f9 25 cmp $0x25,%cl - 104d43: 0f 84 9d 02 00 00 je 104fe6 - 104d49: 80 f9 2d cmp $0x2d,%cl - 104d4c: 0f 84 81 02 00 00 je 104fd3 - 104d52: 43 inc %ebx - 104d53: 80 f9 30 cmp $0x30,%cl - 104d56: 0f 84 6b 02 00 00 je 104fc7 - 104d5c: 8d 41 d0 lea 0xffffffd0(%ecx),%eax - 104d5f: 3c 09 cmp $0x9,%al - 104d61: 77 12 ja 104d75 - 104d63: 8b 45 cc mov 0xffffffcc(%ebp),%eax - 104d66: 8d 14 80 lea (%eax,%eax,4),%edx - 104d69: 0f be c1 movsbl %cl,%eax - 104d6c: 8d 54 50 d0 lea 0xffffffd0(%eax,%edx,2),%edx - 104d70: 89 55 cc mov %edx,0xffffffcc(%ebp) - 104d73: eb b3 jmp 104d28 - 104d75: 43 inc %ebx - 104d76: 80 f9 46 cmp $0x46,%cl - 104d79: 0f 84 3c 02 00 00 je 104fbb - 104d7f: 80 f9 4e cmp $0x4e,%cl - 104d82: 74 a4 je 104d28 - 104d84: 80 f9 6c cmp $0x6c,%cl - 104d87: 0f 84 25 02 00 00 je 104fb2 - 104d8d: 80 f9 68 cmp $0x68,%cl - 104d90: 0f 84 13 02 00 00 je 104fa9 - 104d96: 89 f6 mov %esi,%esi - 104d98: 0f be c1 movsbl %cl,%eax - 104d9b: 83 e8 58 sub $0x58,%eax - 104d9e: 83 f8 20 cmp $0x20,%eax - 104da1: 8d 7d e7 lea 0xffffffe7(%ebp),%edi - 104da4: c6 45 e7 00 movb $0x0,0xffffffe7(%ebp) - 104da8: 0f 87 2e 01 00 00 ja 104edc - 104dae: ff 24 85 90 63 10 00 jmp *0x106390(,%eax,4) - 104db5: 83 4d d4 02 orl $0x2,0xffffffd4(%ebp) - 104db9: bb 10 00 00 00 mov $0x10,%ebx - 104dbe: f6 45 d4 08 testb $0x8,0xffffffd4(%ebp) - 104dc2: 0f 85 8c 01 00 00 jne 104f54 - 104dc8: f6 45 d4 10 testb $0x10,0xffffffd4(%ebp) - 104dcc: 0f 84 6d 01 00 00 je 104f3f - 104dd2: f6 45 d4 04 testb $0x4,0xffffffd4(%ebp) - 104dd6: 0f 84 53 01 00 00 je 104f2f - 104ddc: 83 45 0c 04 addl $0x4,0xc(%ebp) - 104de0: 8b 45 0c mov 0xc(%ebp),%eax - 104de3: 0f bf 48 fc movswl 0xfffffffc(%eax),%ecx - 104de7: f6 45 d4 04 testb $0x4,0xffffffd4(%ebp) - 104deb: 74 08 je 104df5 - 104ded: 85 c9 test %ecx,%ecx - 104def: 0f 88 2f 01 00 00 js 104f24 - 104df5: 8b 45 d4 mov 0xffffffd4(%ebp),%eax - 104df8: 83 e0 02 and $0x2,%eax - 104dfb: 89 45 c8 mov %eax,0xffffffc8(%ebp) - 104dfe: 89 f6 mov %esi,%esi - 104e00: 31 d2 xor %edx,%edx - 104e02: 89 c8 mov %ecx,%eax - 104e04: f7 f3 div %ebx - 104e06: 4f dec %edi - 104e07: 83 fa 09 cmp $0x9,%edx - 104e0a: 8d 42 30 lea 0x30(%edx),%eax - 104e0d: 76 11 jbe 104e20 - 104e0f: 8b 45 c8 mov 0xffffffc8(%ebp),%eax - 104e12: 85 c0 test %eax,%eax - 104e14: 0f 84 02 01 00 00 je 104f1c - 104e1a: 8d 42 37 lea 0x37(%edx),%eax - 104e1d: 8d 76 00 lea 0x0(%esi),%esi - 104e20: 31 d2 xor %edx,%edx - 104e22: 88 07 mov %al,(%edi) - 104e24: 89 c8 mov %ecx,%eax - 104e26: f7 f3 div %ebx - 104e28: 85 c0 test %eax,%eax - 104e2a: 89 c1 mov %eax,%ecx - 104e2c: 75 d2 jne 104e00 - 104e2e: 83 ec 0c sub $0xc,%esp - 104e31: 57 push %edi - 104e32: e8 21 03 00 00 call 105158 - 104e37: 83 c4 10 add $0x10,%esp - 104e3a: f6 45 d4 20 testb $0x20,0xffffffd4(%ebp) - 104e3e: 89 c3 mov %eax,%ebx - 104e40: 74 01 je 104e43 - 104e42: 43 inc %ebx - 104e43: 8b 45 d4 mov 0xffffffd4(%ebp),%eax - 104e46: 83 e0 60 and $0x60,%eax - 104e49: 83 f8 60 cmp $0x60,%eax - 104e4c: 0f 84 b3 00 00 00 je 104f05 - 104e52: f6 45 d4 01 testb $0x1,0xffffffd4(%ebp) - 104e56: 75 31 jne 104e89 - 104e58: 39 5d cc cmp %ebx,0xffffffcc(%ebp) - 104e5b: 76 2c jbe 104e89 - 104e5d: 8d 76 00 lea 0x0(%esi),%esi - 104e60: 83 ec 08 sub $0x8,%esp - 104e63: 8d 45 14 lea 0x14(%ebp),%eax - 104e66: f6 45 d4 40 testb $0x40,0xffffffd4(%ebp) - 104e6a: 50 push %eax - 104e6b: b8 30 00 00 00 mov $0x30,%eax - 104e70: 75 05 jne 104e77 - 104e72: b8 20 00 00 00 mov $0x20,%eax - 104e77: 50 push %eax - 104e78: ff 55 10 call *0x10(%ebp) - 104e7b: ff 4d cc decl 0xffffffcc(%ebp) - 104e7e: ff 45 d0 incl 0xffffffd0(%ebp) - 104e81: 83 c4 10 add $0x10,%esp - 104e84: 39 5d cc cmp %ebx,0xffffffcc(%ebp) - 104e87: 77 d7 ja 104e60 - 104e89: 83 65 d4 60 andl $0x60,0xffffffd4(%ebp) - 104e8d: 83 7d d4 20 cmpl $0x20,0xffffffd4(%ebp) - 104e91: 74 5e je 104ef1 - 104e93: 8a 07 mov (%edi),%al - 104e95: 84 c0 test %al,%al - 104e97: 74 1e je 104eb7 - 104e99: 8d 76 00 lea 0x0(%esi),%esi - 104e9c: 83 ec 08 sub $0x8,%esp - 104e9f: 8d 55 14 lea 0x14(%ebp),%edx - 104ea2: 52 push %edx - 104ea3: 0f b6 c0 movzbl %al,%eax - 104ea6: 50 push %eax - 104ea7: ff 55 10 call *0x10(%ebp) - 104eaa: 47 inc %edi - 104eab: ff 45 d0 incl 0xffffffd0(%ebp) - 104eae: 8a 07 mov (%edi),%al - 104eb0: 83 c4 10 add $0x10,%esp - 104eb3: 84 c0 test %al,%al - 104eb5: 75 e5 jne 104e9c - 104eb7: 39 5d cc cmp %ebx,0xffffffcc(%ebp) - 104eba: 72 20 jb 104edc - 104ebc: 29 5d cc sub %ebx,0xffffffcc(%ebp) - 104ebf: 74 1b je 104edc - 104ec1: 8d 76 00 lea 0x0(%esi),%esi - 104ec4: 83 ec 08 sub $0x8,%esp - 104ec7: 8d 45 14 lea 0x14(%ebp),%eax - 104eca: 50 push %eax - 104ecb: 6a 20 push $0x20 - 104ecd: ff 55 10 call *0x10(%ebp) - 104ed0: ff 45 d0 incl 0xffffffd0(%ebp) - 104ed3: 83 c4 10 add $0x10,%esp - 104ed6: ff 4d cc decl 0xffffffcc(%ebp) - 104ed9: 75 e9 jne 104ec4 - 104edb: 90 nop - 104edc: c7 45 cc 00 00 00 00 movl $0x0,0xffffffcc(%ebp) - 104ee3: c7 45 d4 00 00 00 00 movl $0x0,0xffffffd4(%ebp) - 104eea: 31 db xor %ebx,%ebx - 104eec: e9 37 fe ff ff jmp 104d28 - 104ef1: 83 ec 08 sub $0x8,%esp - 104ef4: 8d 55 14 lea 0x14(%ebp),%edx - 104ef7: 52 push %edx - 104ef8: 6a 2d push $0x2d - 104efa: ff 55 10 call *0x10(%ebp) - 104efd: ff 45 d0 incl 0xffffffd0(%ebp) - 104f00: 83 c4 10 add $0x10,%esp - 104f03: eb 8e jmp 104e93 - 104f05: 83 ec 08 sub $0x8,%esp - 104f08: 8d 55 14 lea 0x14(%ebp),%edx - 104f0b: 52 push %edx - 104f0c: 6a 2d push $0x2d - 104f0e: ff 55 10 call *0x10(%ebp) - 104f11: ff 45 d0 incl 0xffffffd0(%ebp) - 104f14: 83 c4 10 add $0x10,%esp - 104f17: e9 36 ff ff ff jmp 104e52 - 104f1c: 8d 42 57 lea 0x57(%edx),%eax - 104f1f: e9 fc fe ff ff jmp 104e20 - 104f24: 83 4d d4 20 orl $0x20,0xffffffd4(%ebp) - 104f28: f7 d9 neg %ecx - 104f2a: e9 c6 fe ff ff jmp 104df5 - 104f2f: 83 45 0c 04 addl $0x4,0xc(%ebp) - 104f33: 8b 55 0c mov 0xc(%ebp),%edx - 104f36: 0f b7 4a fc movzwl 0xfffffffc(%edx),%ecx - 104f3a: e9 a8 fe ff ff jmp 104de7 - 104f3f: f6 45 d4 04 testb $0x4,0xffffffd4(%ebp) - 104f43: 74 0f je 104f54 - 104f45: 83 45 0c 04 addl $0x4,0xc(%ebp) - 104f49: 8b 45 0c mov 0xc(%ebp),%eax - 104f4c: 8b 48 fc mov 0xfffffffc(%eax),%ecx - 104f4f: e9 93 fe ff ff jmp 104de7 - 104f54: 83 45 0c 04 addl $0x4,0xc(%ebp) - 104f58: 8b 55 0c mov 0xc(%ebp),%edx - 104f5b: 8b 4a fc mov 0xfffffffc(%edx),%ecx - 104f5e: e9 84 fe ff ff jmp 104de7 - 104f63: 83 45 0c 04 addl $0x4,0xc(%ebp) - 104f67: 83 65 d4 bf andl $0xffffffbf,0xffffffd4(%ebp) - 104f6b: 8b 55 0c mov 0xc(%ebp),%edx - 104f6e: 4f dec %edi - 104f6f: 8a 42 fc mov 0xfffffffc(%edx),%al - 104f72: bb 01 00 00 00 mov $0x1,%ebx - 104f77: 88 07 mov %al,(%edi) - 104f79: e9 d4 fe ff ff jmp 104e52 - 104f7e: 83 4d d4 04 orl $0x4,0xffffffd4(%ebp) - 104f82: bb 0a 00 00 00 mov $0xa,%ebx - 104f87: e9 32 fe ff ff jmp 104dbe - 104f8c: bb 08 00 00 00 mov $0x8,%ebx - 104f91: e9 28 fe ff ff jmp 104dbe - 104f96: 83 45 0c 04 addl $0x4,0xc(%ebp) - 104f9a: 8b 45 0c mov 0xc(%ebp),%eax - 104f9d: 83 65 d4 bf andl $0xffffffbf,0xffffffd4(%ebp) - 104fa1: 8b 78 fc mov 0xfffffffc(%eax),%edi - 104fa4: e9 85 fe ff ff jmp 104e2e - 104fa9: 83 4d d4 10 orl $0x10,0xffffffd4(%ebp) - 104fad: e9 76 fd ff ff jmp 104d28 - 104fb2: 83 4d d4 08 orl $0x8,0xffffffd4(%ebp) - 104fb6: e9 6d fd ff ff jmp 104d28 - 104fbb: 81 4d d4 80 00 00 00 orl $0x80,0xffffffd4(%ebp) - 104fc2: e9 61 fd ff ff jmp 104d28 - 104fc7: 83 4d d4 40 orl $0x40,0xffffffd4(%ebp) - 104fcb: 46 inc %esi - 104fcc: 8a 0e mov (%esi),%cl - 104fce: e9 89 fd ff ff jmp 104d5c - 104fd3: f6 45 d4 01 testb $0x1,0xffffffd4(%ebp) - 104fd7: 0f 85 ff fe ff ff jne 104edc - 104fdd: 83 4d d4 01 orl $0x1,0xffffffd4(%ebp) - 104fe1: e9 42 fd ff ff jmp 104d28 - 104fe6: 83 ec 08 sub $0x8,%esp - 104fe9: 8d 55 14 lea 0x14(%ebp),%edx - 104fec: 52 push %edx - 104fed: 6a 25 push $0x25 - 104fef: ff 55 10 call *0x10(%ebp) - 104ff2: 31 db xor %ebx,%ebx - 104ff4: ff 45 d0 incl 0xffffffd0(%ebp) - 104ff7: c7 45 cc 00 00 00 00 movl $0x0,0xffffffcc(%ebp) - 104ffe: c7 45 d4 00 00 00 00 movl $0x0,0xffffffd4(%ebp) - 105005: e9 18 fd ff ff jmp 104d22 - ... - -0010500c : -/***************************************************************************** -*****************************************************************************/ -void enable(void) -{ - 10500c: 55 push %ebp - 10500d: 89 e5 mov %esp,%ebp - __asm__ __volatile__("sti" - 10500f: fb sti - : - : - ); -} - 105010: c9 leave - 105011: c3 ret - ... - -00105014 : -/***************************************************************************** -*****************************************************************************/ -unsigned inportb(unsigned short port) -{ - 105014: 55 push %ebp - 105015: 89 e5 mov %esp,%ebp - 105017: 8b 55 08 mov 0x8(%ebp),%edx - unsigned char ret_val; - - __asm__ __volatile__("inb %1,%0" - 10501a: ec in (%dx),%al - : "=a"(ret_val) - : "d"(port)); - return ret_val; - 10501b: 0f b6 c0 movzbl %al,%eax -} - 10501e: c9 leave - 10501f: c3 ret - -00105020 : -4. Save/restore the floating-point state when entering/leaving - the kernel (protected OS only) -*****************************************************************************/ -void longjmp(jmp_buf buf, int ret_val) -{ - 105020: 55 push %ebp - 105021: 89 e5 mov %esp,%ebp - 105023: 8b 45 0c mov 0xc(%ebp),%eax - unsigned *esp; - -/* make sure return value is not 0 */ - if(ret_val == 0) - 105026: 85 c0 test %eax,%eax - 105028: 75 05 jne 10502f - ret_val++; - 10502a: b8 01 00 00 00 mov $0x1,%eax -/* EAX is used for return values, so store it in jmp_buf.EAX */ - buf->eax = ret_val; - 10502f: 8b 4d 08 mov 0x8(%ebp),%ecx - 105032: 89 41 1c mov %eax,0x1c(%ecx) -/* get ESP for new stack */ - esp = (unsigned *)buf->esp; -/* push EFLAGS on the new stack */ - esp--; - 105035: 8b 41 0c mov 0xc(%ecx),%eax - 105038: 83 e8 04 sub $0x4,%eax - *esp = buf->eflags; - 10503b: 8b 51 24 mov 0x24(%ecx),%edx - 10503e: 89 10 mov %edx,(%eax) -/* push current CS on the new stack */ - esp--; - 105040: 83 e8 04 sub $0x4,%eax - __asm__ __volatile__( - 105043: 8c 08 movl %cs,(%eax) - "mov %%cs,%0\n" - : "=m"(*esp)); -/* push EIP on the new stack */ - esp--; - 105045: 83 e8 04 sub $0x4,%eax - *esp = buf->eip; - 105048: 8b 51 20 mov 0x20(%ecx),%edx - 10504b: 89 10 mov %edx,(%eax) -/* new ESP is 12 bytes lower; update jmp_buf.ESP */ - buf->esp = (unsigned)esp; - 10504d: 89 41 0c mov %eax,0xc(%ecx) -/* now, briefly, make the jmp_buf struct our stack */ - __asm__ __volatile__( - 105050: 8b 65 08 mov 0x8(%ebp),%esp - 105053: 61 popa - 105054: 8b 64 24 ec mov 0xffffffec(%esp,1),%esp - 105058: cf iret - "movl %0,%%esp\n" -/* ESP now points to 8 general-purpose registers stored in jmp_buf -Pop them */ - "popa\n" -/* load new stack pointer from jmp_buf */ - "movl -20(%%esp),%%esp\n" -/* ESP now points to new stack, with the IRET frame (EIP, CS, EFLAGS) -we created just above. Pop these registers: */ - "iret\n" - : - : "m"(buf)); -} - 105059: c9 leave - 10505a: c3 ret - ... - -0010505c : -void *memcpy(void *s, const void *t, unsigned n) -{ - 10505c: 55 push %ebp - 10505d: 89 e5 mov %esp,%ebp - void *ret = s; - - while(n--) - 10505f: 8b 55 10 mov 0x10(%ebp),%edx - 105062: 56 push %esi - 105063: 4a dec %edx - 105064: 53 push %ebx - 105065: 83 fa ff cmp $0xffffffff,%edx - 105068: 8b 5d 08 mov 0x8(%ebp),%ebx - 10506b: 8b 4d 0c mov 0xc(%ebp),%ecx - 10506e: 89 de mov %ebx,%esi - 105070: 74 0e je 105080 - 105072: 89 f6 mov %esi,%esi - { - *(char *)s = *(char *)t; - 105074: 8a 01 mov (%ecx),%al - s = (char *)s + 1; - t = (char *)t + 1; - 105076: 4a dec %edx - 105077: 88 03 mov %al,(%ebx) - 105079: 41 inc %ecx - 10507a: 43 inc %ebx - 10507b: 83 fa ff cmp $0xffffffff,%edx - 10507e: 75 f4 jne 105074 - } - - return ret; -} - 105080: 5b pop %ebx - 105081: 89 f0 mov %esi,%eax - 105083: 5e pop %esi - 105084: c9 leave - 105085: c3 ret - ... - -00105088 : - -void *memsetw(void *s, short i, unsigned n) -{ - 105088: 55 push %ebp - 105089: 89 e5 mov %esp,%ebp - void *start = s; - - while(n--) - 10508b: 8b 55 10 mov 0x10(%ebp),%edx - 10508e: 4a dec %edx - 10508f: 8b 4d 08 mov 0x8(%ebp),%ecx - 105092: 83 fa ff cmp $0xffffffff,%edx - 105095: 53 push %ebx - 105096: 8b 45 0c mov 0xc(%ebp),%eax - 105099: 89 cb mov %ecx,%ebx - 10509b: 74 0f je 1050ac - 10509d: 8d 76 00 lea 0x0(%esi),%esi - { - *(short *)s = (short)i; - s = (short *)s + 1; - 1050a0: 4a dec %edx - 1050a1: 66 89 01 mov %ax,(%ecx) - 1050a4: 83 c1 02 add $0x2,%ecx - 1050a7: 83 fa ff cmp $0xffffffff,%edx - 1050aa: 75 f4 jne 1050a0 - } - - return(start); -} - 1050ac: 89 d8 mov %ebx,%eax - 1050ae: 5b pop %ebx - 1050af: c9 leave - 1050b0: c3 ret - 1050b1: 00 00 add %al,(%eax) - ... - -001050b4 : -/***************************************************************************** -*****************************************************************************/ -void outportb(unsigned port, unsigned val) -{ - 1050b4: 55 push %ebp - 1050b5: 89 e5 mov %esp,%ebp - 1050b7: 8b 55 08 mov 0x8(%ebp),%edx - 1050ba: 8b 45 0c mov 0xc(%ebp),%eax - __asm__ __volatile__("outb %b0,%w1" - 1050bd: ee out %al,(%dx) - : - : "a"(val), "d"(port)); -} - 1050be: c9 leave - 1050bf: c3 ret - -001050c0 : -int do_printf(const char *fmt, va_list args, fnptr_t fn, void *ptr); -void putch(unsigned c); - -int printf_help(unsigned c, void **ptr) -{ - 1050c0: 55 push %ebp - 1050c1: 89 e5 mov %esp,%ebp - 1050c3: 83 ec 14 sub $0x14,%esp - /** - * Leave this for now - */ - ptr = ptr; - - putch(c); - 1050c6: ff 75 08 pushl 0x8(%ebp) - 1050c9: e8 32 fa ff ff call 104b00 - return 0; -} - 1050ce: 31 c0 xor %eax,%eax - 1050d0: c9 leave - 1050d1: c3 ret - 1050d2: 89 f6 mov %esi,%esi - -001050d4 : - -void printf(const char *fmt, ...) -{ - 1050d4: 55 push %ebp - 1050d5: 89 e5 mov %esp,%ebp - 1050d7: 83 ec 08 sub $0x8,%esp - va_list args; - - va_start(args, fmt); - (void)do_printf(fmt, args, printf_help, NULL); - 1050da: 6a 00 push $0x0 - 1050dc: 68 c0 50 10 00 push $0x1050c0 - 1050e1: 8d 45 0c lea 0xc(%ebp),%eax - 1050e4: 50 push %eax - 1050e5: ff 75 08 pushl 0x8(%ebp) - 1050e8: e8 e3 fb ff ff call 104cd0 - va_end(args); -} - 1050ed: c9 leave - 1050ee: c3 ret - ... - -001050f0 : -int strcmp(const char * src, const char * dst) -{ - 1050f0: 55 push %ebp - 1050f1: 89 e5 mov %esp,%ebp - 1050f3: 56 push %esi - 1050f4: 53 push %ebx - 1050f5: 8b 5d 0c mov 0xc(%ebp),%ebx - 1050f8: 8b 75 08 mov 0x8(%ebp),%esi - int ret = 0 ; - - while(!(ret = *(unsigned char *)src - *(unsigned char *)dst) && *dst) - 1050fb: 8a 0b mov (%ebx),%cl - 1050fd: 0f b6 c1 movzbl %cl,%eax - 105100: 0f b6 16 movzbl (%esi),%edx - 105103: 29 c2 sub %eax,%edx - 105105: 89 d0 mov %edx,%eax - 105107: 75 1b jne 105124 - 105109: 84 c9 test %cl,%cl - 10510b: 74 17 je 105124 - 10510d: 8d 76 00 lea 0x0(%esi),%esi - ++src, ++dst; - 105110: 43 inc %ebx - 105111: 46 inc %esi - 105112: 8a 0b mov (%ebx),%cl - 105114: 0f b6 c1 movzbl %cl,%eax - 105117: 0f b6 16 movzbl (%esi),%edx - 10511a: 29 c2 sub %eax,%edx - 10511c: 89 d0 mov %edx,%eax - 10511e: 75 04 jne 105124 - 105120: 84 c9 test %cl,%cl - 105122: 75 ec jne 105110 - - if(ret < 0) - 105124: 85 c0 test %eax,%eax - 105126: 78 0d js 105135 - ret = -1 ; - else if(ret > 0) - 105128: 85 c0 test %eax,%eax - 10512a: 7e 05 jle 105131 - ret = 1 ; - 10512c: b8 01 00 00 00 mov $0x1,%eax - - return(ret); -} - 105131: 5b pop %ebx - 105132: 5e pop %esi - 105133: c9 leave - 105134: c3 ret - 105135: b8 ff ff ff ff mov $0xffffffff,%eax - 10513a: eb f5 jmp 105131 - -0010513c : - -char *strcpy(char *s, const char *t) -{ - 10513c: 55 push %ebp - 10513d: 89 e5 mov %esp,%ebp - 10513f: 8b 4d 08 mov 0x8(%ebp),%ecx - 105142: 8b 55 0c mov 0xc(%ebp),%edx - 105145: 8d 76 00 lea 0x0(%esi),%esi - while((*(s++) = *(t++))); - 105148: 8a 02 mov (%edx),%al - 10514a: 88 01 mov %al,(%ecx) - 10514c: 42 inc %edx - 10514d: 41 inc %ecx - 10514e: 84 c0 test %al,%al - 105150: 75 f6 jne 105148 - - return s; -} - 105152: 89 c8 mov %ecx,%eax - 105154: c9 leave - 105155: c3 ret - ... - -00105158 : -#include /* size_t */ -/***************************************************************************** -*****************************************************************************/ -size_t strlen(const char *str) -{ - 105158: 55 push %ebp - 105159: 89 e5 mov %esp,%ebp - 10515b: 8b 55 08 mov 0x8(%ebp),%edx - size_t ret_val; - - for(ret_val = 0; *str != '\0'; str++) - 10515e: 31 c0 xor %eax,%eax - 105160: 80 3a 00 cmpb $0x0,(%edx) - 105163: 74 0a je 10516f - 105165: 8d 76 00 lea 0x0(%esi),%esi - 105168: 42 inc %edx - ret_val++; - 105169: 40 inc %eax - 10516a: 80 3a 00 cmpb $0x0,(%edx) - 10516d: 75 f9 jne 105168 - return ret_val; -} - 10516f: c9 leave - 105170: c3 ret - 105171: 00 00 add %al,(%eax) - ... - -00105174 : -#include /* size_t */ - -char *strncpy(char * dest, const char * source, size_t count) -{ - 105174: 55 push %ebp - 105175: 89 e5 mov %esp,%ebp - 105177: 8b 55 10 mov 0x10(%ebp),%edx - 10517a: 56 push %esi - char *start = dest; - - while(count && (*dest++ = *source++)) /* copy string */ - 10517b: 85 d2 test %edx,%edx - 10517d: 53 push %ebx - 10517e: 8b 75 08 mov 0x8(%ebp),%esi - 105181: 8b 5d 0c mov 0xc(%ebp),%ebx - 105184: 74 2a je 1051b0 - 105186: 8a 03 mov (%ebx),%al - 105188: 43 inc %ebx - 105189: 84 c0 test %al,%al - 10518b: 88 06 mov %al,(%esi) - 10518d: 8d 4e 01 lea 0x1(%esi),%ecx - 105190: 74 0f je 1051a1 - 105192: 89 f6 mov %esi,%esi - count--; - 105194: 4a dec %edx - 105195: 74 19 je 1051b0 - 105197: 8a 03 mov (%ebx),%al - 105199: 88 01 mov %al,(%ecx) - 10519b: 43 inc %ebx - 10519c: 41 inc %ecx - 10519d: 84 c0 test %al,%al - 10519f: 75 f3 jne 105194 - - if(count) /* pad out with zeroes */ - 1051a1: 85 d2 test %edx,%edx - 1051a3: 74 0b je 1051b0 - while(--count) - 1051a5: 4a dec %edx - 1051a6: 74 08 je 1051b0 - *dest++ = '\0'; - 1051a8: c6 01 00 movb $0x0,(%ecx) - 1051ab: 41 inc %ecx - 1051ac: 4a dec %edx - 1051ad: 75 f9 jne 1051a8 - 1051af: 90 nop - - return(start); -} - 1051b0: 5b pop %ebx - 1051b1: 89 f0 mov %esi,%eax - 1051b3: 5e pop %esi - 1051b4: c9 leave - 1051b5: c3 ret - 1051b6: 5b pop %ebx - 1051b7: 20 00 and %al,(%eax) - 1051b9: 25 73 3a 20 25 and $0x25203a73,%eax - 1051be: 73 00 jae 1051c0 - 1051c0: 20 5d 00 and %bl,0x0(%ebp) - 1051c3: 57 push %edi - 1051c4: 61 popa - 1051c5: 69 74 00 08 08 08 08 imul $0x46080808,0x8(%eax,%eax,1),%esi - 1051cc: 46 - 1051cd: 61 popa - 1051ce: 69 6c 0a 00 08 08 08 imul $0x8080808,0x0(%edx,%ecx,1),%ebp - 1051d5: 08 - 1051d6: 2e 2e 00 4f 6b add %cl,%cs:0x6b(%edi) - 1051db: 0a 00 or (%eax),%al - 1051dd: 25 30 32 58 20 and $0x20583230,%eax - 1051e2: 00 09 add %cl,(%ecx) - 1051e4: 00 25 63 00 75 53 add %ah,0x53750063 - 1051ea: 50 push %eax - 1051eb: 3d 25 30 38 58 cmp $0x58383025,%eax - 1051f0: 20 75 53 and %dh,0x53(%ebp) - 1051f3: 53 push %ebx - 1051f4: 3d 25 30 38 58 cmp $0x58383025,%eax - 1051f9: 0a 00 or (%eax),%al - 1051fb: 00 00 add %al,(%eax) - 1051fd: 00 00 add %al,(%eax) - 1051ff: 00 45 44 add %al,0x44(%ebp) - 105202: 49 dec %ecx - 105203: 3d 25 30 38 58 cmp $0x58383025,%eax - 105208: 20 45 53 and %al,0x53(%ebp) - 10520b: 49 dec %ecx - 10520c: 3d 25 30 38 58 cmp $0x58383025,%eax - 105211: 20 45 42 and %al,0x42(%ebp) - 105214: 50 push %eax - 105215: 3d 25 30 38 58 cmp $0x58383025,%eax - 10521a: 20 45 53 and %al,0x53(%ebp) - 10521d: 50 push %eax - 10521e: 3d 25 30 38 58 cmp $0x58383025,%eax - 105223: 0a 00 or (%eax),%al - ... - 10523d: 00 00 add %al,(%eax) - 10523f: 00 45 42 add %al,0x42(%ebp) - 105242: 58 pop %eax - 105243: 3d 25 30 38 58 cmp $0x58383025,%eax - 105248: 20 45 44 and %al,0x44(%ebp) - 10524b: 58 pop %eax - 10524c: 3d 25 30 38 58 cmp $0x58383025,%eax - 105251: 20 45 43 and %al,0x43(%ebp) - 105254: 58 pop %eax - 105255: 3d 25 30 38 58 cmp $0x58383025,%eax - 10525a: 20 45 41 and %al,0x41(%ebp) - 10525d: 58 pop %eax - 10525e: 3d 25 30 38 58 cmp $0x58383025,%eax - 105263: 0a 00 or (%eax),%al - ... - 10527d: 00 00 add %al,(%eax) - 10527f: 00 20 add %ah,(%eax) - 105281: 44 inc %esp - 105282: 53 push %ebx - 105283: 3d 25 30 38 58 cmp $0x58383025,%eax - 105288: 20 20 and %ah,(%eax) - 10528a: 45 inc %ebp - 10528b: 53 push %ebx - 10528c: 3d 25 30 38 58 cmp $0x58383025,%eax - 105291: 20 20 and %ah,(%eax) - 105293: 46 inc %esi - 105294: 53 push %ebx - 105295: 3d 25 30 38 58 cmp $0x58383025,%eax - 10529a: 20 20 and %ah,(%eax) - 10529c: 47 inc %edi - 10529d: 53 push %ebx - 10529e: 3d 25 30 38 58 cmp $0x58383025,%eax - 1052a3: 0a 00 or (%eax),%al - ... - 1052bd: 00 00 add %al,(%eax) - 1052bf: 00 69 6e add %ch,0x6e(%ecx) - 1052c2: 74 3d je 105301 - 1052c4: 25 30 38 58 20 and $0x20583830,%eax - 1052c9: 65 gs - 1052ca: 72 72 jb 10533e - 1052cc: 3d 25 30 38 58 cmp $0x58383025,%eax - 1052d1: 20 45 49 and %al,0x49(%ebp) - 1052d4: 50 push %eax - 1052d5: 3d 25 30 38 58 cmp $0x58383025,%eax - 1052da: 20 20 and %ah,(%eax) - 1052dc: 43 inc %ebx - 1052dd: 53 push %ebx - 1052de: 3d 25 30 38 58 cmp $0x58383025,%eax - 1052e3: 0a 00 or (%eax),%al - ... - 1052fd: 00 00 add %al,(%eax) - 1052ff: 00 64 75 6d add %ah,0x6d(%ebp,%esi,2) - 105303: 70 68 jo 10536d - 105305: 65 gs - 105306: 61 popa - 105307: 70 00 jo 105309 - 105309: 00 2d 68 00 00 00 add %ch,0x68 - ... - 10531f: 00 50 72 add %dl,0x72(%eax) - 105322: 69 6e 74 20 6c 69 73 imul $0x73696c20,0x74(%esi),%ebp - 105329: 74 69 je 105394 - 10532b: 6e outsb %ds:(%esi),(%dx) - 10532c: 67 20 6f 66 addr16 and %ch,102(%bx) - 105330: 20 68 65 and %ch,0x65(%eax) - 105333: 61 popa - 105334: 70 20 jo 105356 - 105336: 75 73 jne 1053ab - 105338: 61 popa - 105339: 67 65 20 61 6e addr16 and %ah,%gs:110(%bx,%di) - 10533e: 64 20 73 74 and %dh,%fs:0x74(%ebx) - 105342: 61 popa - 105343: 74 75 je 1053ba - 105345: 73 2e jae 105375 - 105347: 00 00 add %al,(%eax) - 105349: 65 63 68 6f arpl %bp,%gs:0x6f(%eax) - ... - 10535d: 00 00 add %al,(%eax) - 10535f: 00 45 63 add %al,0x63(%ebp) - 105362: 68 6f 20 61 20 push $0x2061206f - 105367: 6c insb (%dx),%es:(%edi) - 105368: 69 6e 65 20 6f 66 20 imul $0x20666f20,0x65(%esi),%ebp - 10536f: 74 65 je 1053d6 - 105371: 78 74 js 1053e7 - 105373: 20 74 6f 20 and %dh,0x20(%edi,%ebp,2) - 105377: 74 68 je 1053e1 - 105379: 65 20 74 65 72 and %dh,%gs:0x72(%ebp,2) - 10537e: 6d insl (%dx),%es:(%edi) - 10537f: 69 6e 61 6c 2e 00 00 imul $0x2e6c,0x61(%esi),%ebp - 105386: 68 65 6c 70 00 push $0x706c65 - ... - 10539f: 00 44 69 73 add %al,0x73(%ecx,%ebp,2) - 1053a3: 70 6c jo 105411 - 1053a5: 61 popa - 1053a6: 79 73 jns 10541b - 1053a8: 20 67 65 and %ah,0x65(%edi) - 1053ab: 6e outsb %ds:(%esi),(%dx) - 1053ac: 65 gs - 1053ad: 72 61 jb 105410 - 1053af: 6c insb (%dx),%es:(%edi) - 1053b0: 20 68 65 and %ch,0x65(%eax) - 1053b3: 6c insb (%dx),%es:(%edi) - 1053b4: 70 20 jo 1053d6 - 1053b6: 6d insl (%dx),%es:(%edi) - 1053b7: 65 6e outsb %gs:(%esi),(%dx) - 1053b9: 75 20 jne 1053db - 1053bb: 6f outsl %ds:(%esi),(%dx) - 1053bc: 72 20 jb 1053de - 1053be: 68 65 6c 70 20 push $0x20706c65 - 1053c3: 6f outsl %ds:(%esi),(%dx) - 1053c4: 6e outsb %ds:(%esi),(%dx) - 1053c5: 20 73 70 and %dh,0x70(%ebx) - 1053c8: 65 63 69 66 arpl %bp,%gs:0x66(%ecx) - 1053cc: 69 63 20 63 6f 6d 6d imul $0x6d6d6f63,0x20(%ebx),%esp - 1053d3: 61 popa - 1053d4: 6e outsb %ds:(%esi),(%dx) - 1053d5: 64 2e 00 00 add %al,%cs:%fs:(%eax) - 1053d9: 73 68 jae 105443 - 1053db: 75 74 jne 105451 - 1053dd: 64 6f outsl %fs:(%esi),(%dx) - 1053df: 77 6e ja 10544f - 1053e1: 00 00 add %al,(%eax) - 1053e3: 2d 72 00 00 4e sub $0x4e000072,%eax - 1053e8: 4f dec %edi - 1053e9: 57 push %edi - 1053ea: 00 00 add %al,(%eax) - 1053ec: 48 dec %eax - 1053ed: 61 popa - 1053ee: 6c insb (%dx),%es:(%edi) - 1053ef: 74 20 je 105411 - 1053f1: 6f outsl %ds:(%esi),(%dx) - 1053f2: 72 20 jb 105414 - 1053f4: 72 65 jb 10545b - 1053f6: 73 74 jae 10546c - 1053f8: 61 popa - 1053f9: 72 74 jb 10546f - 1053fb: 20 74 68 65 and %dh,0x65(%eax,%ebp,2) - 1053ff: 20 73 79 and %dh,0x79(%ebx) - 105402: 73 74 jae 105478 - 105404: 65 gs - 105405: 6d insl (%dx),%es:(%edi) - 105406: 2e 00 00 add %al,%cs:(%eax) - 105409: 63 6c 73 00 arpl %bp,0x0(%ebx,%esi,2) - ... - 10541d: 00 00 add %al,(%eax) - 10541f: 00 43 6c add %al,0x6c(%ebx) - 105422: 65 gs - 105423: 61 popa - 105424: 72 73 jb 105499 - 105426: 20 74 68 65 and %dh,0x65(%eax,%ebp,2) - 10542a: 20 74 65 72 and %dh,0x72(%ebp,2) - 10542e: 6d insl (%dx),%es:(%edi) - 10542f: 69 6e 61 6c 20 6f 66 imul $0x666f206c,0x61(%esi),%ebp - 105436: 20 61 6c and %ah,0x6c(%ecx) - 105439: 6c insb (%dx),%es:(%edi) - 10543a: 20 6f 75 and %ch,0x75(%edi) - 10543d: 74 70 je 1054af - 10543f: 75 74 jne 1054b5 - 105441: 2e 00 00 add %al,%cs:(%eax) - 105444: 70 77 jo 1054bd - 105446: 64 00 00 add %al,%fs:(%eax) - ... - 10545d: 00 00 add %al,(%eax) - 10545f: 00 50 72 add %dl,0x72(%eax) - 105462: 69 6e 74 73 20 74 68 imul $0x68742073,0x74(%esi),%ebp - 105469: 65 20 63 75 and %ah,%gs:0x75(%ebx) - 10546d: 72 72 jb 1054e1 - 10546f: 65 6e outsb %gs:(%esi),(%dx) - 105471: 74 20 je 105493 - 105473: 77 6f ja 1054e4 - 105475: 72 6b jb 1054e2 - 105477: 69 6e 67 20 64 69 72 imul $0x72696420,0x67(%esi),%ebp - 10547e: 65 63 74 6f 72 arpl %si,%gs:0x72(%edi,%ebp,2) - 105483: 79 2e jns 1054b3 - 105485: 00 00 add %al,(%eax) - 105487: 68 65 6c 70 00 push $0x706c65 - 10548c: 65 gs - 10548d: 73 68 jae 1054f7 - 10548f: 3a 20 cmp (%eax),%ah - 105491: 27 daa - 105492: 25 73 27 20 6e and $0x6e202773,%eax - 105497: 6f outsl %ds:(%esi),(%dx) - 105498: 74 20 je 1054ba - 10549a: 66 6f outsw %ds:(%esi),(%dx) - 10549c: 75 6e jne 10550c - 10549e: 64 2e 0a 00 or %cs:%fs:(%eax),%al - 1054a2: 55 push %ebp - 1054a3: 73 61 jae 105506 - 1054a5: 67 65 3a 20 addr16 cmp %gs:(%bx,%si),%ah - 1054a9: 25 73 20 25 73 and $0x73252073,%eax - 1054ae: 0a 00 or (%eax),%al - 1054b0: 48 dec %eax - 1054b1: 79 62 jns 105515 - 1054b3: 4f dec %edi - 1054b4: 53 push %ebx - 1054b5: 20 45 53 and %al,0x53(%ebp) - 1054b8: 68 65 6c 6c 20 push $0x206c6c65 - 1054bd: 43 inc %ebx - 1054be: 6f outsl %ds:(%esi),(%dx) - 1054bf: 6d insl (%dx),%es:(%edi) - 1054c0: 6d insl (%dx),%es:(%edi) - 1054c1: 61 popa - 1054c2: 6e outsb %ds:(%esi),(%dx) - 1054c3: 64 fs - 1054c4: 73 3a jae 105500 - 1054c6: 0a 00 or (%eax),%al - 1054c8: 25 31 30 73 20 and $0x20733031,%eax - 1054cd: 25 2d 73 0a 00 and $0xa732d,%eax - 1054d2: 08 20 or %ah,(%eax) - 1054d4: 08 00 or %al,(%eax) - 1054d6: 24 20 and $0x20,%al - 1054d8: 00 4f 6b add %cl,0x6b(%edi) - 1054db: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1054df: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1054e3: 00 94 09 10 00 c2 09 add %dl,0x9c20010(%ecx,%ecx,1) - 1054ea: 10 00 adc %al,(%eax) - 1054ec: e3 09 jecxz 1054f7 - 1054ee: 10 00 adc %al,(%eax) - 1054f0: 03 0a add (%edx),%ecx - 1054f2: 10 00 adc %al,(%eax) - 1054f4: 24 0a and $0xa,%al - 1054f6: 10 00 adc %al,(%eax) - 1054f8: 4a dec %edx - 1054f9: 0a 10 or (%eax),%dl - 1054fb: 00 71 0a add %dh,0xa(%ecx) - 1054fe: 10 00 adc %al,(%eax) - 105500: 97 xchg %eax,%edi - 105501: 0a 10 or (%eax),%dl - 105503: 00 be 0a 10 00 e4 add %bh,0xe400100a(%esi) - 105509: 0a 10 or (%eax),%dl - 10550b: 00 0b add %cl,(%ebx) - 10550d: 0b 10 or (%eax),%edx - 10550f: 00 31 add %dh,(%ecx) - 105511: 0b 10 or (%eax),%edx - 105513: 00 57 0b add %dl,0xb(%edi) - 105516: 10 00 adc %al,(%eax) - 105518: 64 12 10 adc %fs:(%eax),%dl - 10551b: 00 61 0b add %ah,0xb(%ecx) - 10551e: 10 00 adc %al,(%eax) - 105520: 88 0b mov %cl,(%ebx) - 105522: 10 00 adc %al,(%eax) - 105524: ae scas %es:(%edi),%al - 105525: 0b 10 or (%eax),%edx - 105527: 00 d4 add %dl,%ah - 105529: 0b 10 or (%eax),%edx - 10552b: 00 fb add %bh,%bl - 10552d: 0b 10 or (%eax),%edx - 10552f: 00 22 add %ah,(%edx) - 105531: 0c 10 or $0x10,%al - 105533: 00 48 0c add %cl,0xc(%eax) - 105536: 10 00 adc %al,(%eax) - 105538: 6e outsb %ds:(%esi),(%dx) - 105539: 0c 10 or $0x10,%al - 10553b: 00 95 0c 10 00 bc add %dl,0xbc00100c(%ebp) - 105541: 0c 10 or $0x10,%al - 105543: 00 e2 add %ah,%dl - 105545: 0c 10 or $0x10,%al - 105547: 00 08 add %cl,(%eax) - 105549: 0d 10 00 2f 0d or $0xd2f0010,%eax - 10554e: 10 00 adc %al,(%eax) - 105550: 64 12 10 adc %fs:(%eax),%dl - 105553: 00 39 add %bh,(%ecx) - 105555: 0d 10 00 60 0d or $0xd600010,%eax - 10555a: 10 00 adc %al,(%eax) - 10555c: 86 0d 10 00 ac 0d xchg %cl,0xdac0010 - 105562: 10 00 adc %al,(%eax) - 105564: d3 0d 10 00 fa 0d rorl %cl,0xdfa0010 - 10556a: 10 00 adc %al,(%eax) - 10556c: 20 0e and %cl,(%esi) - 10556e: 10 00 adc %al,(%eax) - 105570: 46 inc %esi - 105571: 0e push %cs - 105572: 10 00 adc %al,(%eax) - 105574: 6d insl (%dx),%es:(%edi) - 105575: 0e push %cs - 105576: 10 00 adc %al,(%eax) - 105578: 94 xchg %eax,%esp - 105579: 0e push %cs - 10557a: 10 00 adc %al,(%eax) - 10557c: ba 0e 10 00 e0 mov $0xe000100e,%edx - 105581: 0e push %cs - 105582: 10 00 adc %al,(%eax) - 105584: 64 12 10 adc %fs:(%eax),%dl - 105587: 00 ea add %ch,%dl - 105589: 0e push %cs - 10558a: 10 00 adc %al,(%eax) - 10558c: 11 0f adc %ecx,(%edi) - 10558e: 10 00 adc %al,(%eax) - 105590: 38 0f cmp %cl,(%edi) - 105592: 10 00 adc %al,(%eax) - 105594: 5f pop %edi - 105595: 0f 10 00 movups (%eax),%xmm0 - 105598: 85 0f test %ecx,(%edi) - 10559a: 10 00 adc %al,(%eax) - 10559c: ab stos %eax,%es:(%edi) - 10559d: 0f 10 00 movups (%eax),%xmm0 - 1055a0: d2 0f rorb %cl,(%edi) - 1055a2: 10 00 adc %al,(%eax) - 1055a4: f9 stc - 1055a5: 0f 10 00 movups (%eax),%xmm0 - 1055a8: 1f pop %ds - 1055a9: 10 10 adc %dl,(%eax) - 1055ab: 00 45 10 add %al,0x10(%ebp) - 1055ae: 10 00 adc %al,(%eax) - 1055b0: 6c insb (%dx),%es:(%edi) - 1055b1: 10 10 adc %dl,(%eax) - 1055b3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055b7: 00 92 10 10 00 64 add %dl,0x64001010(%edx) - 1055bd: 12 10 adc (%eax),%dl - 1055bf: 00 9c 10 10 00 64 12 add %bl,0x12640010(%eax,%edx,1) - 1055c6: 10 00 adc %al,(%eax) - 1055c8: 64 12 10 adc %fs:(%eax),%dl - 1055cb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055cf: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055d3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055d7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055db: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055df: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055e3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055e7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055eb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055ef: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055f3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1055f7: 00 a6 10 10 00 cc add %ah,0xcc001010(%esi) - 1055fd: 10 10 adc %dl,(%eax) - 1055ff: 00 f3 add %dh,%bl - 105601: 10 10 adc %dl,(%eax) - 105603: 00 19 add %bl,(%ecx) - 105605: 11 10 adc %edx,(%eax) - 105607: 00 23 add %ah,(%ebx) - 105609: 11 10 adc %edx,(%eax) - 10560b: 00 4a 11 add %cl,0x11(%edx) - 10560e: 10 00 adc %al,(%eax) - 105610: 70 11 jo 105623 - 105612: 10 00 adc %al,(%eax) - 105614: 97 xchg %eax,%edi - 105615: 11 10 adc %edx,(%eax) - 105617: 00 a1 11 10 00 c7 add %ah,0xc7001011(%ecx) - 10561d: 11 10 adc %edx,(%eax) - 10561f: 00 ee add %ch,%dh - 105621: 11 10 adc %edx,(%eax) - 105623: 00 14 12 add %dl,(%edx,%edx,1) - 105626: 10 00 adc %al,(%eax) - 105628: 3b 12 cmp (%edx),%edx - 10562a: 10 00 adc %al,(%eax) - 10562c: 64 12 10 adc %fs:(%eax),%dl - 10562f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105633: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105637: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10563b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10563f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105643: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105647: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10564b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10564f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105653: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105657: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10565b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10565f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105663: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105667: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10566b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10566f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105673: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105677: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10567b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10567f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105683: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105687: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10568b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10568f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105693: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105697: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10569b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10569f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056a3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056a7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056ab: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056af: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056b3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056b7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056bb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056bf: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056c3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056c7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056cb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056cf: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056d3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056d7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056db: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056df: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056e3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056e7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056eb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056ef: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056f3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056f7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056fb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1056ff: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105703: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105707: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10570b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10570f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105713: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105717: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10571b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10571f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105723: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105727: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10572b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10572f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105733: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105737: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10573b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10573f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105743: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105747: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10574b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10574f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105753: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105757: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10575b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10575f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105763: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105767: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10576b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10576f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105773: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105777: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10577b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10577f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105783: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105787: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10578b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10578f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105793: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105797: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10579b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10579f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057a3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057a7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057ab: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057af: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057b3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057b7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057bb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057bf: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057c3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057c7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057cb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057cf: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057d3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057d7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057db: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057df: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057e3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057e7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057eb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057ef: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057f3: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057f7: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057fb: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 1057ff: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105803: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105807: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10580b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10580f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105813: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105817: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10581b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10581f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105823: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105827: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10582b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10582f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105833: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105837: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10583b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10583f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105843: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105847: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10584b: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10584f: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105853: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 105857: 00 64 12 10 add %ah,0x10(%edx,%edx,1) - 10585b: 00 98 08 10 00 69 add %bl,0x69001008(%eax) - 105861: 6e outsb %ds:(%esi),(%dx) - 105862: 69 74 3a 20 6b 65 79 imul $0x6279656b,0x20(%edx,%edi,1),%esi - 105869: 62 - 10586a: 6f outsl %ds:(%esi),(%dx) - 10586b: 61 popa - 10586c: 72 64 jb 1058d2 - 10586e: 20 25 32 75 20 62 and %ah,0x62207532 - 105874: 75 66 jne 1058dc - 105876: 2c 20 sub $0x20,%al - 105878: 25 32 75 62 20 and $0x20627532,%eax - 10587d: 65 gs - 10587e: 61 popa - 10587f: 63 68 20 arpl %bp,0x20(%eax) - ... - 10589e: 00 00 add %al,(%eax) - 1058a0: 5d pop %ebp - 1058a1: 2e cs - 1058a2: 2e cs - 1058a3: 2e cs - 1058a4: 2e cs - 1058a5: 2e cs - 1058a6: 2e cs - 1058a7: 2e cs - 1058a8: 2e cs - 1058a9: 2e cs - 1058aa: 2e cs - 1058ab: 2e cs - 1058ac: 2e cs - 1058ad: 2e cs - 1058ae: 2e cs - 1058af: 2e cs - 1058b0: 2e cs - 1058b1: 2e cs - 1058b2: 2e cs - 1058b3: 2e cs - 1058b4: 2e cs - 1058b5: 2e cs - 1058b6: 2e cs - 1058b7: 2e cs - 1058b8: 2e 2e 2e 2e 2e 2e 2e add %dl,%cs:(%edx) - 1058bf: 2e 2e 2e 2e 2e 2e 2e - 1058c6: 2e 2e 2e 2e 2e 2e 00 - 1058cd: 0a - 1058ce: 0a 70 61 or 0x61(%eax),%dh - 1058d1: 6e outsb %ds:(%esi),(%dx) - 1058d2: 69 63 3a 20 00 0a 0a imul $0xa0a0020,0x3a(%ebx),%esp - 1058d9: 53 push %ebx - 1058da: 79 73 jns 10594f - 1058dc: 74 65 je 105943 - 1058de: 6d insl (%dx),%es:(%edi) - 1058df: 20 68 61 and %ch,0x61(%eax) - 1058e2: 6c insb (%dx),%es:(%edi) - 1058e3: 74 65 je 10594a - 1058e5: 64 2e 00 44 69 76 add %al,%cs:%fs:0x76(%ecx,%ebp,2) - 1058eb: 69 64 65 20 65 72 72 imul $0x6f727265,0x20(%ebp,2),%esp - 1058f2: 6f - 1058f3: 72 00 jb 1058f5 - 1058f5: 44 inc %esp - 1058f6: 65 62 75 67 bound %esi,%gs:0x67(%ebp) - 1058fa: 20 65 78 and %ah,0x78(%ebp) - 1058fd: 63 65 70 arpl %sp,0x70(%ebp) - 105900: 74 69 je 10596b - 105902: 6f outsl %ds:(%esi),(%dx) - 105903: 6e outsb %ds:(%esi),(%dx) - 105904: 00 4e 6f add %cl,0x6f(%esi) - 105907: 6e outsb %ds:(%esi),(%dx) - 105908: 6d insl (%dx),%es:(%edi) - 105909: 61 popa - 10590a: 73 6b jae 105977 - 10590c: 61 popa - 10590d: 62 6c 65 20 bound %ebp,0x20(%ebp,2) - 105911: 69 6e 74 65 72 72 75 imul $0x75727265,0x74(%esi),%ebp - 105918: 70 74 jo 10598e - 10591a: 20 28 and %ch,(%eax) - 10591c: 4e dec %esi - 10591d: 4d dec %ebp - 10591e: 49 dec %ecx - 10591f: 29 00 sub %eax,(%eax) - 105921: 42 inc %edx - 105922: 72 65 jb 105989 - 105924: 61 popa - 105925: 6b 70 6f 69 imul $0x69,0x6f(%eax),%esi - 105929: 6e outsb %ds:(%esi),(%dx) - 10592a: 74 20 je 10594c - 10592c: 28 49 4e sub %cl,0x4e(%ecx) - 10592f: 54 push %esp - 105930: 33 29 xor (%ecx),%ebp - 105932: 00 4f 76 add %cl,0x76(%edi) - 105935: 65 gs - 105936: 72 66 jb 10599e - 105938: 6c insb (%dx),%es:(%edi) - 105939: 6f outsl %ds:(%esi),(%dx) - 10593a: 77 20 ja 10595c - 10593c: 28 49 4e sub %cl,0x4e(%ecx) - 10593f: 54 push %esp - 105940: 4f dec %edi - 105941: 29 00 sub %eax,(%eax) - 105943: 42 inc %edx - 105944: 6f outsl %ds:(%esi),(%dx) - 105945: 75 6e jne 1059b5 - 105947: 64 fs - 105948: 73 20 jae 10596a - 10594a: 63 68 65 arpl %bp,0x65(%eax) - 10594d: 63 6b 00 arpl %bp,0x0(%ebx) - 105950: 49 dec %ecx - 105951: 6e outsb %ds:(%esi),(%dx) - 105952: 76 61 jbe 1059b5 - 105954: 6c insb (%dx),%es:(%edi) - 105955: 69 64 20 6f 70 63 6f imul $0x646f6370,0x6f(%eax,1),%esp - 10595c: 64 - 10595d: 65 00 43 6f add %al,%gs:0x6f(%ebx) - 105961: 70 72 jo 1059d5 - 105963: 6f outsl %ds:(%esi),(%dx) - 105964: 63 65 73 arpl %sp,0x73(%ebp) - 105967: 73 6f jae 1059d8 - 105969: 72 20 jb 10598b - 10596b: 6e outsb %ds:(%esi),(%dx) - 10596c: 6f outsl %ds:(%esi),(%dx) - 10596d: 74 20 je 10598f - 10596f: 61 popa - 105970: 76 61 jbe 1059d3 - 105972: 69 6c 61 62 6c 65 00 imul $0x4400656c,0x62(%ecx,2),%ebp - 105979: 44 - 10597a: 6f outsl %ds:(%esi),(%dx) - 10597b: 75 62 jne 1059df - 10597d: 6c insb (%dx),%es:(%edi) - 10597e: 65 20 66 61 and %ah,%gs:0x61(%esi) - 105982: 75 6c jne 1059f0 - 105984: 74 00 je 105986 - 105986: 43 inc %ebx - 105987: 6f outsl %ds:(%esi),(%dx) - 105988: 70 72 jo 1059fc - 10598a: 6f outsl %ds:(%esi),(%dx) - 10598b: 63 65 73 arpl %sp,0x73(%ebp) - 10598e: 73 6f jae 1059ff - 105990: 72 20 jb 1059b2 - 105992: 73 65 jae 1059f9 - 105994: 67 6d addr16 insl (%dx),%es:(%di) - 105996: 65 6e outsb %gs:(%esi),(%dx) - 105998: 74 20 je 1059ba - 10599a: 6f outsl %ds:(%esi),(%dx) - 10599b: 76 65 jbe 105a02 - 10599d: 72 72 jb 105a11 - 10599f: 75 6e jne 105a0f - 1059a1: 00 49 6e add %cl,0x6e(%ecx) - 1059a4: 76 61 jbe 105a07 - 1059a6: 6c insb (%dx),%es:(%edi) - 1059a7: 69 64 20 54 53 53 00 imul $0x53005353,0x54(%eax,1),%esp - 1059ae: 53 - 1059af: 65 gs - 1059b0: 67 6d addr16 insl (%dx),%es:(%di) - 1059b2: 65 6e outsb %gs:(%esi),(%dx) - 1059b4: 74 20 je 1059d6 - 1059b6: 6e outsb %ds:(%esi),(%dx) - 1059b7: 6f outsl %ds:(%esi),(%dx) - 1059b8: 74 20 je 1059da - 1059ba: 70 72 jo 105a2e - 1059bc: 65 gs - 1059bd: 73 65 jae 105a24 - 1059bf: 6e outsb %ds:(%esi),(%dx) - 1059c0: 74 00 je 1059c2 - 1059c2: 53 push %ebx - 1059c3: 74 61 je 105a26 - 1059c5: 63 6b 20 arpl %bp,0x20(%ebx) - 1059c8: 65 gs - 1059c9: 78 63 js 105a2e - 1059cb: 65 gs - 1059cc: 70 74 jo 105a42 - 1059ce: 69 6f 6e 00 47 65 6e imul $0x6e654700,0x6e(%edi),%ebp - 1059d5: 65 gs - 1059d6: 72 61 jb 105a39 - 1059d8: 6c insb (%dx),%es:(%edi) - 1059d9: 20 50 72 and %dl,0x72(%eax) - 1059dc: 6f outsl %ds:(%esi),(%dx) - 1059dd: 74 65 je 105a44 - 1059df: 63 74 69 6f arpl %si,0x6f(%ecx,%ebp,2) - 1059e3: 6e outsb %ds:(%esi),(%dx) - 1059e4: 20 46 61 and %al,0x61(%esi) - 1059e7: 75 6c jne 105a55 - 1059e9: 74 00 je 1059eb - 1059eb: 50 push %eax - 1059ec: 61 popa - 1059ed: 67 65 20 66 61 addr16 and %ah,%gs:97(%bp) - 1059f2: 75 6c jne 105a60 - 1059f4: 74 00 je 1059f6 - 1059f6: 43 inc %ebx - 1059f7: 6f outsl %ds:(%esi),(%dx) - 1059f8: 70 72 jo 105a6c - 1059fa: 6f outsl %ds:(%esi),(%dx) - 1059fb: 63 65 73 arpl %sp,0x73(%ebp) - 1059fe: 73 6f jae 105a6f - 105a00: 72 20 jb 105a22 - 105a02: 65 gs - 105a03: 72 72 jb 105a77 - 105a05: 6f outsl %ds:(%esi),(%dx) - 105a06: 72 00 jb 105a08 - 105a08: 41 inc %ecx - 105a09: 6c insb (%dx),%es:(%edi) - 105a0a: 69 67 6e 6d 65 6e 74 imul $0x746e656d,0x6e(%edi),%esp - 105a11: 20 63 68 and %ah,0x68(%ebx) - 105a14: 65 63 6b 00 arpl %bp,%gs:0x0(%ebx) - 105a18: 3f aas - 105a19: 3f aas - 105a1a: 00 49 52 add %cl,0x52(%ecx) - 105a1d: 51 push %ecx - 105a1e: 30 00 xor %al,(%eax) - 105a20: 49 dec %ecx - 105a21: 52 push %edx - 105a22: 51 push %ecx - 105a23: 31 00 xor %eax,(%eax) - 105a25: 49 dec %ecx - 105a26: 52 push %edx - 105a27: 51 push %ecx - 105a28: 32 00 xor (%eax),%al - 105a2a: 49 dec %ecx - 105a2b: 52 push %edx - 105a2c: 51 push %ecx - 105a2d: 33 00 xor (%eax),%eax - 105a2f: 49 dec %ecx - 105a30: 52 push %edx - 105a31: 51 push %ecx - 105a32: 34 00 xor $0x0,%al - 105a34: 49 dec %ecx - 105a35: 52 push %edx - 105a36: 51 push %ecx - 105a37: 35 00 49 52 51 xor $0x51524900,%eax - 105a3c: 36 00 49 52 add %cl,%ss:0x52(%ecx) - 105a40: 51 push %ecx - 105a41: 37 aaa - 105a42: 00 49 52 add %cl,0x52(%ecx) - 105a45: 51 push %ecx - 105a46: 38 00 cmp %al,(%eax) - 105a48: 49 dec %ecx - 105a49: 52 push %edx - 105a4a: 51 push %ecx - 105a4b: 39 00 cmp %eax,(%eax) - 105a4d: 49 dec %ecx - 105a4e: 52 push %edx - 105a4f: 51 push %ecx - 105a50: 31 30 xor %esi,(%eax) - 105a52: 00 49 52 add %cl,0x52(%ecx) - 105a55: 51 push %ecx - 105a56: 31 31 xor %esi,(%ecx) - 105a58: 00 49 52 add %cl,0x52(%ecx) - 105a5b: 51 push %ecx - 105a5c: 31 32 xor %esi,(%edx) - 105a5e: 00 49 52 add %cl,0x52(%ecx) - 105a61: 51 push %ecx - 105a62: 31 33 xor %esi,(%ebx) - 105a64: 00 49 52 add %cl,0x52(%ecx) - 105a67: 51 push %ecx - 105a68: 31 34 00 xor %esi,(%eax,%eax,1) - 105a6b: 49 dec %ecx - 105a6c: 52 push %edx - 105a6d: 51 push %ecx - 105a6e: 31 35 00 73 79 73 xor %esi,0x73797300 - 105a74: 63 61 6c arpl %sp,0x6c(%ecx) - 105a77: 6c insb (%dx),%es:(%edi) - 105a78: 00 0a add %cl,(%edx) - 105a7a: 0a 70 61 or 0x61(%eax),%dh - 105a7d: 6e outsb %ds:(%esi),(%dx) - 105a7e: 69 63 3a 20 45 78 63 imul $0x63784520,0x3a(%ebx),%esp - 105a85: 65 gs - 105a86: 70 74 jo 105afc - 105a88: 69 6f 6e 20 30 78 25 imul $0x25783020,0x6e(%edi),%ebp - 105a8f: 30 38 xor %bh,(%eax) - 105a91: 58 pop %eax - 105a92: 00 20 add %ah,(%eax) - 105a94: 28 25 73 29 00 75 sub %ah,0x75002973 - 105a9a: 73 65 jae 105b01 - 105a9c: 64 00 62 6c add %ah,%fs:0x6c(%edx) - 105aa0: 6f outsl %ds:(%esi),(%dx) - 105aa1: 63 6b 20 arpl %bp,0x20(%ebx) - 105aa4: 25 35 70 3a 20 and $0x203a7035,%eax - 105aa9: 25 36 75 20 62 and $0x62207536,%eax - 105aae: 79 74 jns 105b24 - 105ab0: 65 gs - 105ab1: 73 20 jae 105ad3 - 105ab3: 25 73 0a 00 66 and $0x66000a73,%eax - 105ab8: 72 65 jb 105b1f - 105aba: 65 00 69 6e add %ch,%gs:0x6e(%ecx) - 105abe: 69 74 00 45 6e 61 62 imul $0x6c62616e,0x45(%eax,%eax,1),%esi - 105ac5: 6c - 105ac6: 69 6e 67 20 68 61 72 imul $0x72616820,0x67(%esi),%ebp - 105acd: 64 fs - 105ace: 77 61 ja 105b31 - 105ad0: 72 65 jb 105b37 - 105ad2: 20 69 6e and %ch,0x6e(%ecx) - 105ad5: 74 65 je 105b3c - 105ad7: 72 72 jb 105b4b - 105ad9: 75 70 jne 105b4b - 105adb: 74 73 je 105b50 - 105add: 00 4d 6f add %cl,0x6f(%ebp) - 105ae0: 72 65 jb 105b47 - 105ae2: 20 77 6f and %dh,0x6f(%edi) - 105ae5: 72 6b jb 105b52 - 105ae7: 20 6e 65 and %ch,0x65(%esi) - 105aea: 65 gs - 105aeb: 64 fs - 105aec: 73 20 jae 105b0e - 105aee: 74 6f je 105b5f - 105af0: 20 62 65 and %ah,0x65(%edx) - 105af3: 20 64 6f 6e and %ah,0x6e(%edi,%ebp,2) - 105af7: 65 0a 00 or %gs:(%eax),%al - 105afa: 00 00 add %al,(%eax) - 105afc: 00 00 add %al,(%eax) - ... - -00105b00 : - 105b00: e8 58 10 00 08 00 00 00 56 00 00 00 f5 58 10 00 .X......V....X.. - 105b10: 05 00 00 00 56 00 00 00 05 59 10 00 07 00 00 00 ....V....Y...... - 105b20: 56 00 00 00 21 59 10 00 07 00 00 00 56 00 00 00 V...!Y......V... - 105b30: 33 59 10 00 08 00 00 00 ba 00 00 00 43 59 10 00 3Y..........CY.. - 105b40: 08 00 00 00 ba 00 00 00 50 59 10 00 04 00 00 00 ........PY...... - 105b50: ba 00 00 00 5f 59 10 00 08 00 00 00 ba 00 00 00 ...._Y.......... - 105b60: 79 59 10 00 07 00 00 00 1e 01 00 00 86 59 10 00 yY...........Y.. - 105b70: 0b 00 00 00 1e 01 00 00 a2 59 10 00 0b 00 00 00 .........Y...... - 105b80: 1e 01 00 00 ae 59 10 00 0b 00 00 00 1e 01 00 00 .....Y.......... - 105b90: c2 59 10 00 0b 00 00 00 1e 01 00 00 d2 59 10 00 .Y...........Y.. - 105ba0: 0b 00 00 00 1e 01 00 00 eb 59 10 00 0b 00 00 00 .........Y...... - 105bb0: 82 01 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ................ - 105bc0: f6 59 10 00 08 00 00 00 82 01 00 00 08 5a 10 00 .Y...........Z.. - ... - 105bd8: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105bf0: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105c08: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105c20: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105c38: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105c50: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105c68: 18 5a 10 00 00 00 00 00 00 00 00 00 18 5a 10 00 .Z...........Z.. - ... - 105c80: 1b 5a 10 00 00 00 00 00 00 00 00 00 20 5a 10 00 .Z.......... Z.. - ... - 105c98: 25 5a 10 00 00 00 00 00 00 00 00 00 2a 5a 10 00 %Z..........*Z.. - ... - 105cb0: 2f 5a 10 00 00 00 00 00 00 00 00 00 34 5a 10 00 /Z..........4Z.. - ... - 105cc8: 39 5a 10 00 00 00 00 00 00 00 00 00 3e 5a 10 00 9Z..........>Z.. - ... - 105ce0: 43 5a 10 00 00 00 00 00 00 00 00 00 48 5a 10 00 CZ..........HZ.. - ... - 105cf8: 4d 5a 10 00 00 00 00 00 00 00 00 00 53 5a 10 00 MZ..........SZ.. - ... - 105d10: 59 5a 10 00 00 00 00 00 00 00 00 00 5f 5a 10 00 YZ.........._Z.. - ... - 105d28: 65 5a 10 00 00 00 00 00 00 00 00 00 6b 5a 10 00 eZ..........kZ.. - ... - 105d40: 71 5a 10 00 00 00 00 00 00 00 00 00 qZ.......... - -00105d4c : - 105d4c: 20 00 00 00 ... - -00105d50 : - 105d50: 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (............... - 105d60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ - 105d70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ - 105d80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a ===============. - ... - 105da0: 62 6c 6f 63 6b 73 3a 20 25 36 75 20 75 73 65 64 blocks: %6u used - 105db0: 2c 20 25 36 75 20 66 72 65 65 2c 20 25 36 75 20 , %6u free, %6u - 105dc0: 74 6f 74 61 6c 0a 00 00 00 00 00 00 00 00 00 00 total........... - ... - 105de0: 20 62 79 74 65 73 3a 20 25 36 75 20 75 73 65 64 bytes: %6u used - 105df0: 2c 20 25 36 75 20 66 72 65 65 2c 20 25 36 75 20 , %6u free, %6u - 105e00: 74 6f 74 61 6c 0a 00 00 00 00 00 00 00 00 00 00 total........... - ... - 105e20: 67 5f 68 65 61 70 5f 62 6f 74 3d 30 78 25 70 2c g_heap_bot=0x%p, - 105e30: 20 67 5f 6b 62 72 6b 3d 30 78 25 70 2c 20 67 5f g_kbrk=0x%p, g_ - 105e40: 68 65 61 70 5f 74 6f 70 3d 30 78 25 70 0a 00 00 heap_top=0x%p... - ... - 105e60: 2a 2a 2a 20 73 6f 6d 65 20 68 65 61 70 20 6d 65 *** some heap me - 105e70: 6d 6f 72 79 20 69 73 20 6e 6f 74 20 61 63 63 6f mory is not acco - 105e80: 75 6e 74 65 64 20 66 6f 72 0a 00 00 00 00 00 00 unted for....... - ... - 105ea0: 6b 65 72 6e 65 6c 20 68 65 61 70 20 69 73 20 63 kernel heap is c - 105eb0: 6f 72 72 75 70 74 20 69 6e 20 6d 61 6c 6c 6f 63 orrupt in malloc - 105ec0: 28 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ().............. - ... - 105ee0: 61 74 74 65 6d 70 74 20 74 6f 20 66 72 65 65 28 attempt to free( - 105ef0: 29 20 62 6c 6f 63 6b 20 61 74 20 30 78 25 70 20 ) block at 0x%p - 105f00: 77 69 74 68 20 62 61 64 20 6d 61 67 69 63 20 76 with bad magic v - 105f10: 61 6c 75 65 00 00 00 00 00 00 00 00 00 00 00 00 alue............ - 105f20: 6b 65 72 6e 65 6c 20 68 65 61 70 20 69 73 20 63 kernel heap is c - 105f30: 6f 72 72 75 70 74 20 69 6e 20 66 72 65 65 28 29 orrupt in free() - ... - 105f60: 61 74 74 65 6d 70 74 20 74 6f 20 66 72 65 65 28 attempt to free( - 105f70: 29 20 62 6c 6f 63 6b 20 61 74 20 30 78 25 70 20 ) block at 0x%p - 105f80: 74 68 61 74 20 69 73 20 6e 6f 74 20 69 6e 20 74 that is not in t - 105f90: 68 65 20 68 65 61 70 00 00 00 00 00 00 00 00 00 he heap......... - 105fa0: 55 6e 61 62 6c 65 20 74 6f 20 72 75 6e 20 74 65 Unable to run te - 105fb0: 73 74 68 65 61 70 20 2d 2d 20 6b 6d 61 6c 6c 6f stheap -- kmallo - 105fc0: 63 28 29 20 69 73 20 62 72 6f 6b 65 6e 2e 0a 00 c() is broken... - ... - 105fe0: 61 74 74 65 6d 70 74 20 74 6f 20 72 65 61 6c 6c attempt to reall - 105ff0: 6f 63 28 29 20 62 6c 6f 63 6b 20 61 74 20 30 78 oc() block at 0x - 106000: 25 70 20 77 69 74 68 20 62 61 64 20 6d 61 67 69 %p with bad magi - 106010: 63 20 76 61 6c 75 65 00 00 00 00 00 00 00 00 00 c value......... - 106020: 49 6e 73 74 61 6c 6c 69 6e 67 20 6b 65 79 62 6f Installing keybo - 106030: 61 72 64 20 69 6e 74 65 72 72 75 70 74 20 68 61 ard interrupt ha - 106040: 6e 64 6c 65 72 00 00 00 00 00 00 00 00 00 00 00 ndler........... - ... - 106060: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 106070: 20 20 20 20 20 20 20 20 20 5f 20 20 20 5f 20 20 _ _ - 106080: 5f 20 20 5f 20 20 5f 5f 5f 5f 20 20 5f 5f 5f 5f _ _ ____ ____ - 106090: 5f 20 20 5f 5f 5f 20 20 20 20 20 20 20 20 20 20 _ ___ - 1060a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - ... - 1060c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 1060d0: 20 20 20 20 20 20 20 20 28 20 29 5f 28 20 29 28 ( )_( )( - 1060e0: 20 5c 2f 20 29 28 20 20 5f 20 5c 28 20 20 5f 20 \/ )( _ \( _ - 1060f0: 20 29 2f 20 5f 5f 29 20 20 20 20 20 20 20 20 20 )/ __) - 106100: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - ... - 106120: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 106130: 20 20 20 20 20 20 20 20 20 29 20 5f 20 28 20 20 ) _ ( - 106140: 5c 20 20 2f 20 20 29 20 5f 20 3c 20 29 28 5f 29 \ / ) _ < )(_) - 106150: 28 20 5c 5f 5f 20 5c 20 20 20 20 20 20 20 20 20 ( \__ \ - 106160: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - ... - 106180: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 106190: 20 20 20 20 20 20 20 20 28 5f 29 20 28 5f 29 20 (_) (_) - 1061a0: 28 5f 5f 29 20 28 5f 5f 5f 5f 2f 28 5f 5f 5f 5f (__) (____/(____ - 1061b0: 5f 29 28 5f 5f 5f 2f 20 20 20 20 20 20 20 20 20 _)(___/ - 1061c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 1061d0: 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 1061e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 1061f0: 20 20 20 20 20 20 20 20 48 79 62 72 69 64 20 4f Hybrid O - 106200: 70 65 72 61 74 69 6e 67 20 53 79 73 74 65 6d 20 perating System - 106210: 28 48 79 62 4f 53 29 20 20 20 20 20 20 20 20 20 (HybOS) - 106220: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 - 106230: 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ - 106240: 41 4c 54 20 2b 20 46 31 20 2d 20 46 38 20 66 6f ALT + F1 - F8 fo - 106250: 72 20 76 69 72 74 75 61 6c 20 74 65 72 6d 69 6e r virtual termin - 106260: 61 6c 73 0a 00 00 00 00 00 00 00 00 00 00 00 00 als............. - ... - 106280: 54 68 72 65 65 20 66 69 6e 67 65 72 20 73 61 6c Three finger sal - 106290: 75 74 65 20 74 6f 20 72 65 73 74 61 72 74 0a 00 ute to restart.. - 1062a0: 49 6e 69 74 69 61 6c 69 7a 69 6e 67 20 6d 65 6d Initializing mem - 1062b0: 6f 72 79 20 6d 61 6e 61 67 65 6d 65 6e 74 00 00 ory management.. - 1062c0: 00 00 00 00 74 61 73 6b 20 68 61 6e 64 6c 65 72 ....task handler - ... - -001062e0 : - 1062e0: 00 00 00 00 04 00 00 00 02 00 00 00 06 00 00 00 ................ - 1062f0: 01 00 00 00 05 00 00 00 03 00 00 00 07 00 00 00 ................ - 106300: 1b 5b 32 4a 00 6d 6f 6e 6f 00 5d 2e 2e 2e 2e 2e .[2J.mono.]..... - 106310: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 00 63 6f 6c 6f ............colo - 106320: 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r............... - ... - 106340: 69 6e 69 74 3a 20 76 69 64 65 6f 20 25 35 73 20 init: video %5s - 106350: 65 6d 75 6c 61 74 69 6f 6e 2c 20 25 32 75 78 25 emulation, %2ux% - 106360: 32 75 2c 20 66 72 61 6d 65 62 75 66 66 65 72 20 2u, framebuffer - 106370: 61 74 20 30 78 25 31 58 20 00 00 00 0c 4d 10 00 at 0x%1X ....M.. - 106380: 40 4d 10 00 5c 4d 10 00 76 4d 10 00 98 4d 10 00 @M..\M..vM...M.. - 106390: b5 4d 10 00 dc 4e 10 00 dc 4e 10 00 dc 4e 10 00 .M...N...N...N.. - 1063a0: dc 4e 10 00 dc 4e 10 00 dc 4e 10 00 dc 4e 10 00 .N...N...N...N.. - 1063b0: dc 4e 10 00 dc 4e 10 00 dc 4e 10 00 63 4f 10 00 .N...N...N..cO.. - 1063c0: 7e 4f 10 00 dc 4e 10 00 dc 4e 10 00 dc 4e 10 00 ~O...N...N...N.. - 1063d0: dc 4e 10 00 7e 4f 10 00 dc 4e 10 00 dc 4e 10 00 .N..~O...N...N.. - 1063e0: dc 4e 10 00 dc 4e 10 00 b9 4d 10 00 8c 4f 10 00 .N...N...M...O.. - 1063f0: b9 4d 10 00 dc 4e 10 00 dc 4e 10 00 96 4f 10 00 .M...N...N...O.. - 106400: dc 4e 10 00 82 4f 10 00 dc 4e 10 00 dc 4e 10 00 .N...O...N...N.. - 106410: b9 4d 10 00 00 00 00 00 00 00 00 00 00 00 00 00 .M.............. - ... diff --git a/Dump/hybos/src/objects/kernel.sym b/Dump/hybos/src/objects/kernel.sym deleted file mode 100644 index 9626ccf..0000000 --- a/Dump/hybos/src/objects/kernel.sym +++ /dev/null @@ -1,656 +0,0 @@ -00000001 a MULTIBOOT_PAGE_ALIGN -00000002 a MULTIBOOT_MEMORY_INFO -00000010 a LINEAR_DATA_SEL -00000018 a LINEAR_CODE_SEL -00010000 a MULTIBOOT_AOUT_KLUDGE -00010003 a MULTIBOOT_HEADER_FLAGS -00100000 A LS_Phys -00100000 A LS_Virt -00100000 T LS_Code /usr/home/reddawg/source/hybos/src/kernel/bootlog.c:10 -00100000 T _code /usr/home/reddawg/source/hybos/src/kernel/bootlog.c:10 -00100000 T code /usr/home/reddawg/source/hybos/src/kernel/bootlog.c:10 -00100000 T klog /usr/home/reddawg/source/hybos/src/kernel/bootlog.c:10 -0010011c T dump /usr/home/reddawg/source/hybos/src/kernel/debug.c:17 -001001cc T dump_regs /usr/home/reddawg/source/hybos/src/kernel/debug.c:44 -00100250 T keyDown /usr/home/reddawg/source/hybos/src/esh/esh.c:44 -00100258 T keyUp /usr/home/reddawg/source/hybos/src/esh/esh.c:58 -00100260 T initCommands /usr/home/reddawg/source/hybos/src/esh/esh.c:63 -00100434 T mapCommand /usr/home/reddawg/source/hybos/src/esh/esh.c:118 -001004b4 T isParam /usr/home/reddawg/source/hybos/src/esh/esh.c:162 -00100508 T mapParams /usr/home/reddawg/source/hybos/src/esh/esh.c:185 -0010064c T processCommand /usr/home/reddawg/source/hybos/src/esh/esh.c:264 -001007e4 t reboot /usr/home/reddawg/source/hybos/src/kernel/keyboard.c:58 -0010082c t _write_kb /usr/home/reddawg/source/hybos/src/kernel/keyboard.c:99 -00100874 T _translate_sc /usr/home/reddawg/source/hybos/src/kernel/keyboard.c:149 -00101298 T handle_meta_key /usr/home/reddawg/source/hybos/src/kernel/keyboard.c:364 -0010131c T keyboard_irq /usr/home/reddawg/source/hybos/src/kernel/keyboard.c:414 -0010157c T init_keyboard /usr/home/reddawg/source/hybos/src/kernel/keyboard.c:555 -00101640 T entry -00101657 t ds_ok -00101673 t sbat -00101697 t do_idt -001016c8 t mboot -001016e8 t all_ints -001016f7 T _getvect -001016f7 T getvect -00101731 T _setvect -00101731 T setvect -0010176b t isr0 -00101785 t isr0.1 -00101791 t isr1 -001017ab t isr1.1 -001017b7 t isr2 -001017d1 t isr2.1 -001017dd t isr3 -001017f7 t isr3.1 -00101803 t isr4 -0010181d t isr4.1 -00101829 t isr5 -00101843 t isr5.1 -0010184f t isr6 -00101869 t isr6.1 -00101875 t isr7 -0010188f t isr7.1 -0010189b t isr8 -001018b5 t isr8.1 -001018c1 t isr9 -001018db t isr9.1 -001018e7 t isr0Ah -00101901 t isr0Ah.1 -0010190d t isr0Bh -00101927 t isr0Bh.1 -00101933 t isr0Ch -0010194d t isr0Ch.1 -00101959 t isr0Dh -00101973 t isr0Dh.1 -0010197f t isr0Eh -00101999 t isr0Eh.1 -001019a5 t isr0Fh -001019bf t isr0Fh.1 -001019cb t isr10h -001019e5 t isr10h.1 -001019f1 t isr11h -00101a0b t isr11h.1 -00101a17 t isr12h -00101a31 t isr12h.1 -00101a3d t isr13h -00101a57 t isr13h.1 -00101a63 t isr14h -00101a7d t isr14h.1 -00101a89 t isr15h -00101aa3 t isr15h.1 -00101aaf t isr16h -00101ac9 t isr16h.1 -00101ad5 t isr17h -00101aef t isr17h.1 -00101afb t isr18h -00101b15 t isr18h.1 -00101b21 t isr19h -00101b3b t isr19h.1 -00101b47 t isr1Ah -00101b61 t isr1Ah.1 -00101b6d t isr1Bh -00101b87 t isr1Bh.1 -00101b93 t isr1Ch -00101bad t isr1Ch.1 -00101bb9 t isr1Dh -00101bd3 t isr1Dh.1 -00101bdf t isr1Eh -00101bf9 t isr1Eh.1 -00101c05 t isr1Fh -00101c1f t isr1Fh.1 -00101c2b t isr20h -00101c45 t isr20h.1 -00101c51 t isr21h -00101c6b t isr21h.1 -00101c77 t isr22h -00101c91 t isr22h.1 -00101c9d t isr23h -00101cb7 t isr23h.1 -00101cc3 t isr24h -00101cdd t isr24h.1 -00101ce9 t isr25h -00101d03 t isr25h.1 -00101d0f t isr26h -00101d29 t isr26h.1 -00101d35 t isr27h -00101d4f t isr27h.1 -00101d5b t isr28h -00101d75 t isr28h.1 -00101d81 t isr29h -00101d9b t isr29h.1 -00101da7 t isr2Ah -00101dc1 t isr2Ah.1 -00101dcd t isr2Bh -00101de7 t isr2Bh.1 -00101df3 t isr2Ch -00101e0d t isr2Ch.1 -00101e19 t isr2Dh -00101e33 t isr2Dh.1 -00101e3f t isr2Eh -00101e59 t isr2Eh.1 -00101e65 t isr2Fh -00101e7f t isr2Fh.1 -00101e8b t isr30h -00101ea5 t isr30h.1 -00101eb1 t isr49 -00101ecb t isr49.1 -00101ed7 t isr50 -00101ef1 t isr50.1 -00101efd t isr51 -00101f17 t isr51.1 -00101f23 t isr52 -00101f3d t isr52.1 -00101f49 t isr53 -00101f63 t isr53.1 -00101f6f t isr54 -00101f89 t isr54.1 -00101f95 t isr55 -00101faf t isr55.1 -00101fbb t isr56 -00101fd5 t isr56.1 -00101fe1 t isr57 -00101ffb t isr57.1 -00102007 t isr58 -00102021 t isr58.1 -0010202d t isr59 -00102047 t isr59.1 -00102053 t isr60 -0010206d t isr60.1 -00102079 t isr61 -00102093 t isr61.1 -0010209f t isr62 -001020b9 t isr62.1 -001020c5 t isr63 -001020df t isr63.1 -001020eb t isr64 -00102105 t isr64.1 -00102111 t isr65 -0010212b t isr65.1 -00102137 t isr66 -00102151 t isr66.1 -0010215d t isr67 -00102177 t isr67.1 -00102183 t isr68 -0010219d t isr68.1 -001021a9 t isr69 -001021c3 t isr69.1 -001021cf t isr70 -001021e9 t isr70.1 -001021f5 t isr71 -0010220f t isr71.1 -0010221b t isr72 -00102235 t isr72.1 -00102241 t isr73 -0010225b t isr73.1 -00102267 t isr74 -00102281 t isr74.1 -0010228d t isr75 -001022a7 t isr75.1 -001022b3 t isr76 -001022cd t isr76.1 -001022d9 t isr77 -001022f3 t isr77.1 -001022ff t isr78 -00102319 t isr78.1 -00102325 t isr79 -0010233f t isr79.1 -0010234b t isr80 -00102365 t isr80.1 -00102371 t isr81 -0010238b t isr81.1 -00102397 t isr82 -001023b1 t isr82.1 -001023bd t isr83 -001023d7 t isr83.1 -001023e3 t isr84 -001023fd t isr84.1 -00102409 t isr85 -00102423 t isr85.1 -0010242f t isr86 -00102449 t isr86.1 -00102455 t isr87 -0010246f t isr87.1 -0010247b t isr88 -00102495 t isr88.1 -001024a1 t isr89 -001024bb t isr89.1 -001024c7 t isr90 -001024e1 t isr90.1 -001024ed t isr91 -00102507 t isr91.1 -00102513 t isr92 -0010252d t isr92.1 -00102539 t isr93 -00102553 t isr93.1 -0010255f t isr94 -00102579 t isr94.1 -00102585 t isr95 -0010259f t isr95.1 -001025ab t isr96 -001025c5 t isr96.1 -001025d1 t isr97 -001025eb t isr97.1 -001025f7 t isr98 -00102611 t isr98.1 -0010261d t isr99 -00102637 t isr99.1 -00102643 t isr100 -0010265d t isr100.1 -00102669 t isr101 -00102683 t isr101.1 -0010268f t isr102 -001026a9 t isr102.1 -001026b5 t isr103 -001026cf t isr103.1 -001026db t isr104 -001026f5 t isr104.1 -00102701 t isr105 -0010271b t isr105.1 -00102727 t isr106 -00102741 t isr106.1 -0010274d t isr107 -00102767 t isr107.1 -00102773 t isr108 -0010278d t isr108.1 -00102799 t isr109 -001027b3 t isr109.1 -001027bf t isr110 -001027d9 t isr110.1 -001027e5 t isr111 -001027ff t isr111.1 -0010280b t isr112 -00102825 t isr112.1 -00102831 t isr113 -0010284b t isr113.1 -00102857 t isr114 -00102871 t isr114.1 -0010287d t isr115 -00102897 t isr115.1 -001028a3 t isr116 -001028bd t isr116.1 -001028c9 t isr117 -001028e3 t isr117.1 -001028ef t isr118 -00102909 t isr118.1 -00102915 t isr119 -0010292f t isr119.1 -0010293b t isr120 -00102955 t isr120.1 -00102961 t isr121 -0010297b t isr121.1 -00102987 t isr122 -001029a1 t isr122.1 -001029ad t isr123 -001029c7 t isr123.1 -001029d3 t isr124 -001029ed t isr124.1 -001029f9 t isr125 -00102a13 t isr125.1 -00102a1f t isr126 -00102a39 t isr126.1 -00102a45 t isr127 -00102a5f t isr127.1 -00102a6b t isr128 -00102a85 t isr128.1 -00102a91 t isr129 -00102aab t isr129.1 -00102ab7 t isr130 -00102ad1 t isr130.1 -00102add t isr131 -00102af7 t isr131.1 -00102b03 t isr132 -00102b1d t isr132.1 -00102b29 t isr133 -00102b43 t isr133.1 -00102b4f t isr134 -00102b69 t isr134.1 -00102b75 t isr135 -00102b8f t isr135.1 -00102b9b t isr136 -00102bb5 t isr136.1 -00102bc1 t isr137 -00102bdb t isr137.1 -00102be7 t isr138 -00102c01 t isr138.1 -00102c0d t isr139 -00102c27 t isr139.1 -00102c33 t isr140 -00102c4d t isr140.1 -00102c59 t isr141 -00102c73 t isr141.1 -00102c7f t isr142 -00102c99 t isr142.1 -00102ca5 t isr143 -00102cbf t isr143.1 -00102ccb t isr144 -00102ce5 t isr144.1 -00102cf1 t isr145 -00102d0b t isr145.1 -00102d17 t isr146 -00102d31 t isr146.1 -00102d3d t isr147 -00102d57 t isr147.1 -00102d63 t isr148 -00102d7d t isr148.1 -00102d89 t isr149 -00102da3 t isr149.1 -00102daf t isr150 -00102dc9 t isr150.1 -00102dd5 t isr151 -00102def t isr151.1 -00102dfb t isr152 -00102e15 t isr152.1 -00102e21 t isr153 -00102e3b t isr153.1 -00102e47 t isr154 -00102e61 t isr154.1 -00102e6d t isr155 -00102e87 t isr155.1 -00102e93 t isr156 -00102ead t isr156.1 -00102eb9 t isr157 -00102ed3 t isr157.1 -00102edf t isr158 -00102ef9 t isr158.1 -00102f05 t isr159 -00102f1f t isr159.1 -00102f2b t isr160 -00102f45 t isr160.1 -00102f51 t isr161 -00102f6b t isr161.1 -00102f77 t isr162 -00102f91 t isr162.1 -00102f9d t isr163 -00102fb7 t isr163.1 -00102fc3 t isr164 -00102fdd t isr164.1 -00102fe9 t isr165 -00103003 t isr165.1 -0010300f t isr166 -00103029 t isr166.1 -00103035 t isr167 -0010304f t isr167.1 -0010305b t isr168 -00103075 t isr168.1 -00103081 t isr169 -0010309b t isr169.1 -001030a7 t isr170 -001030c1 t isr170.1 -001030cd t isr171 -001030e7 t isr171.1 -001030f3 t isr172 -0010310d t isr172.1 -00103119 t isr173 -00103133 t isr173.1 -0010313f t isr174 -00103159 t isr174.1 -00103165 t isr175 -0010317f t isr175.1 -0010318b t isr176 -001031a5 t isr176.1 -001031b1 t isr177 -001031cb t isr177.1 -001031d7 t isr178 -001031f1 t isr178.1 -001031fd t isr179 -00103217 t isr179.1 -00103223 t isr180 -0010323d t isr180.1 -00103249 t isr181 -00103263 t isr181.1 -0010326f t isr182 -00103289 t isr182.1 -00103295 t isr183 -001032af t isr183.1 -001032bb t isr184 -001032d5 t isr184.1 -001032e1 t isr185 -001032fb t isr185.1 -00103307 t isr186 -00103321 t isr186.1 -0010332d t isr187 -00103347 t isr187.1 -00103353 t isr188 -0010336d t isr188.1 -00103379 t isr189 -00103393 t isr189.1 -0010339f t isr190 -001033b9 t isr190.1 -001033c5 t isr191 -001033df t isr191.1 -001033eb t isr192 -00103405 t isr192.1 -00103411 t isr193 -0010342b t isr193.1 -00103437 t isr194 -00103451 t isr194.1 -0010345d t isr195 -00103477 t isr195.1 -00103483 t isr196 -0010349d t isr196.1 -001034a9 t isr197 -001034c3 t isr197.1 -001034cf t isr198 -001034e9 t isr198.1 -001034f5 t isr199 -0010350f t isr199.1 -0010351b t isr200 -00103535 t isr200.1 -00103541 t isr201 -0010355b t isr201.1 -00103567 t isr202 -00103581 t isr202.1 -0010358d t isr203 -001035a7 t isr203.1 -001035b3 t isr204 -001035cd t isr204.1 -001035d9 t isr205 -001035f3 t isr205.1 -001035ff t isr206 -00103619 t isr206.1 -00103625 t isr207 -0010363f t isr207.1 -0010364b t isr208 -00103665 t isr208.1 -00103671 t isr209 -0010368b t isr209.1 -00103697 t isr210 -001036b1 t isr210.1 -001036bd t isr211 -001036d7 t isr211.1 -001036e3 t isr212 -001036fd t isr212.1 -00103709 t isr213 -00103723 t isr213.1 -0010372f t isr214 -00103749 t isr214.1 -00103755 t isr215 -0010376f t isr215.1 -0010377b t isr216 -00103795 t isr216.1 -001037a1 t isr217 -001037bb t isr217.1 -001037c7 t isr218 -001037e1 t isr218.1 -001037ed t isr219 -00103807 t isr219.1 -00103813 t isr220 -0010382d t isr220.1 -00103839 t isr221 -00103853 t isr221.1 -0010385f t isr222 -00103879 t isr222.1 -00103885 t isr223 -0010389f t isr223.1 -001038ab t isr224 -001038c5 t isr224.1 -001038d1 t isr225 -001038eb t isr225.1 -001038f7 t isr226 -00103911 t isr226.1 -0010391d t isr227 -00103937 t isr227.1 -00103943 t isr228 -0010395d t isr228.1 -00103969 t isr229 -00103983 t isr229.1 -0010398f t isr230 -001039a9 t isr230.1 -001039b5 t isr231 -001039cf t isr231.1 -001039db t isr232 -001039f5 t isr232.1 -00103a01 t isr233 -00103a1b t isr233.1 -00103a27 t isr234 -00103a41 t isr234.1 -00103a4d t isr235 -00103a67 t isr235.1 -00103a73 t isr236 -00103a8d t isr236.1 -00103a99 t isr237 -00103ab3 t isr237.1 -00103abf t isr238 -00103ad9 t isr238.1 -00103ae5 t isr239 -00103aff t isr239.1 -00103b0b t isr240 -00103b25 t isr240.1 -00103b31 t isr241 -00103b4b t isr241.1 -00103b57 t isr242 -00103b71 t isr242.1 -00103b7d t isr243 -00103b97 t isr243.1 -00103ba3 t isr244 -00103bbd t isr244.1 -00103bc9 t isr245 -00103be3 t isr245.1 -00103bef t isr246 -00103c09 t isr246.1 -00103c15 t isr247 -00103c2f t isr247.1 -00103c3b t isr248 -00103c55 t isr248.1 -00103c61 t isr249 -00103c7b t isr249.1 -00103c87 t isr250 -00103ca1 t isr250.1 -00103cad t isr251 -00103cc7 t isr251.1 -00103cd3 t isr252 -00103ced t isr252.1 -00103cf9 t isr253 -00103d13 t isr253.1 -00103d1f t isr254 -00103d39 t isr254.1 -00103d45 t isr255 -00103d5f t isr255.1 -00103d6c t kprintf_help /usr/home/reddawg/source/hybos/src/kernel/main.c:80 -00103d80 T kprintf /usr/home/reddawg/source/hybos/src/kernel/main.c:104 -00103d9c T printk /usr/home/reddawg/source/hybos/src/kernel/main.c:117 -00103db8 T panic /usr/home/reddawg/source/hybos/src/kernel/main.c:134 -00103e04 T fault /usr/home/reddawg/source/hybos/src/kernel/main.c:156 -00103e90 t init_8259s /usr/home/reddawg/source/hybos/src/kernel/main.c:248 -00103f14 t dump_heap /usr/home/reddawg/source/hybos/src/kernel/main.c:303 -0010401c T dumpheapk /usr/home/reddawg/source/hybos/src/kernel/main.c:339 -00104028 t kbrk /usr/home/reddawg/source/hybos/src/kernel/main.c:373 -00104080 T kmalloc /usr/home/reddawg/source/hybos/src/kernel/main.c:410 -001041b0 T kfree /usr/home/reddawg/source/hybos/src/kernel/main.c:518 -00104288 T testheap /usr/home/reddawg/source/hybos/src/kernel/main.c:585 -0010429c T krealloc /usr/home/reddawg/source/hybos/src/kernel/main.c:603 -00104324 T main /usr/home/reddawg/source/hybos/src/kernel/main.c:655 -00104424 T _mm_init /usr/home/reddawg/source/hybos/src/mm/memory.c:23 -0010445c T _mm_physical_init /usr/home/reddawg/source/hybos/src/mm/memory.c:31 -001044a4 T _mm_physical_alloc /usr/home/reddawg/source/hybos/src/mm/memory.c:50 -001044f4 T _mm_physical_free /usr/home/reddawg/source/hybos/src/mm/memory.c:75 -00104518 T _mm_virtual_init /usr/home/reddawg/source/hybos/src/mm/memory.c:80 -00104520 T _mm_page_copy_byte /usr/home/reddawg/source/hybos/src/mm/memory.c:84 -00104538 T _mm_page_copy_word /usr/home/reddawg/source/hybos/src/mm/memory.c:96 -00104550 T _mm_page_copy_dword /usr/home/reddawg/source/hybos/src/mm/memory.c:108 -00104568 T schedule /usr/home/reddawg/source/hybos/src/kernel/sched.c:91 -001045ac T init_tasks /usr/home/reddawg/source/hybos/src/kernel/sched.c:128 -001045f4 t write /usr/home/reddawg/source/hybos/src/kernel/tasks.c:31 -00104634 t yield /usr/home/reddawg/source/hybos/src/kernel/tasks.c:47 -00104640 t wait /usr/home/reddawg/source/hybos/src/kernel/tasks.c:57 -00104650 T task1 /usr/home/reddawg/source/hybos/src/kernel/tasks.c:69 -00104664 T task2 /usr/home/reddawg/source/hybos/src/kernel/tasks.c:88 -00104678 T task3 /usr/home/reddawg/source/hybos/src/kernel/tasks.c:106 -0010468c T task4 /usr/home/reddawg/source/hybos/src/kernel/tasks.c:124 -001046a0 T blink /usr/home/reddawg/source/hybos/src/kernel/video.c:51 -001046ac T get_current_vc /usr/home/reddawg/source/hybos/src/kernel/video.c:60 -001046b8 t scroll /usr/home/reddawg/source/hybos/src/kernel/video.c:69 -0010473c t set_attrib /usr/home/reddawg/source/hybos/src/kernel/video.c:101 -00104798 t move_csr /usr/home/reddawg/source/hybos/src/kernel/video.c:132 -00104804 T select_vc /usr/home/reddawg/source/hybos/src/kernel/video.c:149 -00104890 T putch_help /usr/home/reddawg/source/hybos/src/kernel/video.c:171 -00104b00 T putch /usr/home/reddawg/source/hybos/src/kernel/video.c:365 -00104b18 T init_video /usr/home/reddawg/source/hybos/src/kernel/video.c:377 -00104cc8 T disable /usr/home/reddawg/source/hybos/lib/x86/disable.c:4 -00104cd0 T do_printf /usr/home/reddawg/source/hybos/lib/stdio/doprintf.c:62 -0010500c T enable /usr/home/reddawg/source/hybos/lib/x86/enable.c:4 -00105014 T inportb /usr/home/reddawg/source/hybos/lib/x86/inportb.c:4 -00105020 T longjmp /usr/home/reddawg/source/hybos/lib/setjmp/longjmp.c:42 -0010505c T memcpy /usr/home/reddawg/source/hybos/lib/mem/memcpy.c:2 -00105088 T memsetw /usr/home/reddawg/source/hybos/lib/mem/memsetw.c:3 -001050b4 T outportb /usr/home/reddawg/source/hybos/lib/x86/outportb.c:4 -001050c0 T printf_help /usr/home/reddawg/source/hybos/lib/stdio/printf.c:14 -001050d4 T printf /usr/home/reddawg/source/hybos/lib/stdio/printf.c:25 -001050f0 T strcmp /usr/home/reddawg/source/hybos/lib/string/strcmp.c:2 -0010513c T strcpy /usr/home/reddawg/source/hybos/lib/string/strcpy.c:3 -00105158 T strlen /usr/home/reddawg/source/hybos/lib/string/strlen.c:5 -00105174 T strncpy /usr/home/reddawg/source/hybos/lib/string/strncpy.c:4 -00105b00 t ex.0 -00105d4c t irq0_int.1 -00105d50 t irq8_int.2 -001062e0 t ansi_to_vga.0 -00107000 D LS_Data -00107000 D _data -00107000 D data -00107000 d ds_magic -00107004 d gdt -00107024 d gdt_end -00107024 d gdt_ptr -0010702a d idt -0010782a d idt_end -0010782a d idt_ptr -00107840 D _ctype -00108000 B LS_Bss -00108000 B _bss -00108000 B bss -00108000 b altk.0 -00108020 b buffers.1 -00108320 b rawkey -00108340 b keys -00108540 b numkeysbuffer -00108560 b szInBuf -001085a0 b makebreak -001095a4 b stack -001095c0 b heap.3 -001836e0 b g_heap_bot -001836e4 b g_kbrk -001836e8 b g_heap_top -00183700 b current.0 -00183704 b entry.2 -00183704 b stacks.1 -00183720 b _tasks -00183a20 b _num_vcs -00183a24 b _curr_vc -00183a28 b _vga_fb_adr -00183a2c b _crtc_io_adr -00183a30 b _vc_width -00183a34 b _vc_height -00183a40 B eshCommands -00194280 B ts -00197280 B bufferIterator -00197284 B buffer -001972a0 B td -0019a2a0 B _curr_task -0019a2c0 B curr_vtty -0019a2e0 B _vc -0019b000 A _end -0019b000 A end -1badb002 a MULTIBOOT_HEADER_MAGIC -3544da2a a DS_MAGIC -e4514ffb a MULTIBOOT_CHECKSUM diff --git a/Dump/linecount.c b/Dump/linecount.c deleted file mode 100644 index ebb844c..0000000 --- a/Dump/linecount.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - int fd = 0x0; - int curcnt = 0x0; - int maxcnt = 0x0; - char c; - - if (argc < 2) { - printf("Error: No file specified\n"); - exit(0x0); - } - - fd = open(argv[1],O_RDONLY); - - if (fd == 0x0) { - printf("Error: Not a valid file: [%s]\n",argv[1]); - exit(0x0); - } - - curcnt = 0; - maxcnt = 0; - printf("File opened...\n"); - - while (read(fd,&c,1) != 0x0) { - if (c == 0x0C) { - printf("linefeed found!\n\tcurcnt = %i\n\tmaxcnt = %i\n", curcnt, maxcnt); - if (curcnt > maxcnt) - maxcnt = curcnt; - curcnt = 0; - } - else if (c == 0x0D) { - read(fd,&c,1); - if (c = 0x0A) - curcnt++; - printf("DDD"); - } - } - close(fd); - printf("Max line count is: %i\n", maxcnt); - return(0x0); - } diff --git a/Dump/linecount2.c b/Dump/linecount2.c deleted file mode 100644 index 8b17e94..0000000 --- a/Dump/linecount2.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - int fd = 0x0; - int curcnt = 0x1; - int maxcnt = 0x0; - char c; - - if (argc < 2) { - printf("Error: No file specified\n"); - exit(0x0); - } - - fd = open(argv[1],O_RDONLY); - - if (fd == 0x0) { - printf("Error: Not a valid file: [%s]\n",argv[1]); - exit(0x0); - } - - printf("File opened...\n"); - - while (read(fd,&c,1) != 0x0) { - if (c == 0x0C) { - if (curcnt > maxcnt) - maxcnt = curcnt; - curcnt = 1; - } - else if (c == 0x0A) - curcnt++; - } - close(fd); - printf("Max line count is: %i\n", maxcnt); - return(0x0); - } diff --git a/Dump/linecount3.c b/Dump/linecount3.c deleted file mode 100644 index 8b17e94..0000000 --- a/Dump/linecount3.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - int fd = 0x0; - int curcnt = 0x1; - int maxcnt = 0x0; - char c; - - if (argc < 2) { - printf("Error: No file specified\n"); - exit(0x0); - } - - fd = open(argv[1],O_RDONLY); - - if (fd == 0x0) { - printf("Error: Not a valid file: [%s]\n",argv[1]); - exit(0x0); - } - - printf("File opened...\n"); - - while (read(fd,&c,1) != 0x0) { - if (c == 0x0C) { - if (curcnt > maxcnt) - maxcnt = curcnt; - curcnt = 1; - } - else if (c == 0x0A) - curcnt++; - } - close(fd); - printf("Max line count is: %i\n", maxcnt); - return(0x0); - } diff --git a/Dump/ubix.elf b/Dump/ubix.elf deleted file mode 100644 index 0570158..0000000 --- a/Dump/ubix.elf +++ /dev/null Binary files differ diff --git a/Dump/ubix.flp b/Dump/ubix.flp deleted file mode 100644 index 750e409..0000000 --- a/Dump/ubix.flp +++ /dev/null Binary files differ diff --git a/Dump/ubix.img b/Dump/ubix.img deleted file mode 100644 index 3ca7f58..0000000 --- a/Dump/ubix.img +++ /dev/null Binary files differ diff --git a/Dump/ubthread.c b/Dump/ubthread.c deleted file mode 100644 index d0ab762..0000000 --- a/Dump/ubthread.c +++ /dev/null @@ -1,137 +0,0 @@ -/***************************************************************************************** - Copyright (c) 2002 The UbixOS Project - All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions, the following disclaimer and the list of authors. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions, the following -disclaimer and the list of authors in the documentation and/or other materials provided -with the distribution. Neither the name of the UbixOS Project nor the names of its -contributors may be used to endorse or promote products derived from this software -without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Log: ubthread.c,v $ - Revision 1.7 2004/04/13 16:16:44 reddawg - Changed our copyright, it is all now under a BSD-Style license - - - - $Id: ubthread.c,v 1.7 2004/04/13 16:16:44 reddawg Exp $ - -*****************************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -struct ubthread_cond_list *conds = 0x0; -struct ubthread_mutex_list *mutex = 0x0; - -kTask_t *ubthread_self() { - return(_current); - } - -int ubthread_cond_init(ubthread_cond_t *cond,const uInt32 attr) { - ubthread_cond_t ubcond = kmalloc(sizeof(struct ubthread_cond),sysID); - ubcond->id = (int)cond; - ubcond->locked = UNLOCKED; - *cond = ubcond; - return(0x0); - } - -int ubthread_mutex_init(ubthread_mutex_t *mutex,const uInt32 attr) { - ubthread_mutex_t ubmutex = kmalloc(sizeof(struct ubthread_mutex),sysID); - ubmutex->id = (int)mutex; - ubmutex->locked = UNLOCKED; - *mutex = ubmutex; - return(0x0); - } - -int ubthread_cond_destroy(ubthread_cond_t *cond) { - kfree(*cond); - *cond = 0x0; - return(0x0); - } - -int ubthread_mutex_destroy(ubthread_mutex_t *mutex) { - kfree(*mutex); - *mutex = 0x0; - return(0x0); - } - -int ubthread_create(kTask_t **thread,const uInt32 *attr,void *start_routine, void *arg) { - *thread = (void *)execThread((void *)start_routine,(uInt32)(kmalloc(0x4000,sysID)+0x4000),arg,"TCP/IP Thread"); - return(0x0); - } - -int ubthread_mutex_lock(ubthread_mutex_t *mutex) { - ubthread_mutex_t ubmutex = *mutex; - if (ubmutex->locked == LOCKED) { - kprintf("Mutex Already Lock By %x Trying To Be Relocked By %x\n",ubmutex->pid,_current->id); - } - while (ubmutex->locked == LOCKED); - ubmutex->locked = LOCKED; - ubmutex->pid = _current->id; - return(0x0); - } - -int ubthread_mutex_unlock(ubthread_mutex_t *mutex) { - ubthread_mutex_t ubmutex = *mutex; - if (ubmutex->pid == _current->id) { - ubmutex->locked = UNLOCKED; - return(0x0); - } - else { - kprintf("Trying To Unlock Mutex From No Locking Thread\n"); - ubmutex->locked = UNLOCKED; - return(-1); - } - } - -int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime) { - ubthread_cond_t ubcond = *cond; - ubthread_mutex_t ubmutex = *mutex; - uInt32 enterTime = systemVitals->sysUptime+20; - while (enterTime > systemVitals->sysUptime) { - if (ubcond->locked == UNLOCKED) break; - schedYield(); - } - ubmutex->locked = UNLOCKED; - return(0x0); - } - -int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex) { - ubthread_cond_t ubcond = *cond; - ubthread_mutex_t ubmutex = *mutex; - while (ubcond->locked == 0x0); - ubmutex->locked = UNLOCKED; - return(0x0); - } - -int ubthread_cond_signal(ubthread_cond_t *cond) { - ubthread_cond_t ubcond = *cond; - ubcond->locked = UNLOCKED; - return(0x0); - } - -/*** - END - ***/ diff --git a/bin/sh/mkbuiltins b/bin/sh/mkbuiltins old mode 100644 new mode 100755 diff --git a/bin/sh/tests/functional_test.sh b/bin/sh/tests/functional_test.sh old mode 100644 new mode 100755 diff --git a/contrib/jemalloc/FREEBSD-upgrade b/contrib/jemalloc/FREEBSD-upgrade old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/cat/t_cat.sh b/contrib/netbsd-tests/bin/cat/t_cat.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/cp/t_cp.sh b/contrib/netbsd-tests/bin/cp/t_cp.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/dd/t_dd.sh b/contrib/netbsd-tests/bin/dd/t_dd.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/df/t_df.sh b/contrib/netbsd-tests/bin/df/t_df.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/expr/t_expr.sh b/contrib/netbsd-tests/bin/expr/t_expr.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/pax/t_pax.sh b/contrib/netbsd-tests/bin/pax/t_pax.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/ps/t_ps.sh b/contrib/netbsd-tests/bin/ps/t_ps.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command b/contrib/netbsd-tests/bin/sh/dotcmd/scoped_command old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/dotcmd/t_dotcmd.sh b/contrib/netbsd-tests/bin/sh/dotcmd/t_dotcmd.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_arith.sh b/contrib/netbsd-tests/bin/sh/t_arith.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_cmdsub.sh b/contrib/netbsd-tests/bin/sh/t_cmdsub.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_evaltested.sh b/contrib/netbsd-tests/bin/sh/t_evaltested.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_exit.sh b/contrib/netbsd-tests/bin/sh/t_exit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_expand.sh b/contrib/netbsd-tests/bin/sh/t_expand.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_fsplit.sh b/contrib/netbsd-tests/bin/sh/t_fsplit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_here.sh b/contrib/netbsd-tests/bin/sh/t_here.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_option.sh b/contrib/netbsd-tests/bin/sh/t_option.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_redir.sh b/contrib/netbsd-tests/bin/sh/t_redir.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_redircloexec.sh b/contrib/netbsd-tests/bin/sh/t_redircloexec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_set_e.sh b/contrib/netbsd-tests/bin/sh/t_set_e.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_shift.sh b/contrib/netbsd-tests/bin/sh/t_shift.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_ulimit.sh b/contrib/netbsd-tests/bin/sh/t_ulimit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_varquote.sh b/contrib/netbsd-tests/bin/sh/t_varquote.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_varval.sh b/contrib/netbsd-tests/bin/sh/t_varval.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sh/t_wait.sh b/contrib/netbsd-tests/bin/sh/t_wait.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/sleep/t_sleep.sh b/contrib/netbsd-tests/bin/sleep/t_sleep.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/bin/tar/t_tar.sh b/contrib/netbsd-tests/bin/tar/t_tar.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh b/contrib/netbsd-tests/crypto/libcrypto/t_certs.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh b/contrib/netbsd-tests/crypto/libcrypto/t_ciphers.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh b/contrib/netbsd-tests/crypto/libcrypto/t_hashes.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh b/contrib/netbsd-tests/crypto/opencrypto/t_opencrypto.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/audio/t_pad.sh b/contrib/netbsd-tests/dev/audio/t_pad.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd.sh b/contrib/netbsd-tests/dev/cgd/t_cgd.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh b/contrib/netbsd-tests/dev/clock_subr/clock_subr_test_data_gen.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/dm/t_dm.sh b/contrib/netbsd-tests/dev/dm/t_dm.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/fss/t_fss.sh b/contrib/netbsd-tests/dev/fss/t_fss.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/md/t_md.sh b/contrib/netbsd-tests/dev/md/t_md.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/raidframe/t_raid.sh b/contrib/netbsd-tests/dev/raidframe/t_raid.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh b/contrib/netbsd-tests/dev/sysmon/t_swsensor.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/cd9660/t_high_ino_big_file.sh b/contrib/netbsd-tests/fs/cd9660/t_high_ino_big_file.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/ffs_common.sh b/contrib/netbsd-tests/fs/ffs/ffs_common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/quotas_common.sh b/contrib/netbsd-tests/fs/ffs/quotas_common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/t_clearquota.sh b/contrib/netbsd-tests/fs/ffs/t_clearquota.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/t_getquota.sh b/contrib/netbsd-tests/fs/ffs/t_getquota.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/t_miscquota.sh b/contrib/netbsd-tests/fs/ffs/t_miscquota.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh b/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/ffs/t_setquota.sh b/contrib/netbsd-tests/fs/ffs/t_setquota.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/nfs/t_rquotad.sh b/contrib/netbsd-tests/fs/nfs/t_rquotad.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh b/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_create.sh b/contrib/netbsd-tests/fs/tmpfs/t_create.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_devices.sh b/contrib/netbsd-tests/fs/tmpfs/t_devices.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_dots.sh b/contrib/netbsd-tests/fs/tmpfs/t_dots.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_exec.sh b/contrib/netbsd-tests/fs/tmpfs/t_exec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_link.sh b/contrib/netbsd-tests/fs/tmpfs/t_link.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mkdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_mkdir.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh b/contrib/netbsd-tests/fs/tmpfs/t_mknod.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_mount.sh b/contrib/netbsd-tests/fs/tmpfs/t_mount.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_pipes.sh b/contrib/netbsd-tests/fs/tmpfs/t_pipes.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_read_write.sh b/contrib/netbsd-tests/fs/tmpfs/t_read_write.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_readdir.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_remove.sh b/contrib/netbsd-tests/fs/tmpfs/t_remove.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_rename.sh b/contrib/netbsd-tests/fs/tmpfs/t_rename.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_rmdir.sh b/contrib/netbsd-tests/fs/tmpfs/t_rmdir.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_setattr.sh b/contrib/netbsd-tests/fs/tmpfs/t_setattr.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh b/contrib/netbsd-tests/fs/tmpfs/t_sizes.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_sockets.sh b/contrib/netbsd-tests/fs/tmpfs/t_sockets.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh b/contrib/netbsd-tests/fs/tmpfs/t_statvfs.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_symlink.sh b/contrib/netbsd-tests/fs/tmpfs/t_symlink.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_times.sh b/contrib/netbsd-tests/fs/tmpfs/t_times.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_trail_slash.sh b/contrib/netbsd-tests/fs/tmpfs/t_trail_slash.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_truncate.sh b/contrib/netbsd-tests/fs/tmpfs/t_truncate.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh b/contrib/netbsd-tests/fs/tmpfs/t_vnd.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh b/contrib/netbsd-tests/fs/tmpfs/t_vnode_leak.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/fs/zfs/t_zpool.sh b/contrib/netbsd-tests/fs/zfs/t_zpool.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/games/t_factor.sh b/contrib/netbsd-tests/games/t_factor.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/h_common.sh b/contrib/netbsd-tests/ipf/h_common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_bpf.sh b/contrib/netbsd-tests/ipf/t_bpf.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_filter_exec.sh b/contrib/netbsd-tests/ipf/t_filter_exec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_filter_parse.sh b/contrib/netbsd-tests/ipf/t_filter_parse.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_logging.sh b/contrib/netbsd-tests/ipf/t_logging.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_nat_exec.sh b/contrib/netbsd-tests/ipf/t_nat_exec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_nat_ipf_exec.sh b/contrib/netbsd-tests/ipf/t_nat_ipf_exec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_nat_parse.sh b/contrib/netbsd-tests/ipf/t_nat_parse.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/ipf/t_pools.sh b/contrib/netbsd-tests/ipf/t_pools.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/kernel/gen_t_subr_prf b/contrib/netbsd-tests/kernel/gen_t_subr_prf old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/kernel/t_ps_strings.sh b/contrib/netbsd-tests/kernel/t_ps_strings.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/kernel/t_umount.sh b/contrib/netbsd-tests/kernel/t_umount.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/kernel/t_umountstress.sh b/contrib/netbsd-tests/kernel/t_umountstress.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/csu/t_crt0.sh b/contrib/netbsd-tests/lib/csu/t_crt0.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/h_nonexec.sh b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/h_nonexec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/hash/t_hash.sh b/contrib/netbsd-tests/lib/libc/hash/t_hash.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/net/gen_ether_subr b/contrib/netbsd-tests/lib/libc/net/gen_ether_subr old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/net/getaddrinfo/t_getaddrinfo.sh b/contrib/netbsd-tests/lib/libc/net/getaddrinfo/t_getaddrinfo.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/net/t_hostent.sh b/contrib/netbsd-tests/lib/libc/net/t_hostent.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/net/t_nsdispatch.sh b/contrib/netbsd-tests/lib/libc/net/t_nsdispatch.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/net/t_protoent.sh b/contrib/netbsd-tests/lib/libc/net/t_protoent.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/net/t_servent.sh b/contrib/netbsd-tests/lib/libc/net/t_servent.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/regex/t_regex.sh b/contrib/netbsd-tests/lib/libc/regex/t_regex.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_atexit.sh b/contrib/netbsd-tests/lib/libc/stdlib/t_atexit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_getopt.sh b/contrib/netbsd-tests/lib/libc/stdlib/t_getopt.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libcurses/t_curses.sh b/contrib/netbsd-tests/lib/libcurses/t_curses.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libevent/t_event.sh b/contrib/netbsd-tests/lib/libevent/t_event.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libppath/plist_to_c b/contrib/netbsd-tests/lib/libppath/plist_to_c old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libpthread/t_atexit.sh b/contrib/netbsd-tests/lib/libpthread/t_atexit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libpthread/t_cancel.sh b/contrib/netbsd-tests/lib/libpthread/t_cancel.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libpthread/t_exit.sh b/contrib/netbsd-tests/lib/libpthread/t_exit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libpthread/t_resolv.sh b/contrib/netbsd-tests/lib/libpthread/t_resolv.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumpclient/t_exec.sh b/contrib/netbsd-tests/lib/librumpclient/t_exec.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumphijack/t_asyncio.sh b/contrib/netbsd-tests/lib/librumphijack/t_asyncio.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumphijack/t_config.sh b/contrib/netbsd-tests/lib/librumphijack/t_config.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumphijack/t_cwd.sh b/contrib/netbsd-tests/lib/librumphijack/t_cwd.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumphijack/t_sh.sh b/contrib/netbsd-tests/lib/librumphijack/t_sh.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/librumphijack/t_vfs.sh b/contrib/netbsd-tests/lib/librumphijack/t_vfs.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/lib/libsljit/t_sljit.sh b/contrib/netbsd-tests/lib/libsljit/t_sljit.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/libexec/ld.elf_so/t_df_1_noopen.sh b/contrib/netbsd-tests/libexec/ld.elf_so/t_df_1_noopen.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/libexec/ld.elf_so/t_dl_symver.sh b/contrib/netbsd-tests/libexec/ld.elf_so/t_dl_symver.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/modules/t_abi_uvm.sh b/contrib/netbsd-tests/modules/t_abi_uvm.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/modules/t_modload.sh b/contrib/netbsd-tests/modules/t_modload.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/arp/t_arp.sh b/contrib/netbsd-tests/net/arp/t_arp.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/arp/t_dad.sh b/contrib/netbsd-tests/net/arp/t_dad.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/carp/t_basic.sh b/contrib/netbsd-tests/net/carp/t_basic.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/fdpass/t_fdpass.sh b/contrib/netbsd-tests/net/fdpass/t_fdpass.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh b/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh b/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/icmp/t_ping2.sh b/contrib/netbsd-tests/net/icmp/t_ping2.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if/t_ifconf.sh b/contrib/netbsd-tests/net/if/t_ifconf.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if/t_ifconfig.sh b/contrib/netbsd-tests/net/if/t_ifconfig.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if_bridge/t_bridge.sh b/contrib/netbsd-tests/net/if_bridge/t_bridge.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if_gif/t_gif.sh b/contrib/netbsd-tests/net/if_gif/t_gif.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh b/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if_tap/t_tap.sh b/contrib/netbsd-tests/net/if_tap/t_tap.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if_tun/t_tun.sh b/contrib/netbsd-tests/net/if_tun/t_tun.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/if_vlan/t_vlan.sh b/contrib/netbsd-tests/net/if_vlan/t_vlan.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/in_cksum/t_in_cksum.sh b/contrib/netbsd-tests/net/in_cksum/t_in_cksum.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/mcast/t_mcast.sh b/contrib/netbsd-tests/net/mcast/t_mcast.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/mpls/t_ldp_regen.sh b/contrib/netbsd-tests/net/mpls/t_ldp_regen.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/mpls/t_mpls_fw.sh b/contrib/netbsd-tests/net/mpls/t_mpls_fw.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/mpls/t_mpls_fw6.sh b/contrib/netbsd-tests/net/mpls/t_mpls_fw6.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/mpls/t_mpls_fw64.sh b/contrib/netbsd-tests/net/mpls/t_mpls_fw64.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/mpls/t_rfc4182.sh b/contrib/netbsd-tests/net/mpls/t_rfc4182.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/ndp/t_dad.sh b/contrib/netbsd-tests/net/ndp/t_dad.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/ndp/t_ndp.sh b/contrib/netbsd-tests/net/ndp/t_ndp.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/ndp/t_ra.sh b/contrib/netbsd-tests/net/ndp/t_ra.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_forwarding.sh b/contrib/netbsd-tests/net/net/t_forwarding.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_ipaddress.sh b/contrib/netbsd-tests/net/net/t_ipaddress.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_ipv6address.sh b/contrib/netbsd-tests/net/net/t_ipv6address.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_mtudisc.sh b/contrib/netbsd-tests/net/net/t_mtudisc.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_mtudisc6.sh b/contrib/netbsd-tests/net/net/t_mtudisc6.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net/t_ping6_opts.sh b/contrib/netbsd-tests/net/net/t_ping6_opts.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/net_common.sh b/contrib/netbsd-tests/net/net_common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/npf/t_npf.sh b/contrib/netbsd-tests/net/npf/t_npf.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/route/t_change.sh b/contrib/netbsd-tests/net/route/t_change.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/route/t_flags.sh b/contrib/netbsd-tests/net/route/t_flags.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/route/t_flags6.sh b/contrib/netbsd-tests/net/route/t_flags6.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/net/route/t_route.sh b/contrib/netbsd-tests/net/route/t_route.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/rump/rumpkern/t_sp.sh b/contrib/netbsd-tests/rump/rumpkern/t_sp.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/rump/rumpnet/t_shmif.sh b/contrib/netbsd-tests/rump/rumpnet/t_shmif.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/fsck_ffs/quotas_common.sh b/contrib/netbsd-tests/sbin/fsck_ffs/quotas_common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/fsck_ffs/t_check_quotas.sh b/contrib/netbsd-tests/sbin/fsck_ffs/t_check_quotas.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/fsck_ffs/t_enable_quotas.sh b/contrib/netbsd-tests/sbin/fsck_ffs/t_enable_quotas.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/gpt/t_gpt.sh b/contrib/netbsd-tests/sbin/gpt/t_gpt.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/ifconfig/t_nonexistent.sh b/contrib/netbsd-tests/sbin/ifconfig/t_nonexistent.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/newfs/quotas_common.sh b/contrib/netbsd-tests/sbin/newfs/quotas_common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/newfs/t_enable_quotas.sh b/contrib/netbsd-tests/sbin/newfs/t_enable_quotas.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/newfs_msdos/t_create.sh b/contrib/netbsd-tests/sbin/newfs_msdos/t_create.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/resize_ffs/common.sh b/contrib/netbsd-tests/sbin/resize_ffs/common.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/resize_ffs/t_check.sh b/contrib/netbsd-tests/sbin/resize_ffs/t_check.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/resize_ffs/t_grow.sh b/contrib/netbsd-tests/sbin/resize_ffs/t_grow.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/resize_ffs/t_grow_swapped.sh b/contrib/netbsd-tests/sbin/resize_ffs/t_grow_swapped.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/resize_ffs/t_shrink.sh b/contrib/netbsd-tests/sbin/resize_ffs/t_shrink.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/resize_ffs/t_shrink_swapped.sh b/contrib/netbsd-tests/sbin/resize_ffs/t_shrink_swapped.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/route/t_missing.sh b/contrib/netbsd-tests/sbin/route/t_missing.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/sysctl/t_perm.sh b/contrib/netbsd-tests/sbin/sysctl/t_perm.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sbin/sysctl/t_sysctl.sh b/contrib/netbsd-tests/sbin/sysctl/t_sysctl.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/share/examples/t_asm.sh b/contrib/netbsd-tests/share/examples/t_asm.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/share/mk/t_lib.sh b/contrib/netbsd-tests/share/mk/t_lib.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/share/mk/t_own.sh b/contrib/netbsd-tests/share/mk/t_own.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/share/mk/t_prog.sh b/contrib/netbsd-tests/share/mk/t_prog.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/share/mk/t_test.sh b/contrib/netbsd-tests/share/mk/t_test.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sys/rc/h_args.sh b/contrib/netbsd-tests/sys/rc/h_args.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sys/rc/h_simple.sh b/contrib/netbsd-tests/sys/rc/h_simple.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/sys/rc/t_rc_d_cli.sh b/contrib/netbsd-tests/sys/rc/t_rc_d_cli.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/awk/t_awk.sh b/contrib/netbsd-tests/usr.bin/awk/t_awk.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/basename/t_basename.sh b/contrib/netbsd-tests/usr.bin/basename/t_basename.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/bzip2/t_bzip2.sh b/contrib/netbsd-tests/usr.bin/bzip2/t_bzip2.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/cc/t_hello.sh b/contrib/netbsd-tests/usr.bin/cc/t_hello.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/cmp/t_cmp.sh b/contrib/netbsd-tests/usr.bin/cmp/t_cmp.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/config/t_config.sh b/contrib/netbsd-tests/usr.bin/config/t_config.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/cut/t_cut.sh b/contrib/netbsd-tests/usr.bin/cut/t_cut.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/diff/t_diff.sh b/contrib/netbsd-tests/usr.bin/diff/t_diff.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh b/contrib/netbsd-tests/usr.bin/dirname/t_dirname.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/find/t_find.sh b/contrib/netbsd-tests/usr.bin/find/t_find.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/gdb/t_regress.sh b/contrib/netbsd-tests/usr.bin/gdb/t_regress.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/gzip/t_gzip.sh b/contrib/netbsd-tests/usr.bin/gzip/t_gzip.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/id/t_groups.sh b/contrib/netbsd-tests/usr.bin/id/t_groups.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/id/t_id.sh b/contrib/netbsd-tests/usr.bin/id/t_id.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/id/t_whoami.sh b/contrib/netbsd-tests/usr.bin/id/t_whoami.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/infocmp/t_terminfo.sh b/contrib/netbsd-tests/usr.bin/infocmp/t_terminfo.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/jot/t_jot.sh b/contrib/netbsd-tests/usr.bin/jot/t_jot.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/ld/t_script.sh b/contrib/netbsd-tests/usr.bin/ld/t_script.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/ld/t_section.sh b/contrib/netbsd-tests/usr.bin/ld/t_section.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/m4/t_m4.sh b/contrib/netbsd-tests/usr.bin/m4/t_m4.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/make/t_make.sh b/contrib/netbsd-tests/usr.bin/make/t_make.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh b/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/mkdep/t_mkdep.sh b/contrib/netbsd-tests/usr.bin/mkdep/t_mkdep.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/nbperf/h_nbperf.sh b/contrib/netbsd-tests/usr.bin/nbperf/h_nbperf.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/nbperf/t_nbperf.sh b/contrib/netbsd-tests/usr.bin/nbperf/t_nbperf.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh b/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/pr/t_basic.sh b/contrib/netbsd-tests/usr.bin/pr/t_basic.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/rump_server/t_disk.sh b/contrib/netbsd-tests/usr.bin/rump_server/t_disk.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/sdiff/t_sdiff.sh b/contrib/netbsd-tests/usr.bin/sdiff/t_sdiff.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/sed/t_sed.sh b/contrib/netbsd-tests/usr.bin/sed/t_sed.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/shmif_dumpbus/t_basic.sh b/contrib/netbsd-tests/usr.bin/shmif_dumpbus/t_basic.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/sort/t_sort.sh b/contrib/netbsd-tests/usr.bin/sort/t_sort.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/tmux/t_tmux.sh b/contrib/netbsd-tests/usr.bin/tmux/t_tmux.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/tr/t_basic.sh b/contrib/netbsd-tests/usr.bin/tr/t_basic.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh b/contrib/netbsd-tests/usr.bin/uniq/t_uniq.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh b/contrib/netbsd-tests/usr.bin/vmstat/t_vmstat.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh b/contrib/netbsd-tests/usr.bin/xlint/lint1/t_integration.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh b/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh b/contrib/netbsd-tests/usr.sbin/tcpdump/t_tcpdump.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh b/contrib/netbsd-tests/usr.sbin/traceroute/t_traceroute.sh old mode 100644 new mode 100755 diff --git a/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh b/contrib/netbsd-tests/usr.sbin/useradd/t_useradd.sh old mode 100644 new mode 100755 diff --git a/debug/sysctl.c b/debug/sysctl.c deleted file mode 100644 index 9a3f143..0000000 --- a/debug/sysctl.c +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include -#include -#include -#include - -int mib[CTL_MAXNAME]; -//int mib[2]; -size_t len; -char *p; - -static int name2oid(const char *name, int *oidp); - -int main() { - printf("SYSCTL\n"); - - - mib[0] = 1; - mib[1] = 1; - - sysctl(mib, 2, NULL, &len, NULL, 0); - p = malloc(len); - sysctl(mib, 2, p, &len, NULL, 0); - - printf("[%s]\n", p); - - mib[0] = 1; - mib[1] = 10; - - sysctl(mib, 2, NULL, &len, NULL, 0); - p = malloc(len); - sysctl(mib, 2, p, &len, NULL, 0); - - printf("[%s]\n", p); - - mib[0] = 1; - mib[1] = 2; - - sysctl(mib, 2, NULL, &len, NULL, 0); - p = malloc(len); - sysctl(mib, 2, p, &len, NULL, 0); - - printf("[%s]\n", p); - - mib[0] = 1; - mib[1] = 4; - - sysctl(mib, 2, NULL, &len, NULL, 0); - p = malloc(len); - sysctl(mib, 2, p, &len, NULL, 0); - - printf("[%s]\n", p); - - mib[0] = 6; - mib[1] = 1; - - sysctl(mib, 2, NULL, &len, NULL, 0); - p = malloc(len); - sysctl(mib, 2, p, &len, NULL, 0); - - printf("[%s]\n", p); - - size_t j; - - j = name2oid("vm.overcommit", mib); - - printf("j:[%i]\n", j); - - for (int i = 0; i < j; i++) - printf("[%i]", mib[i]); - printf("\n"); -} - -static int name2oid(const char *name, int *oidp) -{ - int oid[2]; - int i; - size_t j; - - oid[0] = 0; - oid[1] = 3; - - j = CTL_MAXNAME * sizeof(int); - i = sysctl(oid, 2, oidp, &j, name, strlen(name)); - if (i < 0) - return (i); - j /= sizeof(int); - return (j); -} diff --git a/include/fs/common/crc32.h b/include/fs/common/crc32.h deleted file mode 100644 index 43e722b..0000000 --- a/include/fs/common/crc32.h +++ /dev/null @@ -1,13 +0,0 @@ -/*- - * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or - * code or tables extracted from it, as desired without restriction. - * - * $FreeBSD: releng/10.2/sys/boot/common/crc32.h 213136 2010-09-24 19:49:12Z pjd $ - */ - -#ifndef _CRC32_H_ -#define _CRC32_H_ - -uint32_t crc32(const void *buf, size_t size); - -#endif /* !_CRC32_H_ */ diff --git a/include/fs/common/gpt.h b/include/fs/common/gpt.h deleted file mode 100644 index 673f0c9..0000000 --- a/include/fs/common/gpt.h +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * Copyright (c) 2010 Pawel Jakub Dawidek - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: releng/10.2/sys/boot/common/gpt.h 213136 2010-09-24 19:49:12Z pjd $ - */ - -#ifndef _GPT_H_ -#define _GPT_H_ - -#include -#include -#include - -#define bcopy(src, dst, len) memcpy((dst), (src), (len)) -#define bzero(buf, size) memset((buf), 0, (size)) -#define bcmp(b1, b2, len) (memcmp((b1), (b2), (len)) != 0) - -//MrOlsen (2016-01-11) NOTE: Fix This Temm Place To Store These Defines -#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ -#define DEV_BSIZE (1< - */ - - int gptread(const uuid_t *uuid, struct device_interface *devInfo, char *buf); - int gptfind(const uuid_t *uuid, struct device_interface *devInfo, int part); - void gptbootfailed(struct device_interface *devInfo); - -#endif /* !_GPT_H_ */ diff --git a/include/fs/devfs/devfs.h b/include/fs/devfs/devfs.h deleted file mode 100644 index 03e0955..0000000 --- a/include/fs/devfs/devfs.h +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEVFS_DEVFS_H -#define _DEVFS_DEVFS_H - -#include -#include - -struct devfs_devices { - struct devfs_devices *next; - struct devfs_devices *prev; - uInt8 devType; - uInt16 devMajor; - uInt16 devMinor; - char devName[32]; -}; - -struct devfs_info { - struct devfs_devices *deviceList; -}; - -int devfs_init(); -int devfs_makeNode(char *name, uInt8 type, uInt16 major, uInt16 minor); -/* - int devfs_open(char *file,fileDescriptor *fd); - void devFSInit(struct mountPoints *mp); - int devfs_read(fileDescriptor *fd,char *data,long offset,long size); - int devfs_write(fileDescriptor *fd,char *data,long offset,long size); - */ - -#endif - -/*** - $Log: devfs.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:38 reddawg - no message - - Revision 1.5 2004/07/21 10:02:09 reddawg - devfs: renamed functions - device system: renamed functions - fdc: fixed a few potential bugs and cleaned up some unused variables - strol: fixed definition - endtask: made it print out freepage debug info - kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost - ld: fixed a pointer conversion - file: cleaned up a few unused variables - sched: broke task deletion - kprintf: fixed ogPrintf definition - - Revision 1.4 2004/07/14 12:17:52 reddawg - devfs: devFSEnable to devfs_init - Changed Startup Routines - - Revision 1.3 2004/05/21 14:54:41 reddawg - Cleaned up - - - END - ***/ diff --git a/include/fs/msdos_fs.h b/include/fs/msdos_fs.h deleted file mode 100644 index 0248157..0000000 --- a/include/fs/msdos_fs.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _FS_MSDOS_FS_H -#define _FS_MSDOS_FS_H - -/* - * MS-DOS file system in-core superblock data - */ - -struct msdos_sb_info { - unsigned short cluster_size; /* sectors/cluster */ - unsigned char fats, fat_bits; /* number of FATs, FAT bits (12 or 16) */ - unsigned short fat_start, fat_length; /* FAT start & length (sec.) */ - unsigned short dir_start, dir_entries; /* root dir start & entries */ - unsigned short data_start; /* first data sector */ - unsigned long clusters; /* number of clusters */ - uid_t fs_uid; - gid_t fs_gid; - int quiet; /* fake successful chmods and chowns */ - unsigned short fs_umask; - unsigned char name_check; /* r = relaxed, n = normal, s = strict */ - unsigned char conversion; /* b = binary, t = text, a = auto */ - struct wait_queue *fat_wait; - int fat_lock; - int prev_free; /* previously returned free cluster number */ - int free_clusters; /* -1 if undefined */ -}; - -/* - * MS-DOS file system inode data in memory - */ - -struct msdos_inode_info { - int i_start; /* first cluster or 0 */ - int i_attrs; /* unused attribute bits */ - int i_busy; /* file is either deleted but still open, or - inconsistent (mkdir) */ - struct inode *i_depend; /* pointer to inode that depends on the - current inode */ - struct inode *i_old; /* pointer to the old inode this inode - depends on */ - int i_binary; /* file contains non-text data */ -}; - -#endif diff --git a/include/fs/pipe_fs.h b/include/fs/pipe_fs.h deleted file mode 100644 index e7431ea..0000000 --- a/include/fs/pipe_fs.h +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _FS_PIPE_FS_H -#define _FS_PIPE_FS_H - -struct pipe_inode_info { - struct wait_queue *wait; - char *base; - unsigned int start; - unsigned int len; - unsigned int lock; - unsigned int rd_openers; - unsigned int wr_openers; - unsigned int readers; - unsigned int writers; -}; - -#define PIPE_WAIT(inode) ((inode).u.pipe_i.wait) -#define PIPE_BASE(inode) ((inode).u.pipe_i.base) -#define PIPE_START(inode) ((inode).u.pipe_i.start) -#define PIPE_LEN(inode) ((inode).u.pipe_i.len) -#define PIPE_RD_OPENERS(inode) ((inode).u.pipe_i.rd_openers) -#define PIPE_WR_OPENERS(inode) ((inode).u.pipe_i.wr_openers) -#define PIPE_READERS(inode) ((inode).u.pipe_i.readers) -#define PIPE_WRITERS(inode) ((inode).u.pipe_i.writers) -#define PIPE_LOCK(inode) ((inode).u.pipe_i.lock) -#define PIPE_SIZE(inode) PIPE_LEN(inode) - -#define PIPE_EMPTY(inode) (PIPE_SIZE(inode)==0) -#define PIPE_FULL(inode) (PIPE_SIZE(inode)==PIPE_BUF) -#define PIPE_FREE(inode) (PIPE_BUF - PIPE_LEN(inode)) -#define PIPE_END(inode) ((PIPE_START(inode)+PIPE_LEN(inode))&\ - (PIPE_BUF-1)) -#define PIPE_MAX_RCHUNK(inode) (PIPE_BUF - PIPE_START(inode)) -#define PIPE_MAX_WCHUNK(inode) (PIPE_BUF - PIPE_END(inode)) - -#endif diff --git a/include/fs/ubixfs/dirCache.h b/include/fs/ubixfs/dirCache.h deleted file mode 100644 index 710904c..0000000 --- a/include/fs/ubixfs/dirCache.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXFS_DIRCACHE_H -#define _UBIXFS_DIRCACHE_H - -/* #include "ubixfs.h" */ -#include - -struct cacheNode { - char * name; - struct cacheNode * prev; - struct cacheNode * next; - struct cacheNode * parent; - struct cacheNode * fileListHead; - struct cacheNode * fileListTail; - void * info; - int * size; - int present; - int dirty; - uInt32 * startCluster; - uInt16 * attributes; - uInt16 * permissions; -}; -/* cacheNode */ - -struct cacheNode * ubixfs_cacheFind(struct cacheNode *, char *); -struct cacheNode * ubixfs_cacheNew(const char *); -void ubixfs_cacheDelete(struct cacheNode **); -struct cacheNode * ubixfs_cacheAdd(struct cacheNode *, struct cacheNode *); - -#endif /* END _UBIXFS_DIRCACHE_H */ diff --git a/include/fs/ubixfs/ubixfs.h b/include/fs/ubixfs/ubixfs.h deleted file mode 100644 index cab2be5..0000000 --- a/include/fs/ubixfs/ubixfs.h +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXFS_UBIXFS_H -#define _UBIXFS_UBIXFS_H - -#include -#include -#include -#include -#include - -#define UBIXFS_BLOCKSIZE_BYTES blockSize*512 -#define UBIXFS_ALIGN(size) (size + ((((size) % (UBIXFS_BLOCKSIZE_BYTES)) == 0)? 0 : ((UBIXFS_BLOCKSIZE_BYTES) - ((size) % (UBIXFS_BLOCKSIZE_BYTES))))) - -#define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */ -#define MAXUBIXPARTITIONS 16 -#define blockSize 8 - -#define EOBC -1 - -#define typeFile 1 -#define typeContainer 2 -#define typeDirectory 4 -#define typeDeleted 8 - -/* Start */ -struct directoryList { - char dirName[256]; - char *dirCache; - uInt32 dirBlock; - struct directoryList *next; - struct directoryList *prev; -}; - -typedef struct directoryList * dirList_t; - -dirList_t ubixFSLoadDir(char *); -/* End */ - -//Partition Information -struct ubixDiskLabel { - uInt32 magicNum; - uInt32 magicNum2; - uInt16 driveType; - uInt16 numPartitions; - struct ubixPartitions { //the partition table - uInt32 pSize; //number of sectors in partition - uInt32 pOffset; //starting sector - uInt32 pFsSize; //filesystem basic fragment size - uInt32 pBatSize; //BAT size - uInt8 pFsType; //filesystem type, see below - uInt8 pFrag; //filesystem fragments per block - } partitions[MAXUBIXPARTITIONS]; -}; - -struct partitionInformation { - uInt32 size; //Size In Sectors - uInt32 startSector; //Base Sector Of Partition - uInt32 blockAllocationTable; //Base Sector Of BAT - uInt32 rootDirectory; //Base Sector Of Root Directory -}; - -//Block Allocation Table Entry -struct blockAllocationTableEntry { - long attributes; //Block Attributes - long realSector; //Real Sector - long nextBlock; //Sector Of Next Block - long reserved; //Reserved -}; - -//UbixFS Directory Entry -struct directoryEntry { - uInt32 startCluster; //Starting Cluster Of File - uInt32 size; //Size Of File - uInt32 creationDate; //Date Created - uInt32 lastModified; //Date Last Modified - uInt32 uid; //UID Of Owner - uInt32 gid; //GID Of Owner - uInt16 attributes; //Files Attributes - uInt16 permissions; //Files Permissions - char fileName[256]; //File Name -}; - -struct bootSect { - uInt8 jmp[4]; - uInt8 id[6]; - uInt16 version; - uInt16 tmp; - uInt16 fsStart; - uInt16 tmp2; - uInt32 krnl_start; - uInt BytesPerSector; - uInt SectersPerTrack; - uInt TotalHeads; - uInt32 TotalSectors; - uInt8 code[479]; -}; - -struct ubixFSInfo { - struct blockAllocationTableEntry *blockAllocationTable; - struct cacheNode * dirCache; - uInt32 batEntries; - uInt32 rootDir; -}; -/* ubixFSInfo */ - -int readFile(char *file); -int writeFileByte(int ch, fileDescriptor_t *fd, long offset); -//int openFileUbixFS(char *file,fileDescriptor_t *fd); -int getFreeBlocks(int count, fileDescriptor_t *fd); -//extern struct ubixDiskLabel *diskLabel; - -//Good Functions -//void initUbixFS(struct mountPoints *mp); - -int readUbixFS(fileDescriptor_t *fd, char *data, uInt32, long size); -int writeUbixFS(fileDescriptor_t *fd, char *data, long offset, long size); -void syncBat(struct vfs_mountPoint *mp); -int freeBlocks(int block, fileDescriptor_t *fd); -int addDirEntry(struct directoryEntry *dir, fileDescriptor_t *fd); -void ubixFSUnlink(char *path, struct vfs_mountPoint *mp); -int ubixFSmkDir(char *dir, fileDescriptor_t *fd); - -int ubixfs_init(); -int ubixfs_initialize(); -void ubixfs_thread(); - -#endif /* END _UBIXFS_UBIXFS_H */ diff --git a/include/fs/ufs/ffs.h b/include/fs/ufs/ffs.h deleted file mode 100644 index d8996f1..0000000 --- a/include/fs/ufs/ffs.h +++ /dev/null @@ -1,44 +0,0 @@ -/***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of - conditions, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id: ffs.h 79 2016-01-11 16:21:27Z reddawg $ - -*****************************************************************************************/ - -#ifndef _FFS_H -#define _FFS_H - -#include -#include -#include - -int ffs_read(fileDescriptor_t *,char *,uint32_t,long); - -#endif - -/*** - END - ***/ - diff --git a/include/fs/ufs/ffs/fs.h b/include/fs/ufs/ffs/fs.h deleted file mode 100644 index 7a50ab5..0000000 --- a/include/fs/ufs/ffs/fs.h +++ /dev/null @@ -1,778 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)fs.h 8.13 (Berkeley) 3/21/95 - * $FreeBSD: releng/11.1/sys/ufs/ffs/fs.h 298804 2016-04-29 20:43:51Z pfg $ - */ - -#ifndef _UFS_FFS_FS_H_ -#define _UFS_FFS_FS_H_ - -#include -#include - -/* - * Each disk drive contains some number of filesystems. - * A filesystem consists of a number of cylinder groups. - * Each cylinder group has inodes and data. - * - * A filesystem is described by its super-block, which in turn - * describes the cylinder groups. The super-block is critical - * data and is replicated in each cylinder group to protect against - * catastrophic loss. This is done at `newfs' time and the critical - * super-block data does not change, so the copies need not be - * referenced further unless disaster strikes. - * - * For filesystem fs, the offsets of the various blocks of interest - * are given in the super block as: - * [fs->fs_sblkno] Super-block - * [fs->fs_cblkno] Cylinder group block - * [fs->fs_iblkno] Inode blocks - * [fs->fs_dblkno] Data blocks - * The beginning of cylinder group cg in fs, is given by - * the ``cgbase(fs, cg)'' macro. - * - * Depending on the architecture and the media, the superblock may - * reside in any one of four places. For tiny media where every block - * counts, it is placed at the very front of the partition. Historically, - * UFS1 placed it 8K from the front to leave room for the disk label and - * a small bootstrap. For UFS2 it got moved to 64K from the front to leave - * room for the disk label and a bigger bootstrap, and for really piggy - * systems we check at 256K from the front if the first three fail. In - * all cases the size of the superblock will be SBLOCKSIZE. All values are - * given in byte-offset form, so they do not imply a sector size. The - * SBLOCKSEARCH specifies the order in which the locations should be searched. - */ -#define SBLOCK_FLOPPY 0 -#define SBLOCK_UFS1 8192 -#define SBLOCK_UFS2 65536 -#define SBLOCK_PIGGY 262144 -#define SBLOCKSIZE 8192 -#define SBLOCKSEARCH \ - { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } - -/* - * Max number of fragments per block. This value is NOT tweakable. - */ -#define MAXFRAG 8 - -/* - * Addresses stored in inodes are capable of addressing fragments - * of `blocks'. File system blocks of at most size MAXBSIZE can - * be optionally broken into 2, 4, or 8 pieces, each of which is - * addressable; these pieces may be DEV_BSIZE, or some multiple of - * a DEV_BSIZE unit. - * - * Large files consist of exclusively large data blocks. To avoid - * undue wasted disk space, the last data block of a small file may be - * allocated as only as many fragments of a large block as are - * necessary. The filesystem format retains only a single pointer - * to such a fragment, which is a piece of a single large block that - * has been divided. The size of such a fragment is determinable from - * information in the inode, using the ``blksize(fs, ip, lbn)'' macro. - * - * The filesystem records space availability at the fragment level; - * to determine block availability, aligned fragments are examined. - */ - -/* - * MINBSIZE is the smallest allowable block size. - * In order to insure that it is possible to create files of size - * 2^32 with only two levels of indirection, MINBSIZE is set to 4096. - * MINBSIZE must be big enough to hold a cylinder group block, - * thus changes to (struct cg) must keep its size within MINBSIZE. - * Note that super blocks are always of size SBLOCKSIZE, - * and that both SBLOCKSIZE and MAXBSIZE must be >= MINBSIZE. - */ -#define MINBSIZE 4096 - -/* - * The path name on which the filesystem is mounted is maintained - * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in - * the super block for this name. - */ -#define MAXMNTLEN 468 - -/* - * The volume name for this filesystem is maintained in fs_volname. - * MAXVOLLEN defines the length of the buffer allocated. - */ -#define MAXVOLLEN 32 - -/* - * There is a 128-byte region in the superblock reserved for in-core - * pointers to summary information. Originally this included an array - * of pointers to blocks of struct csum; now there are just a few - * pointers and the remaining space is padded with fs_ocsp[]. - * - * NOCSPTRS determines the size of this padding. One pointer (fs_csp) - * is taken away to point to a contiguous array of struct csum for - * all cylinder groups; a second (fs_maxcluster) points to an array - * of cluster sizes that is computed as cylinder groups are inspected, - * and the third points to an array that tracks the creation of new - * directories. A fourth pointer, fs_active, is used when creating - * snapshots; it points to a bitmap of cylinder groups for which the - * free-block bitmap has changed since the snapshot operation began. - */ -#define NOCSPTRS ((128 / sizeof(void *)) - 4) - -/* - * A summary of contiguous blocks of various sizes is maintained - * in each cylinder group. Normally this is set by the initial - * value of fs_maxcontig. To conserve space, a maximum summary size - * is set by FS_MAXCONTIG. - */ -#define FS_MAXCONTIG 16 - -/* - * MINFREE gives the minimum acceptable percentage of filesystem - * blocks which may be free. If the freelist drops below this level - * only the superuser may continue to allocate blocks. This may - * be set to 0 if no reserve of free blocks is deemed necessary, - * however throughput drops by fifty percent if the filesystem - * is run at between 95% and 100% full; thus the minimum default - * value of fs_minfree is 5%. However, to get good clustering - * performance, 10% is a better choice. hence we use 10% as our - * default value. With 10% free space, fragmentation is not a - * problem, so we choose to optimize for time. - */ -#define MINFREE 8 -#define DEFAULTOPT FS_OPTTIME - -/* - * Grigoriy Orlov has done some extensive work to fine - * tune the layout preferences for directories within a filesystem. - * His algorithm can be tuned by adjusting the following parameters - * which tell the system the average file size and the average number - * of files per directory. These defaults are well selected for typical - * filesystems, but may need to be tuned for odd cases like filesystems - * being used for squid caches or news spools. - */ -#define AVFILESIZ 16384 /* expected average file size */ -#define AFPDIR 64 /* expected number of files per directory */ - -/* - * The maximum number of snapshot nodes that can be associated - * with each filesystem. This limit affects only the number of - * snapshot files that can be recorded within the superblock so - * that they can be found when the filesystem is mounted. However, - * maintaining too many will slow the filesystem performance, so - * having this limit is a good idea. - */ -#define FSMAXSNAP 20 - -/* - * Used to identify special blocks in snapshots: - * - * BLK_NOCOPY - A block that was unallocated at the time the snapshot - * was taken, hence does not need to be copied when written. - * BLK_SNAP - A block held by another snapshot that is not needed by this - * snapshot. When the other snapshot is freed, the BLK_SNAP entries - * are converted to BLK_NOCOPY. These are needed to allow fsck to - * identify blocks that are in use by other snapshots (which are - * expunged from this snapshot). - */ -#define BLK_NOCOPY ((ufs2_daddr_t)(1)) -#define BLK_SNAP ((ufs2_daddr_t)(2)) - -/* - * Sysctl values for the fast filesystem. - */ -#define FFS_ADJ_REFCNT 1 /* adjust inode reference count */ -#define FFS_ADJ_BLKCNT 2 /* adjust inode used block count */ -#define FFS_BLK_FREE 3 /* free range of blocks in map */ -#define FFS_DIR_FREE 4 /* free specified dir inodes in map */ -#define FFS_FILE_FREE 5 /* free specified file inodes in map */ -#define FFS_SET_FLAGS 6 /* set filesystem flags */ -#define FFS_ADJ_NDIR 7 /* adjust number of directories */ -#define FFS_ADJ_NBFREE 8 /* adjust number of free blocks */ -#define FFS_ADJ_NIFREE 9 /* adjust number of free inodes */ -#define FFS_ADJ_NFFREE 10 /* adjust number of free frags */ -#define FFS_ADJ_NUMCLUSTERS 11 /* adjust number of free clusters */ -#define FFS_SET_CWD 12 /* set current directory */ -#define FFS_SET_DOTDOT 13 /* set inode number for ".." */ -#define FFS_UNLINK 14 /* remove a name in the filesystem */ -#define FFS_SET_INODE 15 /* update an on-disk inode */ -#define FFS_SET_BUFOUTPUT 16 /* set buffered writing on descriptor */ -#define FFS_MAXID 16 /* number of valid ffs ids */ - -/* - * Command structure passed in to the filesystem to adjust filesystem values. - */ -#define FFS_CMD_VERSION 0x19790518 /* version ID */ -struct fsck_cmd { - int32_t version; /* version of command structure */ - int32_t handle; /* reference to filesystem to be changed */ - int64_t value; /* inode or block number to be affected */ - int64_t size; /* amount or range to be adjusted */ - int64_t spare; /* reserved for future use */ -}; - -/* - * Per cylinder group information; summarized in blocks allocated - * from first cylinder group data blocks. These blocks have to be - * read in from fs_csaddr (size fs_cssize) in addition to the - * super block. - */ -struct csum { - int32_t cs_ndir; /* number of directories */ - int32_t cs_nbfree; /* number of free blocks */ - int32_t cs_nifree; /* number of free inodes */ - int32_t cs_nffree; /* number of free frags */ -}; -struct csum_total { - int64_t cs_ndir; /* number of directories */ - int64_t cs_nbfree; /* number of free blocks */ - int64_t cs_nifree; /* number of free inodes */ - int64_t cs_nffree; /* number of free frags */ - int64_t cs_numclusters; /* number of free clusters */ - int64_t cs_spare[3]; /* future expansion */ -}; - -/* - * Super block for an FFS filesystem. - */ -struct fs { - int32_t fs_firstfield; /* historic filesystem linked list, */ - int32_t fs_unused_1; /* used for incore super blocks */ - int32_t fs_sblkno; /* offset of super-block in filesys */ - int32_t fs_cblkno; /* offset of cyl-block in filesys */ - int32_t fs_iblkno; /* offset of inode-blocks in filesys */ - int32_t fs_dblkno; /* offset of first data after cg */ - int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */ - int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */ - int32_t fs_old_time; /* last time written */ - int32_t fs_old_size; /* number of blocks in fs */ - int32_t fs_old_dsize; /* number of data blocks in fs */ - u_int32_t fs_ncg; /* number of cylinder groups */ - int32_t fs_bsize; /* size of basic blocks in fs */ - int32_t fs_fsize; /* size of frag blocks in fs */ - int32_t fs_frag; /* number of frags in a block in fs */ -/* these are configuration parameters */ - int32_t fs_minfree; /* minimum percentage of free blocks */ - int32_t fs_old_rotdelay; /* num of ms for optimal next block */ - int32_t fs_old_rps; /* disk revolutions per second */ -/* these fields can be computed from the others */ - int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ - int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ - int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ - int32_t fs_fshift; /* ``numfrags'' calc number of frags */ -/* these are configuration parameters */ - int32_t fs_maxcontig; /* max number of contiguous blks */ - int32_t fs_maxbpg; /* max number of blks per cyl group */ -/* these fields can be computed from the others */ - int32_t fs_fragshift; /* block to frag shift */ - int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ - int32_t fs_sbsize; /* actual size of super block */ - int32_t fs_spare1[2]; /* old fs_csmask */ - /* old fs_csshift */ - int32_t fs_nindir; /* value of NINDIR */ - u_int32_t fs_inopb; /* value of INOPB */ - int32_t fs_old_nspf; /* value of NSPF */ -/* yet another configuration parameter */ - int32_t fs_optim; /* optimization preference, see below */ - int32_t fs_old_npsect; /* # sectors/track including spares */ - int32_t fs_old_interleave; /* hardware sector interleave */ - int32_t fs_old_trackskew; /* sector 0 skew, per track */ - int32_t fs_id[2]; /* unique filesystem id */ -/* sizes determined by number of cylinder groups and their sizes */ - int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */ - int32_t fs_cssize; /* size of cyl grp summary area */ - int32_t fs_cgsize; /* cylinder group size */ - int32_t fs_spare2; /* old fs_ntrak */ - int32_t fs_old_nsect; /* sectors per track */ - int32_t fs_old_spc; /* sectors per cylinder */ - int32_t fs_old_ncyl; /* cylinders in filesystem */ - int32_t fs_old_cpg; /* cylinders per group */ - u_int32_t fs_ipg; /* inodes per group */ - int32_t fs_fpg; /* blocks per group * fs_frag */ -/* this data must be re-computed after crashes */ - struct csum fs_old_cstotal; /* cylinder summary information */ -/* these fields are cleared at mount time */ - int8_t fs_fmod; /* super block modified flag */ - int8_t fs_clean; /* filesystem is clean flag */ - int8_t fs_ronly; /* mounted read-only flag */ - int8_t fs_old_flags; /* old FS_ flags */ - u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ - u_char fs_volname[MAXVOLLEN]; /* volume name */ - u_int64_t fs_swuid; /* system-wide uid */ - int32_t fs_pad; /* due to alignment of fs_swuid */ -/* these fields retain the current block allocation info */ - int32_t fs_cgrotor; /* last cg searched */ - void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ - u_int8_t *fs_contigdirs; /* (u) # of contig. allocated dirs */ - struct csum *fs_csp; /* (u) cg summary info buffer */ - int32_t *fs_maxcluster; /* (u) max cluster in each cyl group */ - u_int *fs_active; /* (u) used by snapshots to track fs */ - int32_t fs_old_cpc; /* cyl per cycle in postbl */ - int32_t fs_maxbsize; /* maximum blocking factor permitted */ - int64_t fs_unrefs; /* number of unreferenced inodes */ - int64_t fs_providersize; /* size of underlying GEOM provider */ - int64_t fs_metaspace; /* size of area reserved for metadata */ - int64_t fs_sparecon64[14]; /* old rotation block list head */ - int64_t fs_sblockloc; /* byte offset of standard superblock */ - struct csum_total fs_cstotal; /* (u) cylinder summary information */ - ufs_time_t fs_time; /* last time written */ - int64_t fs_size; /* number of blocks in fs */ - int64_t fs_dsize; /* number of data blocks in fs */ - ufs2_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */ - int64_t fs_pendingblocks; /* (u) blocks being freed */ - u_int32_t fs_pendinginodes; /* (u) inodes being freed */ - uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ - u_int32_t fs_avgfilesize; /* expected average file size */ - u_int32_t fs_avgfpdir; /* expected # of files per directory */ - int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ - ufs_time_t fs_mtime; /* Last mount or fsck time. */ - int32_t fs_sujfree; /* SUJ free list */ - int32_t fs_sparecon32[23]; /* reserved for future constants */ - int32_t fs_flags; /* see FS_ flags below */ - int32_t fs_contigsumsize; /* size of cluster summary array */ - int32_t fs_maxsymlinklen; /* max length of an internal symlink */ - int32_t fs_old_inodefmt; /* format of on-disk inodes */ - u_int64_t fs_maxfilesize; /* maximum representable file size */ - int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ - int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ - int32_t fs_state; /* validate fs_clean field */ - int32_t fs_old_postblformat; /* format of positional layout tables */ - int32_t fs_old_nrpos; /* number of rotational positions */ - int32_t fs_spare5[2]; /* old fs_postbloff */ - /* old fs_rotbloff */ - int32_t fs_magic; /* magic number */ -}; - -/* Sanity checking. */ -#ifdef CTASSERT -CTASSERT(sizeof(struct fs) == 1376); -#endif - -/* - * Filesystem identification - */ -#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast filesystem magic number */ -#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast filesystem magic number */ -#define FS_BAD_MAGIC 0x19960408 /* UFS incomplete newfs magic number */ -#define FS_OKAY 0x7c269d38 /* superblock checksum */ -#define FS_42INODEFMT -1 /* 4.2BSD inode format */ -#define FS_44INODEFMT 2 /* 4.4BSD inode format */ - -/* - * Preference for optimization. - */ -#define FS_OPTTIME 0 /* minimize allocation time */ -#define FS_OPTSPACE 1 /* minimize disk fragmentation */ - -/* - * Filesystem flags. - * - * The FS_UNCLEAN flag is set by the kernel when the filesystem was - * mounted with fs_clean set to zero. The FS_DOSOFTDEP flag indicates - * that the filesystem should be managed by the soft updates code. - * Note that the FS_NEEDSFSCK flag is set and cleared only by the - * fsck utility. It is set when background fsck finds an unexpected - * inconsistency which requires a traditional foreground fsck to be - * run. Such inconsistencies should only be found after an uncorrectable - * disk error. A foreground fsck will clear the FS_NEEDSFSCK flag when - * it has successfully cleaned up the filesystem. The kernel uses this - * flag to enforce that inconsistent filesystems be mounted read-only. - * The FS_INDEXDIRS flag when set indicates that the kernel maintains - * on-disk auxiliary indexes (such as B-trees) for speeding directory - * accesses. Kernels that do not support auxiliary indices clear the - * flag to indicate that the indices need to be rebuilt (by fsck) before - * they can be used. - * - * FS_ACLS indicates that POSIX.1e ACLs are administratively enabled - * for the file system, so they should be loaded from extended attributes, - * observed for access control purposes, and be administered by object - * owners. FS_NFS4ACLS indicates that NFSv4 ACLs are administratively - * enabled. This flag is mutually exclusive with FS_ACLS. FS_MULTILABEL - * indicates that the TrustedBSD MAC Framework should attempt to back MAC - * labels into extended attributes on the file system rather than maintain - * a single mount label for all objects. - */ -#define FS_UNCLEAN 0x0001 /* filesystem not clean at mount */ -#define FS_DOSOFTDEP 0x0002 /* filesystem using soft dependencies */ -#define FS_NEEDSFSCK 0x0004 /* filesystem needs sync fsck before mount */ -#define FS_SUJ 0x0008 /* Filesystem using softupdate journal */ -#define FS_ACLS 0x0010 /* file system has POSIX.1e ACLs enabled */ -#define FS_MULTILABEL 0x0020 /* file system is MAC multi-label */ -#define FS_GJOURNAL 0x0040 /* gjournaled file system */ -#define FS_FLAGS_UPDATED 0x0080 /* flags have been moved to new location */ -#define FS_NFS4ACLS 0x0100 /* file system has NFSv4 ACLs enabled */ -#define FS_INDEXDIRS 0x0200 /* kernel supports indexed directories */ -#define FS_TRIM 0x0400 /* issue BIO_DELETE for deleted blocks */ - -/* - * Macros to access bits in the fs_active array. - */ -#define ACTIVECGNUM(fs, cg) ((fs)->fs_active[(cg) / (NBBY * sizeof(int))]) -#define ACTIVECGOFF(cg) (1 << ((cg) % (NBBY * sizeof(int)))) -#define ACTIVESET(fs, cg) do { \ - if ((fs)->fs_active) \ - ACTIVECGNUM((fs), (cg)) |= ACTIVECGOFF((cg)); \ -} while (0) -#define ACTIVECLEAR(fs, cg) do { \ - if ((fs)->fs_active) \ - ACTIVECGNUM((fs), (cg)) &= ~ACTIVECGOFF((cg)); \ -} while (0) - -/* - * The size of a cylinder group is calculated by CGSIZE. The maximum size - * is limited by the fact that cylinder groups are at most one block. - * Its size is derived from the size of the maps maintained in the - * cylinder group and the (struct cg) size. - */ -#define CGSIZE(fs) \ - /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \ - /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \ - /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \ - /* inode map */ howmany((fs)->fs_ipg, NBBY) + \ - /* block map */ howmany((fs)->fs_fpg, NBBY) +\ - /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \ - /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \ - /* cluster map */ howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY))) - -/* - * The minimal number of cylinder groups that should be created. - */ -#define MINCYLGRPS 4 - -/* - * Convert cylinder group to base address of its global summary info. - */ -#define fs_cs(fs, indx) fs_csp[indx] - -/* - * Cylinder group block for a filesystem. - */ -#define CG_MAGIC 0x090255 -struct cg { - int32_t cg_firstfield; /* historic cyl groups linked list */ - int32_t cg_magic; /* magic number */ - int32_t cg_old_time; /* time last written */ - u_int32_t cg_cgx; /* we are the cgx'th cylinder group */ - int16_t cg_old_ncyl; /* number of cyl's this cg */ - int16_t cg_old_niblk; /* number of inode blocks this cg */ - u_int32_t cg_ndblk; /* number of data blocks this cg */ - struct csum cg_cs; /* cylinder summary information */ - u_int32_t cg_rotor; /* position of last used block */ - u_int32_t cg_frotor; /* position of last used frag */ - u_int32_t cg_irotor; /* position of last used inode */ - u_int32_t cg_frsum[MAXFRAG]; /* counts of available frags */ - int32_t cg_old_btotoff; /* (int32) block totals per cylinder */ - int32_t cg_old_boff; /* (u_int16) free block positions */ - u_int32_t cg_iusedoff; /* (u_int8) used inode map */ - u_int32_t cg_freeoff; /* (u_int8) free block map */ - u_int32_t cg_nextfreeoff; /* (u_int8) next available space */ - u_int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */ - u_int32_t cg_clusteroff; /* (u_int8) free cluster map */ - u_int32_t cg_nclusterblks; /* number of clusters this cg */ - u_int32_t cg_niblk; /* number of inode blocks this cg */ - u_int32_t cg_initediblk; /* last initialized inode */ - u_int32_t cg_unrefs; /* number of unreferenced inodes */ - int32_t cg_sparecon32[2]; /* reserved for future use */ - ufs_time_t cg_time; /* time last written */ - int64_t cg_sparecon64[3]; /* reserved for future use */ - u_int8_t cg_space[1]; /* space for cylinder group maps */ -/* actually longer */ -}; - -/* - * Macros for access to cylinder group array structures - */ -#define cg_chkmagic(cgp) ((cgp)->cg_magic == CG_MAGIC) -#define cg_inosused(cgp) \ - ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_iusedoff)) -#define cg_blksfree(cgp) \ - ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_freeoff)) -#define cg_clustersfree(cgp) \ - ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_clusteroff)) -#define cg_clustersum(cgp) \ - ((int32_t *)((uintptr_t)(cgp) + (cgp)->cg_clustersumoff)) - -/* - * Turn filesystem block numbers into disk block addresses. - * This maps filesystem blocks to device size blocks. - */ -#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb) -#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) - -/* - * Cylinder group macros to locate things in cylinder groups. - * They calc filesystem addresses of cylinder group data structures. - */ -#define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c)) -#define cgdata(fs, c) (cgdmin(fs, c) + (fs)->fs_metaspace) /* data zone */ -#define cgmeta(fs, c) (cgdmin(fs, c)) /* meta data */ -#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ -#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ -#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ -#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ -#define cgstart(fs, c) \ - ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : \ - (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask)))) - -/* - * Macros for handling inode numbers: - * inode number to filesystem block offset. - * inode number to cylinder group number. - * inode number to filesystem block address. - */ -#define ino_to_cg(fs, x) (((ino_t)(x)) / (fs)->fs_ipg) -#define ino_to_fsba(fs, x) \ - ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) + \ - (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs)))))) -#define ino_to_fsbo(fs, x) (((ino_t)(x)) % INOPB(fs)) - -/* - * Give cylinder group number for a filesystem block. - * Give cylinder group block number for a filesystem block. - */ -#define dtog(fs, d) ((d) / (fs)->fs_fpg) -#define dtogd(fs, d) ((d) % (fs)->fs_fpg) - -/* - * Extract the bits for a block from a map. - * Compute the cylinder and rotational position of a cyl block addr. - */ -#define blkmap(fs, map, loc) \ - (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) - -/* - * The following macros optimize certain frequently calculated - * quantities by using shifts and masks in place of divisions - * modulos and multiplications. - */ -#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ - ((loc) & (fs)->fs_qbmask) -#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ - ((loc) & (fs)->fs_qfmask) -#define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \ - (((off_t)(frag)) << (fs)->fs_fshift) -#define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \ - (((off_t)(blk)) << (fs)->fs_bshift) -/* Use this only when `blk' is known to be small, e.g., < NDADDR. */ -#define smalllblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \ - ((blk) << (fs)->fs_bshift) -#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \ - ((loc) >> (fs)->fs_bshift) -#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \ - ((loc) >> (fs)->fs_fshift) -#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ - (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask) -#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ - (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) -#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \ - ((frags) >> (fs)->fs_fragshift) -#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \ - ((blks) << (fs)->fs_fragshift) -#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \ - ((fsb) & ((fs)->fs_frag - 1)) -#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ - ((fsb) &~ ((fs)->fs_frag - 1)) - -/* - * Determine the number of available frags given a - * percentage to hold in reserve. - */ -#define freespace(fs, percentreserved) \ - (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ - (fs)->fs_cstotal.cs_nffree - \ - (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100)) - -/* - * Determining the size of a file block in the filesystem. - */ -#define blksize(fs, ip, lbn) \ - (((lbn) >= NDADDR || (ip)->i_size >= smalllblktosize(fs, (lbn) + 1)) \ - ? (fs)->fs_bsize \ - : (fragroundup(fs, blkoff(fs, (ip)->i_size)))) -#define sblksize(fs, size, lbn) \ - (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \ - ? (fs)->fs_bsize \ - : (fragroundup(fs, blkoff(fs, (size))))) - -/* - * Number of indirects in a filesystem block. - */ -#define NINDIR(fs) ((fs)->fs_nindir) - -/* - * Indirect lbns are aligned on NDADDR addresses where single indirects - * are the negated address of the lowest lbn reachable, double indirects - * are this lbn - 1 and triple indirects are this lbn - 2. This yields - * an unusual bit order to determine level. - */ -static inline int -lbn_level(ufs_lbn_t lbn) -{ - if (lbn >= 0) - return 0; - switch (lbn & 0x3) { - case 0: - return (0); - case 1: - break; - case 2: - return (2); - case 3: - return (1); - default: - break; - } - return (-1); -} - -static inline ufs_lbn_t -lbn_offset(struct fs *fs, int level) -{ - ufs_lbn_t res; - - for (res = 1; level > 0; level--) - res *= NINDIR(fs); - return (res); -} - -/* - * Number of inodes in a secondary storage block/fragment. - */ -#define INOPB(fs) ((fs)->fs_inopb) -#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) - -/* - * Softdep journal record format. - */ - -#define JOP_ADDREF 1 /* Add a reference to an inode. */ -#define JOP_REMREF 2 /* Remove a reference from an inode. */ -#define JOP_NEWBLK 3 /* Allocate a block. */ -#define JOP_FREEBLK 4 /* Free a block or a tree of blocks. */ -#define JOP_MVREF 5 /* Move a reference from one off to another. */ -#define JOP_TRUNC 6 /* Partial truncation record. */ -#define JOP_SYNC 7 /* fsync() complete record. */ - -#define JREC_SIZE 32 /* Record and segment header size. */ - -#define SUJ_MIN (4 * 1024 * 1024) /* Minimum journal size */ -#define SUJ_MAX (32 * 1024 * 1024) /* Maximum journal size */ -#define SUJ_FILE ".sujournal" /* Journal file name */ - -/* - * Size of the segment record header. There is at most one for each disk - * block in the journal. The segment header is followed by an array of - * records. fsck depends on the first element in each record being 'op' - * and the second being 'ino'. Segments may span multiple disk blocks but - * the header is present on each. - */ -struct jsegrec { - uint64_t jsr_seq; /* Our sequence number */ - uint64_t jsr_oldest; /* Oldest valid sequence number */ - uint16_t jsr_cnt; /* Count of valid records */ - uint16_t jsr_blocks; /* Count of device bsize blocks. */ - uint32_t jsr_crc; /* 32bit crc of the valid space */ - ufs_time_t jsr_time; /* timestamp for mount instance */ -}; - -/* - * Reference record. Records a single link count modification. - */ -struct jrefrec { - uint32_t jr_op; - uint32_t jr_ino; - uint32_t jr_parent; - uint16_t jr_nlink; - uint16_t jr_mode; - int64_t jr_diroff; - uint64_t jr_unused; -}; - -/* - * Move record. Records a reference moving within a directory block. The - * nlink is unchanged but we must search both locations. - */ -struct jmvrec { - uint32_t jm_op; - uint32_t jm_ino; - uint32_t jm_parent; - uint16_t jm_unused; - int64_t jm_oldoff; - int64_t jm_newoff; -}; - -/* - * Block record. A set of frags or tree of blocks starting at an indirect are - * freed or a set of frags are allocated. - */ -struct jblkrec { - uint32_t jb_op; - uint32_t jb_ino; - ufs2_daddr_t jb_blkno; - ufs_lbn_t jb_lbn; - uint16_t jb_frags; - uint16_t jb_oldfrags; - uint32_t jb_unused; -}; - -/* - * Truncation record. Records a partial truncation so that it may be - * completed at check time. Also used for sync records. - */ -struct jtrncrec { - uint32_t jt_op; - uint32_t jt_ino; - int64_t jt_size; - uint32_t jt_extsize; - uint32_t jt_pad[3]; -}; - -union jrec { - struct jsegrec rec_jsegrec; - struct jrefrec rec_jrefrec; - struct jmvrec rec_jmvrec; - struct jblkrec rec_jblkrec; - struct jtrncrec rec_jtrncrec; -}; - -#ifdef CTASSERT -CTASSERT(sizeof(struct jsegrec) == JREC_SIZE); -CTASSERT(sizeof(struct jrefrec) == JREC_SIZE); -CTASSERT(sizeof(struct jmvrec) == JREC_SIZE); -CTASSERT(sizeof(struct jblkrec) == JREC_SIZE); -CTASSERT(sizeof(struct jtrncrec) == JREC_SIZE); -CTASSERT(sizeof(union jrec) == JREC_SIZE); -#endif - -extern int inside[], around[]; -extern u_char *fragtbl[]; - -/* - * IOCTLs used for filesystem write suspension. - */ -#define UFSSUSPEND _IOW('U', 1, fsid_t) -#define UFSRESUME _IO('U', 2) - -#endif diff --git a/include/fs/ufs/ufs.h b/include/fs/ufs/ufs.h deleted file mode 100644 index 8667d28..0000000 --- a/include/fs/ufs/ufs.h +++ /dev/null @@ -1,279 +0,0 @@ -/***************************************************************************************** - Copyright (c) 2002-2004, 2017 The UbixOS Project - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of - conditions, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id: ufs.h 141 2016-01-17 02:05:18Z reddawg $ - - *****************************************************************************************/ - -#ifndef _UFS_H -#define _UFS_H - -#include -#include - -#define DT_REG 8 -#define MAXNAMLEN 255 -#define ROOTINO ((ino_t)2) -#define DT_DIR 4 -#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ -#define DEV_BSIZE (1<fs_nindir) - -/* - * Cylinder group macros to locate things in cylinder groups. - * They calc filesystem addresses of cylinder group data structures. - */ -#define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c)) -#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ -#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ -#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ -#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ -#define cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask)))) - -#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb) -#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) - -/* - * Macros for handling inode numbers: - * inode number to filesystem block offset. - * inode number to cylinder group number. - * inode number to filesystem block address. - */ -#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg) -#define ino_to_fsba(fs, x) ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs)))))) -#define ino_to_fsbo(fs, x) ((x) % INOPB(fs)) - -#define blkoff(fs, loc) ((loc) & (fs)->fs_qbmask) // calculates (loc % fs->fs_bsize) -#define lblkno(fs, loc) ((loc) >> (fs)->fs_bshift) // calculates (loc / fs->fs_bsize) -#define fragroundup(fs, size) (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) // calculates roundup(size, fs->fs_fsize) - -#define sblksize(fs, size, lbn) (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) ? (fs)->fs_bsize : (fragroundup(fs, blkoff(fs, (size))))) - -typedef int32_t ufs1_daddr_t; -typedef int64_t ufs2_daddr_t; -typedef int64_t ufs_lbn_t; -typedef int64_t ufs_time_t; -// MrOlsen (2016-01-16) NOTE: typedef __int64_t daddr_t; - -struct dirent { - __uint32_t d_fileno; /* file number of entry */ - __uint16_t d_reclen; /* length of this record */ - __uint8_t d_type; /* file type, see below */ - __uint8_t d_namlen; /* length of string in d_name */ - char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ -}; - -#define NXADDR 2 /* External addresses in inode. */ -#define NDADDR 12 /* Direct addresses in inode. */ -#define NIADDR 3 /* Indirect addresses in inode. */ - -struct ufs2_dinode { - u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ - int16_t di_nlink; /* 2: File link count. */ - uint32_t di_uid; /* 4: File owner. */ - uint32_t di_gid; /* 8: File group. */ - uint32_t di_blksize; /* 12: Inode blocksize. */ - u_int64_t di_size; /* 16: File byte count. */ - u_int64_t di_blocks; /* 24: Bytes actually held. */ - ufs_time_t di_atime; /* 32: Last access time. */ - ufs_time_t di_mtime; /* 40: Last modified time. */ - ufs_time_t di_ctime; /* 48: Last inode change time. */ - ufs_time_t di_birthtime; /* 56: Inode creation time. */ - int32_t di_mtimensec; /* 64: Last modified time. */ - int32_t di_atimensec; /* 68: Last access time. */ - int32_t di_ctimensec; /* 72: Last inode change time. */ - int32_t di_birthnsec; /* 76: Inode creation time. */ - int32_t di_gen; /* 80: Generation number. */ - uint32_t di_kernflags; /* 84: Kernel flags. */ - uint32_t di_flags; /* 88: Status flags (chflags). */ - int32_t di_extsize; /* 92: External attributes block. */ - ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */ - ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */ - ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */ - int64_t di_spare[3]; /* 232: Reserved; currently unused */ -}; - -struct ufs1_dinode { - u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ - int16_t di_nlink; /* 2: File link count. */ - union { - u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ - } di_u; - u_int64_t di_size; /* 8: File byte count. */ - int32_t di_atime; /* 16: Last access time. */ - int32_t di_atimensec; /* 20: Last access time. */ - int32_t di_mtime; /* 24: Last modified time. */ - int32_t di_mtimensec; /* 28: Last modified time. */ - int32_t di_ctime; /* 32: Last inode change time. */ - int32_t di_ctimensec; /* 36: Last inode change time. */ - ufs1_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ - ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ - uint32_t di_flags; /* 100: Status flags (chflags). */ - int32_t di_blocks; /* 104: Blocks actually held. */ - int32_t di_gen; /* 108: Generation number. */ - uint32_t di_uid; /* 112: File owner. */ - uint32_t di_gid; /* 116: File group. */ - int32_t di_spare[2]; /* 120: Reserved; currently unused */ -}; - -struct csum { - int32_t cs_ndir; /* number of directories */ - int32_t cs_nbfree; /* number of free blocks */ - int32_t cs_nifree; /* number of free inodes */ - int32_t cs_nffree; /* number of free frags */ -}; -struct csum_total { - int64_t cs_ndir; /* number of directories */ - int64_t cs_nbfree; /* number of free blocks */ - int64_t cs_nifree; /* number of free inodes */ - int64_t cs_nffree; /* number of free frags */ - int64_t cs_numclusters; /* number of free clusters */ - int64_t cs_spare[3]; /* future expansion */ -}; - -struct fs { - int32_t fs_firstfield; /* historic filesystem linked list, */ - int32_t fs_unused_1; /* used for incore super blocks */ - int32_t fs_sblkno; /* offset of super-block in filesys */ - int32_t fs_cblkno; /* offset of cyl-block in filesys */ - int32_t fs_iblkno; /* offset of inode-blocks in filesys */ - int32_t fs_dblkno; /* offset of first data after cg */ - int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */ - int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */ - int32_t fs_old_time; /* last time written */ - int32_t fs_old_size; /* number of blocks in fs */ - int32_t fs_old_dsize; /* number of data blocks in fs */ - int32_t fs_ncg; /* number of cylinder groups */ - int32_t fs_bsize; /* size of basic blocks in fs */ - int32_t fs_fsize; /* size of frag blocks in fs */ - int32_t fs_frag; /* number of frags in a block in fs */ - /* these are configuration parameters */ - int32_t fs_minfree; /* minimum percentage of free blocks */ - int32_t fs_old_rotdelay; /* num of ms for optimal next block */ - int32_t fs_old_rps; /* disk revolutions per second */ - /* these fields can be computed from the others */ - int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ - int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ - int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ - int32_t fs_fshift; /* ``numfrags'' calc number of frags */ - /* these are configuration parameters */ - int32_t fs_maxcontig; /* max number of contiguous blks */ - int32_t fs_maxbpg; /* max number of blks per cyl group */ - /* these fields can be computed from the others */ - int32_t fs_fragshift; /* block to frag shift */ - int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ - int32_t fs_sbsize; /* actual size of super block */ - int32_t fs_spare1[2]; /* old fs_csmask */ - /* old fs_csshift */ - int32_t fs_nindir; /* value of NINDIR */ - int32_t fs_inopb; /* value of INOPB */ - int32_t fs_old_nspf; /* value of NSPF */ - /* yet another configuration parameter */ - int32_t fs_optim; /* optimization preference, see below */ - int32_t fs_old_npsect; /* # sectors/track including spares */ - int32_t fs_old_interleave; /* hardware sector interleave */ - int32_t fs_old_trackskew; /* sector 0 skew, per track */ - int32_t fs_id[2]; /* unique filesystem id */ - /* sizes determined by number of cylinder groups and their sizes */ - int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */ - int32_t fs_cssize; /* size of cyl grp summary area */ - int32_t fs_cgsize; /* cylinder group size */ - int32_t fs_spare2; /* old fs_ntrak */ - int32_t fs_old_nsect; /* sectors per track */ - int32_t fs_old_spc; /* sectors per cylinder */ - int32_t fs_old_ncyl; /* cylinders in filesystem */ - int32_t fs_old_cpg; /* cylinders per group */ - int32_t fs_ipg; /* inodes per group */ - int32_t fs_fpg; /* blocks per group * fs_frag */ - /* this data must be re-computed after crashes */ - struct csum fs_old_cstotal; /* cylinder summary information */ - /* these fields are cleared at mount time */ - int8_t fs_fmod; /* super block modified flag */ - int8_t fs_clean; /* filesystem is clean flag */ - int8_t fs_ronly; /* mounted read-only flag */ - int8_t fs_old_flags; /* old FS_ flags */ - u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ - u_char fs_volname[MAXVOLLEN]; /* volume name */ - u_int64_t fs_swuid; /* system-wide uid */ - int32_t fs_pad; /* due to alignment of fs_swuid */ - /* these fields retain the current block allocation info */ - int32_t fs_cgrotor; /* last cg searched */ - void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ - u_int8_t *fs_contigdirs; /* (u) # of contig. allocated dirs */ - struct csum *fs_csp; /* (u) cg summary info buffer */ - int32_t *fs_maxcluster; /* (u) max cluster in each cyl group */ - u_int *fs_active; /* (u) used by snapshots to track fs */ - int32_t fs_old_cpc; /* cyl per cycle in postbl */ - int32_t fs_maxbsize; /* maximum blocking factor permitted */ - int64_t fs_sparecon64[17]; /* old rotation block list head */ - int64_t fs_sblockloc; /* byte offset of standard superblock */ - struct csum_total fs_cstotal; /* (u) cylinder summary information */ - ufs_time_t fs_time; /* last time written */ - int64_t fs_size; /* number of blocks in fs */ - int64_t fs_dsize; /* number of data blocks in fs */ - ufs2_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */ - int64_t fs_pendingblocks; /* (u) blocks being freed */ - int32_t fs_pendinginodes; /* (u) inodes being freed */ - int32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ - int32_t fs_avgfilesize; /* expected average file size */ - int32_t fs_avgfpdir; /* expected # of files per directory */ - int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ - int32_t fs_sparecon32[26]; /* reserved for future constants */ - int32_t fs_flags; /* see FS_ flags below */ - int32_t fs_contigsumsize; /* size of cluster summary array */ - int32_t fs_maxsymlinklen; /* max length of an internal symlink */ - int32_t fs_old_inodefmt; /* format of on-disk inodes */ - u_int64_t fs_maxfilesize; /* maximum representable file size */ - int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ - int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ - int32_t fs_state; /* validate fs_clean field */ - int32_t fs_old_postblformat; /* format of positional layout tables */ - int32_t fs_old_nrpos; /* number of rotational positions */ - int32_t fs_spare5[2]; /* old fs_postbloff */ - /* old fs_rotbloff */ - int32_t fs_magic; /* magic number */ -}; - -int ufs_init(); -int ufs_initialize(); - -#endif - -/*** - END - ***/ diff --git a/include/fs/ufs/ufs/ufs_extern.h b/include/fs/ufs/ufs/ufs_extern.h deleted file mode 100644 index 72235fe..0000000 --- a/include/fs/ufs/ufs/ufs_extern.h +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ufs_extern.h 8.10 (Berkeley) 5/14/95 - * $FreeBSD: releng/11.1/sys/ufs/ufs/ufs_extern.h 262678 2014-03-02 02:52:34Z pfg $ - */ - -#ifndef _UFS_UFS_EXTERN_H_ -#define _UFS_UFS_EXTERN_H_ - -struct componentname; -struct direct; -struct indir; -struct inode; -struct mount; -struct thread; -struct sockaddr; -struct ucred; -struct ufid; -struct vfsconf; -struct vnode; -struct vop_bmap_args; -struct vop_cachedlookup_args; -struct vop_generic_args; -struct vop_inactive_args; -struct vop_reclaim_args; - -extern struct vop_vector ufs_fifoops; -extern struct vop_vector ufs_vnodeops; - -int ufs_bmap(struct vop_bmap_args *); -int ufs_bmaparray(struct vnode *, ufs2_daddr_t, ufs2_daddr_t *, - struct buf *, int *, int *); -int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); -int ufs_checkpath(ino_t, ino_t, struct inode *, struct ucred *, ino_t *); -void ufs_dirbad(struct inode *, doff_t, char *); -int ufs_dirbadentry(struct vnode *, struct direct *, int); -int ufs_dirempty(struct inode *, ino_t, struct ucred *); -int ufs_extread(struct vop_read_args *); -int ufs_extwrite(struct vop_write_args *); -void ufs_makedirentry(struct inode *, struct componentname *, - struct direct *); -int ufs_direnter(struct vnode *, struct vnode *, struct direct *, - struct componentname *, struct buf *, int); -int ufs_dirremove(struct vnode *, struct inode *, int, int); -int ufs_dirrewrite(struct inode *, struct inode *, ino_t, int, int); -int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *, - ino_t *); -int ufs_getlbns(struct vnode *, ufs2_daddr_t, struct indir *, int *); -int ufs_inactive(struct vop_inactive_args *); -int ufs_init(struct vfsconf *); -void ufs_itimes(struct vnode *vp); -int ufs_lookup(struct vop_cachedlookup_args *); -void ufs_prepare_reclaim(struct vnode *vp); -int ufs_readdir(struct vop_readdir_args *); -int ufs_reclaim(struct vop_reclaim_args *); -void ffs_snapgone(struct inode *); -vfs_root_t ufs_root; -int ufs_uninit(struct vfsconf *); -int ufs_vinit(struct mount *, struct vop_vector *, struct vnode **); - -#include -SYSCTL_DECL(_vfs_ufs); - -/* - * Soft update function prototypes. - */ -int softdep_setup_directory_add(struct buf *, struct inode *, off_t, - ino_t, struct buf *, int); -void softdep_change_directoryentry_offset(struct buf *, struct inode *, - caddr_t, caddr_t, caddr_t, int); -void softdep_setup_remove(struct buf *,struct inode *, struct inode *, int); -void softdep_setup_directory_change(struct buf *, struct inode *, - struct inode *, ino_t, int); -void softdep_change_linkcnt(struct inode *); -int softdep_slowdown(struct vnode *); -void softdep_setup_create(struct inode *, struct inode *); -void softdep_setup_dotdot_link(struct inode *, struct inode *); -void softdep_setup_link(struct inode *, struct inode *); -void softdep_setup_mkdir(struct inode *, struct inode *); -void softdep_setup_rmdir(struct inode *, struct inode *); -void softdep_setup_unlink(struct inode *, struct inode *); -void softdep_revert_create(struct inode *, struct inode *); -void softdep_revert_link(struct inode *, struct inode *); -void softdep_revert_mkdir(struct inode *, struct inode *); -void softdep_revert_rmdir(struct inode *, struct inode *); - -/* - * Flags to low-level allocation routines. The low 16-bits are reserved - * for IO_ flags from vnode.h. - * - * Note: The general vfs code typically limits the sequential heuristic - * count to 127. See sequential_heuristic() in kern/vfs_vnops.c - */ -#define BA_CLRBUF 0x00010000 /* Clear invalid areas of buffer. */ -#define BA_METAONLY 0x00020000 /* Return indirect block buffer. */ -#define BA_UNMAPPED 0x00040000 /* Do not mmap resulted buffer. */ -#define BA_SEQMASK 0x7F000000 /* Bits holding seq heuristic. */ -#define BA_SEQSHIFT 24 -#define BA_SEQMAX 0x7F - -#endif /* !_UFS_UFS_EXTERN_H_ */ diff --git a/include/fs/ufs/ufs/ufsmount.h b/include/fs/ufs/ufs/ufsmount.h deleted file mode 100644 index 64a0032..0000000 --- a/include/fs/ufs/ufs/ufsmount.h +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95 - * $FreeBSD: releng/11.1/sys/ufs/ufs/ufsmount.h 306553 2016-10-01 09:19:43Z kib $ - */ - -#ifndef _UFS_UFS_UFSMOUNT_H_ -#define _UFS_UFS_UFSMOUNT_H_ - -/* - * Arguments to mount UFS-based filesystems - */ -struct ufs_args { - char *fspec; /* block special device to mount */ - //struct oexport_args export; /* network export information */ -}; - -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_UFSMNT); -#endif - -struct buf; -struct inode; -struct nameidata; -struct taskqueue; -struct timeval; -struct ucred; -struct uio; -struct vnode; -struct ufs_extattr_per_mount; -struct jblocks; -struct inodedep; - -//TAILQ_HEAD(inodedeplst, inodedep); -//LIST_HEAD(bmsafemaphd, bmsafemap); - -/* This structure describes the UFS specific mount structure data. */ -struct ufsmount { - struct mount *um_mountp; /* filesystem vfs structure */ - struct cdev *um_dev; /* device mounted */ - struct g_consumer *um_cp; - struct bufobj *um_bo; /* Buffer cache object */ - struct vnode *um_devvp; /* block device mounted vnode */ - u_long um_fstype; /* type of filesystem */ - struct fs *um_fs; /* pointer to superblock */ - //struct ufs_extattr_per_mount um_extattr; /* extended attrs */ - u_long um_nindir; /* indirect ptrs per block */ - u_long um_bptrtodb; /* indir ptr to disk block */ - u_long um_seqinc; /* inc between seq blocks */ - //struct mtx um_lock; /* Protects ufsmount & fs */ - pid_t um_fsckpid; /* PID permitted fsck sysctls */ - struct mount_softdeps *um_softdep; /* softdep mgmt structure */ - struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ - struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */ - time_t um_btime[MAXQUOTAS]; /* block quota time limit */ - time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ - char um_qflags[MAXQUOTAS]; /* quota specific flags */ - int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */ - int um_candelete; /* devvp supports TRIM */ - int um_writesuspended; /* suspension in progress */ - u_int um_trim_inflight; - struct taskqueue *um_trim_tq; - int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, - int, struct buf **); - int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **); - int (*um_truncate)(struct vnode *, off_t, int, struct ucred *); - int (*um_update)(struct vnode *, int); - int (*um_valloc)(struct vnode *, int, struct ucred *, - struct vnode **); - int (*um_vfree)(struct vnode *, ino_t, int); - void (*um_ifree)(struct ufsmount *, struct inode *); - int (*um_rdonly)(struct inode *); - void (*um_snapgone)(struct inode *); -}; - -#define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff) -#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd) -#define UFS_TRUNCATE(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd) -#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb) -#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd) -#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) -#define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) -#define UFS_RDONLY(aa) (ITOUMP(aa)->um_rdonly(aa)) -#define UFS_SNAPGONE(aa) (ITOUMP(aa)->um_snapgone(aa)) - -#define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) -#define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) -#define UFS_MTX(aa) (&(aa)->um_lock) - -/* - * Filesystem types - */ -#define UFS1 1 -#define UFS2 2 - -/* - * Flags describing the state of quotas. - */ -#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */ -#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */ -#define QTF_64BIT 0x04 /* 64-bit quota file */ - -/* Convert mount ptr to ufsmount ptr. */ -#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data)) -#define UFSTOVFS(ump) (ump)->um_mountp - -/* - * Macros to access filesystem parameters in the ufsmount structure. - * Used by ufs_bmap. - */ -#define MNINDIR(ump) ((ump)->um_nindir) -#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb) -#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc) - -#endif diff --git a/include/isa/8259.h b/include/isa/8259.h deleted file mode 100644 index df36487..0000000 --- a/include/isa/8259.h +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_8259_H -#define _ISA_8259_H - -#include - -#define mPic 0x20 // I/O for master PIC -#define mImr 0x21 // I/O for master IMR -#define sPic 0xA0 // I/O for slave PIC -#define sImr 0xA1 // I/O for slace IMR -#define eoi 0x20 // EOI command -#define icw1 0x11 // Cascade, Edge triggered -#define icw4 0x01 // 8088 mode -#define mVec 0x68 // Vector for master -#define sVec 0x70 // Vector for slave -#define ocw3Irr 0x0A // Read IRR -#define ocw3Isr 0x0B // Read ISR - -int i8259_init(); -void irqEnable(uInt16 irqNo); -void irqDisable(uInt16 irqNo); - -#endif - -/*** - $Log: 8259.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:39 reddawg - no message - - Revision 1.4 2004/07/09 13:20:08 reddawg - Oh yeah duh you can not name functions with numbers - - Revision 1.3 2004/07/09 13:14:29 reddawg - 8259: changed init8259 to 8259_init - Adjusted Startup Routines - - Revision 1.2 2004/05/21 14:57:16 reddawg - Cleaned up - - END - ***/ diff --git a/include/isa/atkbd.h b/include/isa/atkbd.h deleted file mode 100644 index c1e41d9..0000000 --- a/include/isa/atkbd.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_ATKBD_H -#define _ISA_ATKBD_H - -#define shiftKey 1 -#define controlKey 2 -#define altKey 4 -#define ledNumlock 2 -#define ledScrolllock 1 -#define ledCapslock 4 - -int atkbd_init(); -void atkbd_isr(); - -void keyboardHandler(); -void setLED(); - - -#endif /* END _ISA_ATKBD_H */ diff --git a/include/isa/fdc.h b/include/isa/fdc.h deleted file mode 100644 index fcc33b8..0000000 --- a/include/isa/fdc.h +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of - conditions, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id: fdc.h 79 2016-01-11 16:21:27Z reddawg $ - -*****************************************************************************************/ - -#ifndef _FDC_H -#define _FDC_H - -#include - -typedef struct DrvGeom { - Int8 heads; - Int8 tracks; - Int8 spt; -} drvGeom; - - -#define fdcMsr (0x3f4) -#define fdcData (0x3f5) -#define fdcDir (0x3f7) -#define fdcCcr (0x3f7) -#define fdcDor (0x3f2) -#define fdcDrs (0x3f4) - -#define cmdWrite (0xc5) -#define cmdRead (0xe6) -#define cmdSeek (0x0f) -#define cmdSensei (0x08) -#define cmdRecal (0x07) -#define cmdSpecify (0x03) - -#define dg144Heads 2 /* heads per drive (1.44M) */ -#define dg144Tracks 80 -#define dg144Spt 18 -#define dg144Gap3rw 0x1b -#define dg168Gap3rw 0x1c - - - -int fdc_init(); -void floppyIsr(); -void floppyIsrhndlr(); -void sendByte(int Int8); -int getByte(); -bool fdcRw(int block,unsigned char *blockBuffer,bool read,unsigned long numSectors); -void block2Hts(int block,int *head,int *track,int *sector); -void motorOn(void); -void motorOff(void); -bool seek(int track); -bool waitFdc(bool sensei); -int getByte(); -void sendByte(int Int8); -void recalibrate(void); -void reset(void); -bool writeBlock(int block,Int8 *blockBuffer, unsigned long numSectors); -bool readBlock(int block,Int8 *blockBuffer, unsigned long numSectors); -void fdcWrite(void *info,void *,uInt32 startSector,uInt32 sectorCount); -void fdcRead(void *info,void *,uInt32 startSector,uInt32 sectorCount); - -#endif - -/*** - $Log: fdc.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:39 reddawg - no message - - Revision 1.6 2004/07/17 02:38:31 reddawg - Fixed a few problems - - Revision 1.5 2004/07/14 12:42:46 reddawg - fdc: fdcInit to fdc_init - Changed Startup Routines - - Revision 1.4 2004/05/21 14:57:16 reddawg - Cleaned up - - END - ***/ diff --git a/include/isa/mouse.h b/include/isa/mouse.h deleted file mode 100644 index 240f253..0000000 --- a/include/isa/mouse.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_MOUSE_H -#define _ISA_MOUSE_H - -int mouseInit(); -void mouseISR(); -void mouseHandler(); - -#endif - -/*** - $Log: mouse.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:39 reddawg - no message - - Revision 1.1 2004/06/04 10:20:53 reddawg - mouse drive: fixed a few bugs works a bit better now - - END - ***/ diff --git a/include/isa/ne2k.h b/include/isa/ne2k.h deleted file mode 100644 index e908f9c..0000000 --- a/include/isa/ne2k.h +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_NE2K_H -#define _ISA_NE2K_H - -#include -#include - -#define ether_addr ether_addr_t -typedef struct dp_rcvhdr -{ - uInt8 dr_status; /* Copy of rsr */ - uInt8 dr_next; /* Pointer to next packet */ - uInt8 dr_rbcl; /* Receive Byte Count Low */ - uInt8 dr_rbch; /* Receive Byte Count High */ -} dp_rcvhdr_t; - -typedef union etheraddr { - unsigned char bytes[6]; /* byteorder safe initialization */ - unsigned short shorts[3]; /* force 2-byte alignment */ -} ether_addr; - - -#define RSR_FO 0x08 -#define RSR_PRX 0x01 -#define DEF_ENABLED 0x200 - -#define OK 0 - - -#define startPage 0x4C -#define stopPage 0x80 - - -#define NE_CMD 0x00 -#define NE_PSTART 0x01 -#define NE_PSTOP 0x02 -#define NE_BNRY 0x03 -#define NE_TPSR 0x04 -#define NE_ISR 0x07 -#define NE_CURRENT 0x07 -#define NE_RBCR0 0x0A -#define NE_RBCR1 0x0B -#define NE_RCR 0x0C -#define NE_TCR 0x0D -#define NE_DCR 0x0E -#define NE_IMR 0x0F - - -#define NE_DCR_WTS 0x01 -#define NE_DCR_LS 0x08 -#define NE_DCR_AR 0x10 -#define NE_DCR_FT1 0x40 -#define NE_DCR_FT0 0x20 - - - -#define E8390_STOP 0x01 -#define E8390_NODMA 0x20 -#define E8390_PAGE0 0x00 -#define E8390_PAGE1 0x40 -#define E8390_CMD 0x00 -#define E8390_START 0x02 -#define E8390_RREAD 0x08 -#define E8390_RWRITE 0x10 -#define E8390_RXOFF 0x20 -#define E8390_TXOFF 0x00 -#define E8390_RXCONFIG 0x04 -#define E8390_TXCONFIG 0x00 - -#define EN0_COUNTER0 0x0d -#define EN0_DCFG 0x0e -#define EN0_RCNTLO 0x0a -#define EN0_RCNTHI 0x0b -#define EN0_ISR 0x07 -#define EN0_IMR 0x0f -#define EN0_RSARLO 0x08 -#define EN0_RSARHI 0x09 -#define EN0_TPSR 0x04 -#define EN0_RXCR 0x0c -#define EN0_TXCR 0x0D -#define EN0_STARTPG 0x01 -#define EN0_STOPPG 0x02 -#define EN0_BOUNDARY 0x03 - -#define EN1_PHYS 0x01 -#define EN1_CURPAG 0x07 -#define EN1_MULT 0x08 - -#define NE1SM_START_PG 0x20 -#define NE1SM_STOP_PG 0x40 -#define NESM_START_PG 0x40 -#define NESM_STOP_PG 0x80 - -#define ENISR_ALL 0x3f - -#define ENDCFG_WTS 0x01 - -#define NE_DATAPORT 0x10 - -#define TX_2X_PAGES 12 -#define TX_1X_PAGES 6 -#define TX_PAGES (dev->priv->pingPong ? TX_2X_PAGES : TX_1X_PAGES) - - -#define DP_CURR 0x7 /* Current Page Register */ -#define DP_MAR0 0x8 /* Multicast Address Register 0 */ -#define DP_MAR1 0x9 /* Multicast Address Register 1 */ -#define DP_MAR2 0xA /* Multicast Address Register 2 */ -#define DP_MAR3 0xB /* Multicast Address Register 3 */ -#define DP_MAR4 0xC /* Multicast Address Register 4 */ -#define DP_MAR5 0xD /* Multicast Address Register 5 */ -#define DP_MAR6 0xE /* Multicast Address Register 6 */ -#define DP_MAR7 0xF /* Multicast Address Register 7 */ - -#define DP_CNTR0 0xD /* Tally Counter 0 */ -#define DP_CNTR1 0xE /* Tally Counter 1 */ -#define DP_CNTR2 0xF /* Tally Counter 2 */ - - -#define DP_PAGESIZE 256 - -extern char *nicPacket; -extern uInt32 packetLength; - - -int ne2k_init(); -int ne2kProbe(int,struct device *); -int ne2kDevInit(struct device *); -void NS8390_init(struct device *dev,int startp); - -void ne2kISR(); -void ne2kHandler(); - -int NICtoPC(struct device *dev,void *packet,int length,int nic_addr); -int PCtoNIC(struct device *dev,void *packet,int length); - -struct nicBuffer *ne2kAllocBuffer(int); -struct nicBuffer *ne2kGetBuffer(); -void ne2kFreeBuffer(struct nicBuffer *); - -#endif - -/*** - $Log: ne2k.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:39 reddawg - no message - - Revision 1.6 2004/07/14 12:03:49 reddawg - ne2k: ne2kInit to ne2k_init - Changed Startup Routines - - Revision 1.5 2004/05/21 14:57:16 reddawg - Cleaned up - - - END - ***/ diff --git a/include/isa/pit.h b/include/isa/pit.h deleted file mode 100644 index 628fd22..0000000 --- a/include/isa/pit.h +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_PIT_H -#define _ISA_PIT_H - -#define PIT_TIMER 200 - -int pit_init(); - -#endif - -/*** - $Log: pit.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:40 reddawg - no message - - Revision 1.6 2004/08/14 11:23:02 reddawg - Changes - - Revision 1.5 2004/07/16 04:06:32 reddawg - Tune ups this stuff should of been taken care of months ago - - Revision 1.4 2004/07/16 01:08:58 reddawg - Whew we work once again - - Revision 1.3 2004/07/09 13:29:15 reddawg - pit: pitInit to pit_init - Adjusted initialization routines - - Revision 1.2 2004/05/21 14:57:16 reddawg - Cleaned up - - END - ***/ - diff --git a/include/lib/bioscall.h b/include/lib/bioscall.h deleted file mode 100644 index 6593bb4..0000000 --- a/include/lib/bioscall.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_BIOSCALL_H -#define _ISA_BIOSCALL_H - -#include - -#define EFLAG_TF 0x100 -#define EFLAG_IF 0x200 -#define EFLAG_IOPL3 0x3000 -#define EFLAG_VM 0x20000 - -void biosCall(int biosInt, int eax, int ebx, int ecx, int edx, int esi, int edi, int es, int ds); -void bios16Code(); - -#endif - -/*** - $Log: bioscall.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:40 reddawg - no message - - Revision 1.2 2004/05/21 15:00:27 reddawg - Cleaned up - - - END - ***/ diff --git a/include/lib/kmalloc.h b/include/lib/kmalloc.h deleted file mode 100644 index edc4889..0000000 --- a/include/lib/kmalloc.h +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LIB_KMALLOC_H -#define _LIB_KMALLOC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define sysID -2 -#define MALLOC_ALIGN_SIZE 32 -#define MALLOC_ALIGN(size) (size + ((((size) % (MALLOC_ALIGN_SIZE)) == 0)? 0 : ((MALLOC_ALIGN_SIZE) - ((size) % (MALLOC_ALIGN_SIZE))))) - - struct memDescriptor { - struct memDescriptor *prev; //4 - struct memDescriptor *next; //4 - void *baseAddr; //4 - uInt32 limit; //4 - /*uInt8 status; //1 */ - /*char reserved[11]; //11 */ - }; - - void kfree(void *baseAddr); - void *kmalloc(uInt32 len); - -#ifdef __cplusplus -} -#endif - -#endif - -/*** - $Log: kmalloc.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:40 reddawg - no message - - Revision 1.7 2004/09/14 20:57:01 reddawg - Bug fixes: macro problem over opt a multiply - - Revision 1.6 2004/07/21 10:02:09 reddawg - devfs: renamed functions - device system: renamed functions - fdc: fixed a few potential bugs and cleaned up some unused variables - strol: fixed definition - endtask: made it print out freepage debug info - kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost - ld: fixed a pointer conversion - file: cleaned up a few unused variables - sched: broke task deletion - kprintf: fixed ogPrintf definition - - Revision 1.5 2004/07/19 02:08:27 reddawg - Cleaned out the rest of debuging code also temporarily disabled the ip stack to improve boot time - - Revision 1.4 2004/07/18 05:24:15 reddawg - Fixens - - Revision 1.3 2004/05/21 15:00:27 reddawg - Cleaned up - - END - ***/ diff --git a/include/lib/kprintf.h b/include/lib/kprintf.h deleted file mode 100644 index 10f876e..0000000 --- a/include/lib/kprintf.h +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _KPRINTF_H -#define _KPRINTF_H - -#include -#include - -#define MAXNBUF 512 - -int kprintf(const char *, ...); -int sprintf(char *buf, const char *fmt, ...); -int kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap); -int ogPrintf(char *); - -extern int printOff; -extern int ogprintOff; - -#endif - -/*** - $Log: kprintf.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:40 reddawg - no message - - Revision 1.2 2004/05/21 15:00:27 reddawg - Cleaned up - - - END - ***/ diff --git a/include/lib/libcpp.h b/include/lib/libcpp.h deleted file mode 100644 index 47d9deb..0000000 --- a/include/lib/libcpp.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LIBCPP_H -#define __LIBCPP_H - -#include - -void * operator new(unsigned size); -void operator delete(void * ptr); -void * operator new[](unsigned size); -void operator delete[](void * ptr); - -#endif diff --git a/include/machine/_limits.h b/include/machine/_limits.h deleted file mode 100644 index e3c85d7..0000000 --- a/include/machine/_limits.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 - * $FreeBSD: releng/11.2/sys/x86/include/_limits.h 331722 2018-03-29 02:50:57Z eadler $ - */ - -#ifndef _MACHINE__LIMITS_H_ -#define _MACHINE__LIMITS_H_ - -/* - * According to ANSI (section 2.2.4.2), the values below must be usable by - * #if preprocessing directives. Additionally, the expression must have the - * same type as would an expression that is an object of the corresponding - * type converted according to the integral promotions. The subtraction for - * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an - * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). - */ - -#define __CHAR_BIT 8 /* number of bits in a char */ - -#define __SCHAR_MAX 0x7f /* max value for a signed char */ -#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ - -#define __UCHAR_MAX 0xff /* max value for an unsigned char */ - -#define __USHRT_MAX 0xffff /* max value for an unsigned short */ -#define __SHRT_MAX 0x7fff /* max value for a short */ -#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */ - -#define __UINT_MAX 0xffffffff /* max value for an unsigned int */ -#define __INT_MAX 0x7fffffff /* max value for an int */ -#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */ - -#ifdef __LP64__ -#define __ULONG_MAX 0xffffffffffffffff /* max for an unsigned long */ -#define __LONG_MAX 0x7fffffffffffffff /* max for a long */ -#define __LONG_MIN (-0x7fffffffffffffff - 1) /* min for a long */ -#else -#define __ULONG_MAX 0xffffffffUL -#define __LONG_MAX 0x7fffffffL -#define __LONG_MIN (-0x7fffffffL - 1) -#endif - - /* max value for an unsigned long long */ -#define __ULLONG_MAX 0xffffffffffffffffULL -#define __LLONG_MAX 0x7fffffffffffffffLL /* max value for a long long */ -#define __LLONG_MIN (-0x7fffffffffffffffLL - 1) /* min for a long long */ - -#ifdef __LP64__ -#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ -#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ -#define __OFF_MAX __LONG_MAX /* max value for an off_t */ -#define __OFF_MIN __LONG_MIN /* min value for an off_t */ -/* Quads and longs are the same on the amd64. Ensure they stay in sync. */ -#define __UQUAD_MAX __ULONG_MAX /* max value for a uquad_t */ -#define __QUAD_MAX __LONG_MAX /* max value for a quad_t */ -#define __QUAD_MIN __LONG_MIN /* min value for a quad_t */ -#define __LONG_BIT 64 -#else -#define __SSIZE_MAX __INT_MAX -#define __SIZE_T_MAX __UINT_MAX -#define __OFF_MAX __LLONG_MAX -#define __OFF_MIN __LLONG_MIN -#define __UQUAD_MAX __ULLONG_MAX -#define __QUAD_MAX __LLONG_MAX -#define __QUAD_MIN __LLONG_MIN -#define __LONG_BIT 32 -#endif - -#define __WORD_BIT 32 - -/* Minimum signal stack size. */ -#define __MINSIGSTKSZ (512 * 4) - -#endif /* !_MACHINE__LIMITS_H_ */ diff --git a/include/machine/_stdint.h b/include/machine/_stdint.h deleted file mode 100644 index b876c53..0000000 --- a/include/machine/_stdint.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef _MACHINE__STDINT_H_ -#define _MACHINE__STDINT_H_ - -#include - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - -#define INT8_C(c) (c) -#define INT16_C(c) (c) -#define INT32_C(c) (c) - -#define UINT8_C(c) (c) -#define UINT16_C(c) (c) -#define UINT32_C(c) (c ## U) - -#ifdef __LP64__ -#define INT64_C(c) (c ## L) -#define UINT64_C(c) (c ## UL) -#else -#define INT64_C(c) (c ## LL) -#define UINT64_C(c) (c ## ULL) -#endif - -#define INTMAX_C(c) INT64_C(c) -#define UINTMAX_C(c) UINT64_C(c) - -#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) - -/* - * ISO/IEC 9899:1999 - * 7.18.2.1 Limits of exact-width integer types - */ -#define INT8_MIN (-0x7f-1) -#define INT16_MIN (-0x7fff-1) -#define INT32_MIN (-0x7fffffff-1) - -#define INT8_MAX 0x7f -#define INT16_MAX 0x7fff -#define INT32_MAX 0x7fffffff - -#define UINT8_MAX 0xff -#define UINT16_MAX 0xffff -#define UINT32_MAX 0xffffffffU - -#ifdef __LP64__ -#define INT64_MIN (-0x7fffffffffffffff-1) -#define INT64_MAX 0x7fffffffffffffff -#define UINT64_MAX 0xffffffffffffffff -#else -#define INT64_MIN (-0x7fffffffffffffffLL-1) -#define INT64_MAX 0x7fffffffffffffffLL -#define UINT64_MAX 0xffffffffffffffffULL -#endif - -/* - * ISO/IEC 9899:1999 - * 7.18.2.2 Limits of minimum-width integer types - */ -/* Minimum values of minimum-width signed integer types. */ -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST64_MIN INT64_MIN - -/* Maximum values of minimum-width signed integer types. */ -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MAX INT64_MAX - -/* Maximum values of minimum-width unsigned integer types. */ -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.3 Limits of fastest minimum-width integer types - */ -/* Minimum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MIN INT32_MIN -#define INT_FAST16_MIN INT32_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN - -/* Maximum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MAX INT32_MAX -#define INT_FAST16_MAX INT32_MAX -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MAX INT64_MAX - -/* Maximum values of fastest minimum-width unsigned integer types. */ -#define UINT_FAST8_MAX UINT32_MAX -#define UINT_FAST16_MAX UINT32_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.4 Limits of integer types capable of holding object pointers - */ -#ifdef __LP64__ -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX -#else -#define INTPTR_MIN INT32_MIN -#define INTPTR_MAX INT32_MAX -#define UINTPTR_MAX UINT32_MAX -#endif - -/* - * ISO/IEC 9899:1999 - * 7.18.2.5 Limits of greatest-width integer types - */ -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.3 Limits of other integer types - */ -#ifdef __LP64__ -/* Limits of ptrdiff_t. */ -#define PTRDIFF_MIN INT64_MIN -#define PTRDIFF_MAX INT64_MAX - -/* Limits of sig_atomic_t. */ -#define SIG_ATOMIC_MIN __LONG_MIN -#define SIG_ATOMIC_MAX __LONG_MAX - -/* Limit of size_t. */ -#define SIZE_MAX UINT64_MAX -#else -#define PTRDIFF_MIN INT32_MIN -#define PTRDIFF_MAX INT32_MAX -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX -#define SIZE_MAX UINT32_MAX -#endif - -/* Limits of wint_t. */ -#define WINT_MIN INT32_MIN -#define WINT_MAX INT32_MAX - -#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ - -#endif /* !_MACHINE__STDINT_H_ */ diff --git a/include/machine/_types.h b/include/machine/_types.h deleted file mode 100644 index 7c3fdfb..0000000 --- a/include/machine/_types.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MACHINE__TYPES_H_ -#define _MACHINE__TYPES_H_ - -/* Basic types upon which most other types are built */ - -typedef __signed char __int8_t; -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -typedef long long __int64_t; -typedef unsigned long long __uint64_t; - -// Standard type definitions. - -typedef unsigned long __clock_t; /* clock()... */ -typedef __int32_t __critical_t; -typedef double __double_t; -typedef double __float_t; -typedef __int32_t __intfptr_t; -typedef __int64_t __intmax_t; -typedef __int32_t __intptr_t; -typedef __int32_t __int_fast8_t; -typedef __int32_t __int_fast16_t; -typedef __int32_t __int_fast32_t; -typedef __int64_t __int_fast64_t; -typedef __int8_t __int_least8_t; -typedef __int16_t __int_least16_t; -typedef __int32_t __int_least32_t; -typedef __int64_t __int_least64_t; -typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */ -typedef __int32_t __register_t; -typedef __int32_t __segsz_t; /* segment size (in pages) */ -typedef __uint32_t __size_t; /* sizeof() */ -typedef __int32_t __ssize_t; /* byte count or error */ -typedef __int32_t __time_t; /* time()... */ -typedef __uint32_t __uintfptr_t; -typedef __uint64_t __uintmax_t; -typedef __uint32_t __uintptr_t; -typedef __uint32_t __uint_fast8_t; -typedef __uint32_t __uint_fast16_t; -typedef __uint32_t __uint_fast32_t; -typedef __uint64_t __uint_fast64_t; -typedef __uint8_t __uint_least8_t; -typedef __uint16_t __uint_least16_t; -typedef __uint32_t __uint_least32_t; -typedef __uint64_t __uint_least64_t; -typedef __uint32_t __u_register_t; -typedef __uint32_t __vm_offset_t; -typedef __int64_t __vm_ooffset_t; -typedef __uint32_t __vm_paddr_t; -typedef __uint64_t __vm_pindex_t; -typedef __uint32_t __vm_size_t; - -#endif /* !_MACHINE__TYPES_H_ */ diff --git a/include/math.h b/include/math.h deleted file mode 100644 index d5418c1..0000000 --- a/include/math.h +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __MATH_H -#define __MATH_H - -#include - -//typedef long long int quad_t; -//typedef unsigned long long int u_quad_t; - -double atan(double x); -double sqrt(double x); -u_quad_t __udivdi3(u_quad_t a, u_quad_t b); -quad_t __divdi3(quad_t a, quad_t b); - -#endif - -/*** - $Log: math.h,v $ - Revision 1.2 2006/10/31 20:41:16 reddawg - Includes - - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:38 reddawg - no message - - Revision 1.2 2004/05/21 15:22:35 reddawg - Cleaned up - - - END - ***/ diff --git a/include/mk-osreldate.sh b/include/mk-osreldate.sh old mode 100644 new mode 100755 diff --git a/include/mpi/mpi.h b/include/mpi/mpi.h deleted file mode 100644 index 0b1ce14..0000000 --- a/include/mpi/mpi.h +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MPI_MPI_H -#define _MPI_MPI_H - -#include -#include - -#define MESSAGE_LENGTH 248 - -struct mpi_message { - char data[MESSAGE_LENGTH]; - uInt32 header; - pidType pid; - struct mpi_message *next; -}; - -struct mpi_mbox { - struct mpi_mbox *next; - struct mpi_mbox *prev; - struct mpi_message *msg; - struct mpi_message *msgLast; - char name[64]; - pidType pid; -}; - -typedef struct mpi_mbox mpi_mbox_t; -typedef struct mpi_message mpi_message_t; - -int mpi_createMbox(char *); -int mpi_destroyMbox(char *); -int mpi_postMessage(char *, uInt32, mpi_message_t *); -int mpi_fetchMessage(char *, mpi_message_t *); -int mpi_spam(uInt32, void *); - -#endif diff --git a/include/net/api.h b/include/net/api.h deleted file mode 100644 index afec037..0000000 --- a/include/net/api.h +++ /dev/null @@ -1,400 +0,0 @@ -/** - * @file - * netconn API (to be used from non-TCPIP threads) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_API_H -#define LWIP_HDR_API_H - -#include "net/opt.h" - -#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ -/* Note: Netconn API is always available when sockets are enabled - - * sockets are implemented on top of them */ - -#include "net/arch.h" -#include "net/netbuf.h" -#include "net/sys.h" -#include "net/ip_addr.h" -#include "net/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Throughout this file, IP addresses and port numbers are expected to be in - * the same byte order as in the corresponding pcb. - */ - -/* Flags for netconn_write (u8_t) */ -#define NETCONN_NOFLAG 0x00 -#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */ -#define NETCONN_COPY 0x01 -#define NETCONN_MORE 0x02 -#define NETCONN_DONTBLOCK 0x04 - -/* Flags for struct netconn.flags (u8_t) */ -/** Should this netconn avoid blocking? */ -#define NETCONN_FLAG_NON_BLOCKING 0x02 -/** Was the last connect action a non-blocking one? */ -#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 -/** If a nonblocking write has been rejected before, poll_tcp needs to - check if the netconn is writable again */ -#define NETCONN_FLAG_CHECK_WRITESPACE 0x10 -#if LWIP_IPV6 -/** If this flag is set then only IPv6 communication is allowed on the - netconn. As per RFC#3493 this features defaults to OFF allowing - dual-stack usage by default. */ -#define NETCONN_FLAG_IPV6_V6ONLY 0x20 -#endif /* LWIP_IPV6 */ - - -/* Helpers to process several netconn_types by the same code */ -#define NETCONNTYPE_GROUP(t) ((t)&0xF0) -#define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0) -#if LWIP_IPV6 -#define NETCONN_TYPE_IPV6 0x08 -#define NETCONNTYPE_ISIPV6(t) (((t)&NETCONN_TYPE_IPV6) != 0) -#define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF3) == NETCONN_UDPLITE) -#define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF3) == NETCONN_UDPNOCHKSUM) -#else /* LWIP_IPV6 */ -#define NETCONNTYPE_ISIPV6(t) (0) -#define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE) -#define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM) -#endif /* LWIP_IPV6 */ - -/** @ingroup netconn_common - * Protocol family and type of the netconn - */ -enum netconn_type { - NETCONN_INVALID = 0, - /** TCP IPv4 */ - NETCONN_TCP = 0x10, -#if LWIP_IPV6 - /** TCP IPv6 */ - NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 /* 0x18 */, -#endif /* LWIP_IPV6 */ - /** UDP IPv4 */ - NETCONN_UDP = 0x20, - /** UDP IPv4 lite */ - NETCONN_UDPLITE = 0x21, - /** UDP IPv4 no checksum */ - NETCONN_UDPNOCHKSUM = 0x22, - -#if LWIP_IPV6 - /** UDP IPv6 (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ - NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 /* 0x28 */, - /** UDP IPv6 lite (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ - NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 /* 0x29 */, - /** UDP IPv6 no checksum (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ - NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 /* 0x2a */, -#endif /* LWIP_IPV6 */ - - /** Raw connection IPv4 */ - NETCONN_RAW = 0x40 -#if LWIP_IPV6 - /** Raw connection IPv6 (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ - , NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6 /* 0x48 */ -#endif /* LWIP_IPV6 */ -}; - -/** Current state of the netconn. Non-TCP netconns are always - * in state NETCONN_NONE! */ -enum netconn_state { - NETCONN_NONE, - NETCONN_WRITE, - NETCONN_LISTEN, - NETCONN_CONNECT, - NETCONN_CLOSE -}; - -/** Used to inform the callback function about changes - * - * Event explanation: - * - * In the netconn implementation, there are three ways to block a client: - * - * - accept mbox (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, 0); in netconn_accept()) - * - receive mbox (sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); in netconn_recv_data()) - * - send queue is full (sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0); in lwip_netconn_do_write()) - * - * The events have to be seen as events signaling the state of these mboxes/semaphores. For non-blocking - * connections, you need to know in advance whether a call to a netconn function call would block or not, - * and these events tell you about that. - * - * RCVPLUS events say: Safe to perform a potentially blocking call call once more. - * They are counted in sockets - three RCVPLUS events for accept mbox means you are safe - * to call netconn_accept 3 times without being blocked. - * Same thing for receive mbox. - * - * RCVMINUS events say: Your call to to a possibly blocking function is "acknowledged". - * Socket implementation decrements the counter. - * - * For TX, there is no need to count, its merely a flag. SENDPLUS means you may send something. - * SENDPLUS occurs when enough data was delivered to peer so netconn_send() can be called again. - * A SENDMINUS event occurs when the next call to a netconn_send() would be blocking. - */ -enum netconn_evt { - NETCONN_EVT_RCVPLUS, - NETCONN_EVT_RCVMINUS, - NETCONN_EVT_SENDPLUS, - NETCONN_EVT_SENDMINUS, - NETCONN_EVT_ERROR -}; - -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -/** Used for netconn_join_leave_group() */ -enum netconn_igmp { - NETCONN_JOIN, - NETCONN_LEAVE -}; -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ - -#if LWIP_DNS -/* Used for netconn_gethostbyname_addrtype(), these should match the DNS_ADDRTYPE defines in dns.h */ -#define NETCONN_DNS_DEFAULT NETCONN_DNS_IPV4_IPV6 -#define NETCONN_DNS_IPV4 0 -#define NETCONN_DNS_IPV6 1 -#define NETCONN_DNS_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */ -#define NETCONN_DNS_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */ -#endif /* LWIP_DNS */ - -/* forward-declare some structs to avoid to include their headers */ -struct ip_pcb; -struct tcp_pcb; -struct udp_pcb; -struct raw_pcb; -struct netconn; -struct api_msg; - -/** A callback prototype to inform about events for a netconn */ -typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len); - -/** A netconn descriptor */ -struct netconn { - /** type of the netconn (TCP, UDP or RAW) */ - enum netconn_type type; - /** current state of the netconn */ - enum netconn_state state; - /** the lwIP internal protocol control block */ - union { - struct ip_pcb *ip; - struct tcp_pcb *tcp; - struct udp_pcb *udp; - struct raw_pcb *raw; - } pcb; - /** the last error this netconn had */ - err_t last_err; -#if !LWIP_NETCONN_SEM_PER_THREAD - /** sem that is used to synchronously execute functions in the core context */ - sys_sem_t op_completed; -#endif - /** mbox where received packets are stored until they are fetched - by the netconn application thread (can grow quite big) */ - sys_mbox_t recvmbox; -#if LWIP_TCP - /** mbox where new connections are stored until processed - by the application thread */ - sys_mbox_t acceptmbox; -#endif /* LWIP_TCP */ - /** only used for socket layer */ -#if LWIP_SOCKET - int socket; -#endif /* LWIP_SOCKET */ -#if LWIP_SO_SNDTIMEO - /** timeout to wait for sending data (which means enqueueing data for sending - in internal buffers) in milliseconds */ - s32_t send_timeout; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVTIMEO - /** timeout in milliseconds to wait for new data to be received - (or connections to arrive for listening netconns) */ - int recv_timeout; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - /** maximum amount of bytes queued in recvmbox - not used for TCP: adjust TCP_WND instead! */ - int recv_bufsize; - /** number of bytes currently in recvmbox to be received, - tested against recv_bufsize to limit bytes on recvmbox - for UDP and RAW, used for FIONREAD */ - int recv_avail; -#endif /* LWIP_SO_RCVBUF */ -#if LWIP_SO_LINGER - /** values <0 mean linger is disabled, values > 0 are seconds to linger */ - s16_t linger; -#endif /* LWIP_SO_LINGER */ - /** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */ - u8_t flags; -#if LWIP_TCP - /** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores how much is already sent. */ - size_t write_offset; - /** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores the message. - Also used during connect and close. */ - struct api_msg *current_msg; -#endif /* LWIP_TCP */ - /** A callback function that is informed about events for this netconn */ - netconn_callback callback; -}; - -/** Register an Network connection event */ -#define API_EVENT(c,e,l) if (c->callback) { \ - (*c->callback)(c, e, l); \ - } - -/** Set conn->last_err to err but don't overwrite fatal errors */ -#define NETCONN_SET_SAFE_ERR(conn, err) do { if ((conn) != NULL) { \ - SYS_ARCH_DECL_PROTECT(netconn_set_safe_err_lev); \ - SYS_ARCH_PROTECT(netconn_set_safe_err_lev); \ - if (!ERR_IS_FATAL((conn)->last_err)) { \ - (conn)->last_err = err; \ - } \ - SYS_ARCH_UNPROTECT(netconn_set_safe_err_lev); \ -}} while(0); - -/* Network connection functions: */ - -/** @ingroup netconn_common - * Create new netconn connection - * @param t @ref netconn_type */ -#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) -#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) -struct netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, - netconn_callback callback); -err_t netconn_delete(struct netconn *conn); -/** Get the type of a netconn (as enum netconn_type). */ -#define netconn_type(conn) (conn->type) - -err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, - u16_t *port, u8_t local); -/** @ingroup netconn_common */ -#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) -/** @ingroup netconn_common */ -#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) - -err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port); -err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port); -err_t netconn_disconnect (struct netconn *conn); -err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); -/** @ingroup netconn_tcp */ -#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) -err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); -err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); -err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); -err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, - const ip_addr_t *addr, u16_t port); -err_t netconn_send(struct netconn *conn, struct netbuf *buf); -err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, - u8_t apiflags, size_t *bytes_written); -/** @ingroup netconn_tcp */ -#define netconn_write(conn, dataptr, size, apiflags) \ - netconn_write_partly(conn, dataptr, size, apiflags, NULL) -err_t netconn_close(struct netconn *conn); -err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); - -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr, - const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ -#if LWIP_DNS -#if LWIP_IPV4 && LWIP_IPV6 -err_t netconn_gethostbyname_addrtype(const char *name, ip_addr_t *addr, u8_t dns_addrtype); -#define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT) -#else /* LWIP_IPV4 && LWIP_IPV6 */ -err_t netconn_gethostbyname(const char *name, ip_addr_t *addr); -#define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr) -#endif /* LWIP_IPV4 && LWIP_IPV6 */ -#endif /* LWIP_DNS */ - -#define netconn_err(conn) ((conn)->last_err) -#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) - -/** Set the blocking status of netconn calls (@todo: write/send is missing) */ -#define netconn_set_nonblocking(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) -/** Get the blocking status of netconn calls (@todo: write/send is missing) */ -#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) - -#if LWIP_IPV6 -/** @ingroup netconn_common - * TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) - */ -#define netconn_set_ipv6only(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_IPV6_V6ONLY; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_IPV6_V6ONLY; }} while(0) -/** @ingroup netconn_common - * TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) - */ -#define netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0) -#endif /* LWIP_IPV6 */ - -#if LWIP_SO_SNDTIMEO -/** Set the send timeout in milliseconds */ -#define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) -/** Get the send timeout in milliseconds */ -#define netconn_get_sendtimeout(conn) ((conn)->send_timeout) -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO -/** Set the receive timeout in milliseconds */ -#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) -/** Get the receive timeout in milliseconds */ -#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF -/** Set the receive buffer in bytes */ -#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) -/** Get the receive buffer in bytes */ -#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) -#endif /* LWIP_SO_RCVBUF*/ - -#if LWIP_NETCONN_SEM_PER_THREAD -void netconn_thread_init(void); -void netconn_thread_cleanup(void); -#else /* LWIP_NETCONN_SEM_PER_THREAD */ -#define netconn_thread_init() -#define netconn_thread_cleanup() -#endif /* LWIP_NETCONN_SEM_PER_THREAD */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN || LWIP_SOCKET */ - -#endif /* LWIP_HDR_API_H */ diff --git a/include/net/apps/FILES b/include/net/apps/FILES deleted file mode 100644 index c983076..0000000 --- a/include/net/apps/FILES +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains application headers. -Every application shall provide one api file APP.h and optionally one options file APP_opts.h diff --git a/include/net/apps/fs.h b/include/net/apps/fs.h deleted file mode 100644 index 0283a0b..0000000 --- a/include/net/apps/fs.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_APPS_FS_H -#define LWIP_HDR_APPS_FS_H - -#include "httpd_opts.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define FS_READ_EOF -1 -#define FS_READ_DELAYED -2 - -#if HTTPD_PRECALCULATED_CHECKSUM -struct fsdata_chksum { - u32_t offset; - u16_t chksum; - u16_t len; -}; -#endif /* HTTPD_PRECALCULATED_CHECKSUM */ - -#define FS_FILE_FLAGS_HEADER_INCLUDED 0x01 -#define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02 - -struct fs_file { - const char *data; - int len; - int index; - void *pextension; -#if HTTPD_PRECALCULATED_CHECKSUM - const struct fsdata_chksum *chksum; - u16_t chksum_count; -#endif /* HTTPD_PRECALCULATED_CHECKSUM */ - u8_t flags; -#if LWIP_HTTPD_CUSTOM_FILES - u8_t is_custom_file; -#endif /* LWIP_HTTPD_CUSTOM_FILES */ -#if LWIP_HTTPD_FILE_STATE - void *state; -#endif /* LWIP_HTTPD_FILE_STATE */ -}; - -#if LWIP_HTTPD_FS_ASYNC_READ -typedef void (*fs_wait_cb)(void *arg); -#endif /* LWIP_HTTPD_FS_ASYNC_READ */ - -err_t fs_open(struct fs_file *file, const char *name); -void fs_close(struct fs_file *file); -#if LWIP_HTTPD_DYNAMIC_FILE_READ -#if LWIP_HTTPD_FS_ASYNC_READ -int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg); -#else /* LWIP_HTTPD_FS_ASYNC_READ */ -int fs_read(struct fs_file *file, char *buffer, int count); -#endif /* LWIP_HTTPD_FS_ASYNC_READ */ -#endif /* LWIP_HTTPD_DYNAMIC_FILE_READ */ -#if LWIP_HTTPD_FS_ASYNC_READ -int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg); -#endif /* LWIP_HTTPD_FS_ASYNC_READ */ -int fs_bytes_left(struct fs_file *file); - -#if LWIP_HTTPD_FILE_STATE -/** This user-defined function is called when a file is opened. */ -void *fs_state_init(struct fs_file *file, const char *name); -/** This user-defined function is called when a file is closed. */ -void fs_state_free(struct fs_file *file, void *state); -#endif /* #if LWIP_HTTPD_FILE_STATE */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_FS_H */ diff --git a/include/net/apps/httpd.h b/include/net/apps/httpd.h deleted file mode 100644 index 57831dd..0000000 --- a/include/net/apps/httpd.h +++ /dev/null @@ -1,236 +0,0 @@ -/** - * @file - * HTTP server - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - * This version of the file has been modified by Texas Instruments to offer - * simple server-side-include (SSI) and Common Gateway Interface (CGI) - * capability. - */ - -#ifndef LWIP_HDR_APPS_HTTPD_H -#define LWIP_HDR_APPS_HTTPD_H - -#include "httpd_opts.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_HTTPD_CGI - -/* - * Function pointer for a CGI script handler. - * - * This function is called each time the HTTPD server is asked for a file - * whose name was previously registered as a CGI function using a call to - * http_set_cgi_handler. The iIndex parameter provides the index of the - * CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters - * pcParam and pcValue provide access to the parameters provided along with - * the URI. iNumParams provides a count of the entries in the pcParam and - * pcValue arrays. Each entry in the pcParam array contains the name of a - * parameter with the corresponding entry in the pcValue array containing the - * value for that parameter. Note that pcParam may contain multiple elements - * with the same name if, for example, a multi-selection list control is used - * in the form generating the data. - * - * The function should return a pointer to a character string which is the - * path and filename of the response that is to be sent to the connected - * browser, for example "/thanks.htm" or "/response/error.ssi". - * - * The maximum number of parameters that will be passed to this function via - * iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming - * HTTP request above this number will be discarded. - * - * Requests intended for use by this CGI mechanism must be sent using the GET - * method (which encodes all parameters within the URI rather than in a block - * later in the request). Attempts to use the POST method will result in the - * request being ignored. - * - */ -typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[], - char *pcValue[]); - -/* - * Structure defining the base filename (URL) of a CGI and the associated - * function which is to be called when that URL is requested. - */ -typedef struct -{ - const char *pcCGIName; - tCGIHandler pfnCGIHandler; -} tCGI; - -void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers); - -#endif /* LWIP_HTTPD_CGI */ - -#if LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI - -#if LWIP_HTTPD_CGI_SSI -/** Define this generic CGI handler in your application. - * It is called once for every URI with parameters. - * The parameters can be stored to - */ -extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue -#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE - , void *connection_state -#endif /* LWIP_HTTPD_FILE_STATE */ - ); -#endif /* LWIP_HTTPD_CGI_SSI */ - -#endif /* LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI */ - -#if LWIP_HTTPD_SSI - -/* - * Function pointer for the SSI tag handler callback. - * - * This function will be called each time the HTTPD server detects a tag of the - * form in a .shtml, .ssi or .shtm file where "name" appears as - * one of the tags supplied to http_set_ssi_handler in the ppcTags array. The - * returned insert string, which will be appended after the the string - * "" in file sent back to the client,should be written to pointer - * pcInsert. iInsertLen contains the size of the buffer pointed to by - * pcInsert. The iIndex parameter provides the zero-based index of the tag as - * found in the ppcTags array and identifies the tag that is to be processed. - * - * The handler returns the number of characters written to pcInsert excluding - * any terminating NULL or a negative number to indicate a failure (tag not - * recognized, for example). - * - * Note that the behavior of this SSI mechanism is somewhat different from the - * "normal" SSI processing as found in, for example, the Apache web server. In - * this case, the inserted text is appended following the SSI tag rather than - * replacing the tag entirely. This allows for an implementation that does not - * require significant additional buffering of output data yet which will still - * offer usable SSI functionality. One downside to this approach is when - * attempting to use SSI within JavaScript. The SSI tag is structured to - * resemble an HTML comment but this syntax does not constitute a comment - * within JavaScript and, hence, leaving the tag in place will result in - * problems in these cases. To work around this, any SSI tag which needs to - * output JavaScript code must do so in an encapsulated way, sending the whole - * HTML section as a single include. - */ -typedef u16_t (*tSSIHandler)( -#if LWIP_HTTPD_SSI_RAW - const char* ssi_tag_name, -#else /* LWIP_HTTPD_SSI_RAW */ - int iIndex, -#endif /* LWIP_HTTPD_SSI_RAW */ - char *pcInsert, int iInsertLen -#if LWIP_HTTPD_SSI_MULTIPART - , u16_t current_tag_part, u16_t *next_tag_part -#endif /* LWIP_HTTPD_SSI_MULTIPART */ -#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE - , void *connection_state -#endif /* LWIP_HTTPD_FILE_STATE */ - ); - -/** Set the SSI handler function - * (if LWIP_HTTPD_SSI_RAW==1, only the first argument is used) - */ -void http_set_ssi_handler(tSSIHandler pfnSSIHandler, - const char **ppcTags, int iNumTags); - -/** For LWIP_HTTPD_SSI_RAW==1, return this to indicate the tag is unknown. - * In this case, the webserver writes a warning into the page. - * You can also just return 0 to write nothing for unknown tags. - */ -#define HTTPD_SSI_TAG_UNKNOWN 0xFFFF - -#endif /* LWIP_HTTPD_SSI */ - -#if LWIP_HTTPD_SUPPORT_POST - -/* These functions must be implemented by the application */ - -/** Called when a POST request has been received. The application can decide - * whether to accept it or not. - * - * @param connection Unique connection identifier, valid until httpd_post_end - * is called. - * @param uri The HTTP header URI receiving the POST request. - * @param http_request The raw HTTP request (the first packet, normally). - * @param http_request_len Size of 'http_request'. - * @param content_len Content-Length from HTTP header. - * @param response_uri Filename of response file, to be filled when denying the - * request - * @param response_uri_len Size of the 'response_uri' buffer. - * @param post_auto_wnd Set this to 0 to let the callback code handle window - * updates by calling 'httpd_post_data_recved' (to throttle rx speed) - * default is 1 (httpd handles window updates automatically) - * @return ERR_OK: Accept the POST request, data may be passed in - * another err_t: Deny the POST request, send back 'bad request'. - */ -err_t httpd_post_begin(void *connection, const char *uri, const char *http_request, - u16_t http_request_len, int content_len, char *response_uri, - u16_t response_uri_len, u8_t *post_auto_wnd); - -/** Called for each pbuf of data that has been received for a POST. - * ATTENTION: The application is responsible for freeing the pbufs passed in! - * - * @param connection Unique connection identifier. - * @param p Received data. - * @return ERR_OK: Data accepted. - * another err_t: Data denied, http_post_get_response_uri will be called. - */ -err_t httpd_post_receive_data(void *connection, struct pbuf *p); - -/** Called when all data is received or when the connection is closed. - * The application must return the filename/URI of a file to send in response - * to this POST request. If the response_uri buffer is untouched, a 404 - * response is returned. - * - * @param connection Unique connection identifier. - * @param response_uri Filename of response file, to be filled when denying the request - * @param response_uri_len Size of the 'response_uri' buffer. - */ -void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len); - -#if LWIP_HTTPD_POST_MANUAL_WND -void httpd_post_data_recved(void *connection, u16_t recved_len); -#endif /* LWIP_HTTPD_POST_MANUAL_WND */ - -#endif /* LWIP_HTTPD_SUPPORT_POST */ - -void httpd_init(void); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HTTPD_H */ diff --git a/include/net/apps/httpd_opts.h b/include/net/apps/httpd_opts.h deleted file mode 100644 index 2669745..0000000 --- a/include/net/apps/httpd_opts.h +++ /dev/null @@ -1,323 +0,0 @@ -/** - * @file - * HTTP server options list - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - * This version of the file has been modified by Texas Instruments to offer - * simple server-side-include (SSI) and Common Gateway Interface (CGI) - * capability. - */ - -#ifndef LWIP_HDR_APPS_HTTPD_OPTS_H -#define LWIP_HDR_APPS_HTTPD_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup httpd_opts Options - * @ingroup httpd - * @{ - */ - -/** Set this to 1 to support CGI (old style) */ -#if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__ -#define LWIP_HTTPD_CGI 0 -#endif - -/** Set this to 1 to support CGI (new style) */ -#if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__ -#define LWIP_HTTPD_CGI_SSI 0 -#endif - -/** Set this to 1 to support SSI (Server-Side-Includes) */ -#if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI 0 -#endif - -/** Set this to 1 to implement an SSI tag handler callback that gets a const char* - * to the tag (instead of an index into a pre-registered array of known tags) */ -#if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI_RAW 0 -#endif - -/** Set this to 1 to support HTTP POST */ -#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_POST 0 -#endif - -/* The maximum number of parameters that the CGI handler can be sent. */ -#if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16 -#endif - -/** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more - * arguments indicating a counter for insert string that are too long to be - * inserted at once: the SSI handler function must then set 'next_tag_part' - * which will be passed back to it in the next call. */ -#if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI_MULTIPART 0 -#endif - -/* The maximum length of the string comprising the tag name */ -#if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8 -#endif - -/* The maximum length of string that can be returned to replace any given tag */ -#if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192 -#endif - -#if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__ -#define LWIP_HTTPD_POST_MANUAL_WND 0 -#endif - -/** This string is passed in the HTTP header as "Server: " */ -#if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__ -#define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)" -#endif - -/** Set this to 1 if you want to include code that creates HTTP headers - * at runtime. Default is off: HTTP headers are then created statically - * by the makefsdata tool. Static headers mean smaller code size, but - * the (readonly) fsdata will grow a bit as every file includes the HTTP - * header. */ -#if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__ -#define LWIP_HTTPD_DYNAMIC_HEADERS 0 -#endif - -#if !defined HTTPD_DEBUG || defined __DOXYGEN__ -#define HTTPD_DEBUG LWIP_DBG_OFF -#endif - -/** Set this to 1 to use a memp pool for allocating - * struct http_state instead of the heap. - */ -#if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ -#define HTTPD_USE_MEM_POOL 0 -#endif - -/** The server port for HTTPD to use */ -#if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__ -#define HTTPD_SERVER_PORT 80 -#endif - -/** Maximum retries before the connection is aborted/closed. - * - number of times pcb->poll is called -> default is 4*500ms = 2s; - * - reset when pcb->sent is called - */ -#if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__ -#define HTTPD_MAX_RETRIES 4 -#endif - -/** The poll delay is X*500ms */ -#if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__ -#define HTTPD_POLL_INTERVAL 4 -#endif - -/** Priority for tcp pcbs created by HTTPD (very low by default). - * Lower priorities get killed first when running out of memory. - */ -#if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__ -#define HTTPD_TCP_PRIO TCP_PRIO_MIN -#endif - -/** Set this to 1 to enable timing each file sent */ -#if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__ -#define LWIP_HTTPD_TIMING 0 -#endif -/** Set this to 1 to enable timing each file sent */ -#if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__ -#define HTTPD_DEBUG_TIMING LWIP_DBG_OFF -#endif - -/** Set this to one to show error pages when parsing a request fails instead - of simply closing the connection. */ -#if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_EXTSTATUS 0 -#endif - -/** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */ -#if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_V09 1 -#endif - -/** Set this to 1 to enable HTTP/1.1 persistent connections. - * ATTENTION: If the generated file system includes HTTP headers, these must - * include the "Connection: keep-alive" header (pass argument "-11" to makefsdata). - */ -#if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0 -#endif - -/** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */ -#if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_REQUESTLIST 1 -#endif - -#if LWIP_HTTPD_SUPPORT_REQUESTLIST -/** Number of rx pbufs to enqueue to parse an incoming request (up to the first - newline) */ -#if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__ -#define LWIP_HTTPD_REQ_QUEUELEN 5 -#endif - -/** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming - request (up to the first double-newline) */ -#if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__ -#define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH -#endif - -/** Defines the maximum length of a HTTP request line (up to the first CRLF, - copied from pbuf into this a global buffer when pbuf- or packet-queues - are received - otherwise the input pbuf is used directly) */ -#if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE)) -#endif -#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ - -/** This is the size of a static buffer used when URIs end with '/'. - * In this buffer, the directory requested is concatenated with all the - * configured default file names. - * Set to 0 to disable checking default filenames on non-root directories. - */ -#if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63 -#endif - -/** Maximum length of the filename to send as response to a POST request, - * filled in by the application when a POST is finished. - */ -#if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63 -#endif - -/** Set this to 0 to not send the SSI tag (default is on, so the tag will - * be sent in the HTML page */ -#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI_INCLUDE_TAG 1 -#endif - -/** Set this to 1 to call tcp_abort when tcp_close fails with memory error. - * This can be used to prevent consuming all memory in situations where the - * HTTP server has low priority compared to other communication. */ -#if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__ -#define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0 -#endif - -/** Set this to 1 to kill the oldest connection when running out of - * memory for 'struct http_state' or 'struct http_ssi_state'. - * ATTENTION: This puts all connections on a linked list, so may be kind of slow. - */ -#if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__ -#define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0 -#endif - -/** Set this to 1 to send URIs without extension without headers - * (who uses this at all??) */ -#if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__ -#define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0 -#endif - -/** Default: Tags are sent from struct http_state and are therefore volatile */ -#if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__ -#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY -#endif - -/* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low - when http is not an important protocol in the device. */ -#if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__ -#define HTTPD_LIMIT_SENDING_TO_2MSS 1 -#endif - -/* Define this to a function that returns the maximum amount of data to enqueue. - The function have this signature: u16_t fn(struct tcp_pcb* pcb); */ -#if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__ -#if HTTPD_LIMIT_SENDING_TO_2MSS -#define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb)) -#endif -#endif - -/*------------------- FS OPTIONS -------------------*/ - -/** Set this to 1 and provide the functions: - * - "int fs_open_custom(struct fs_file *file, const char *name)" - * Called first for every opened file to allow opening files - * that are not included in fsdata(_custom).c - * - "void fs_close_custom(struct fs_file *file)" - * Called to free resources allocated by fs_open_custom(). - */ -#if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__ -#define LWIP_HTTPD_CUSTOM_FILES 0 -#endif - -/** Set this to 1 to support fs_read() to dynamically read file data. - * Without this (default=off), only one-block files are supported, - * and the contents must be ready after fs_open(). - */ -#if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__ -#define LWIP_HTTPD_DYNAMIC_FILE_READ 0 -#endif - -/** Set this to 1 to include an application state argument per file - * that is opened. This allows to keep a state per connection/file. - */ -#if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__ -#define LWIP_HTTPD_FILE_STATE 0 -#endif - -/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for - * predefined (MSS-sized) chunks of the files to prevent having to calculate - * the checksums at runtime. */ -#if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__ -#define HTTPD_PRECALCULATED_CHECKSUM 0 -#endif - -/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations - * (fs_read_async returns FS_READ_DELAYED and calls a callback when finished). - */ -#if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__ -#define LWIP_HTTPD_FS_ASYNC_READ 0 -#endif - -/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the - * file system (to prevent changing the file included in CVS) */ -#if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__ -#define HTTPD_USE_CUSTOM_FSDATA 0 -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */ diff --git a/include/net/apps/lwiperf.h b/include/net/apps/lwiperf.h deleted file mode 100644 index 63a0c0c..0000000 --- a/include/net/apps/lwiperf.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file - * lwIP iPerf server implementation - */ - -/* - * Copyright (c) 2014 Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_APPS_LWIPERF_H -#define LWIP_HDR_APPS_LWIPERF_H - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define LWIPERF_TCP_PORT_DEFAULT 5001 - -/** lwIPerf test results */ -enum lwiperf_report_type -{ - /** The server side test is done */ - LWIPERF_TCP_DONE_SERVER, - /** The client side test is done */ - LWIPERF_TCP_DONE_CLIENT, - /** Local error lead to test abort */ - LWIPERF_TCP_ABORTED_LOCAL, - /** Data check error lead to test abort */ - LWIPERF_TCP_ABORTED_LOCAL_DATAERROR, - /** Transmit error lead to test abort */ - LWIPERF_TCP_ABORTED_LOCAL_TXERROR, - /** Remote side aborted the test */ - LWIPERF_TCP_ABORTED_REMOTE -}; - -/** Prototype of a report function that is called when a session is finished. - This report function can show the test results. - @param report_type contains the test result */ -typedef void (*lwiperf_report_fn)(void *arg, enum lwiperf_report_type report_type, - const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port, - u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec); - - -void* lwiperf_start_tcp_server(const ip_addr_t* local_addr, u16_t local_port, - lwiperf_report_fn report_fn, void* report_arg); -void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg); -void lwiperf_abort(void* lwiperf_session); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_LWIPERF_H */ diff --git a/include/net/apps/mdns.h b/include/net/apps/mdns.h deleted file mode 100644 index b19f80c..0000000 --- a/include/net/apps/mdns.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file - * MDNS responder - */ - - /* - * Copyright (c) 2015 Verisure Innovation AB - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Ekman - * - */ -#ifndef LWIP_HDR_MDNS_H -#define LWIP_HDR_MDNS_H - -#include "lwip/apps/mdns_opts.h" -#include "lwip/netif.h" - -#if LWIP_MDNS_RESPONDER - -enum mdns_sd_proto { - DNSSD_PROTO_UDP = 0, - DNSSD_PROTO_TCP = 1 -}; - -#define MDNS_LABEL_MAXLEN 63 - -struct mdns_host; -struct mdns_service; - -/** Callback function to add text to a reply, called when generating the reply */ -typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata); - -void mdns_resp_init(void); - -err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl); -err_t mdns_resp_remove_netif(struct netif *netif); - -err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata); -err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len); -void mdns_resp_netif_settings_changed(struct netif *netif); - -#endif /* LWIP_MDNS_RESPONDER */ - -#endif /* LWIP_HDR_MDNS_H */ diff --git a/include/net/apps/mdns_opts.h b/include/net/apps/mdns_opts.h deleted file mode 100644 index 9f8e5f5..0000000 --- a/include/net/apps/mdns_opts.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file - * MDNS responder - */ - - /* - * Copyright (c) 2015 Verisure Innovation AB - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Ekman - * - */ - -#ifndef LWIP_HDR_APPS_MDNS_OPTS_H -#define LWIP_HDR_APPS_MDNS_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup mdns_opts Options - * @ingroup mdns - * @{ - */ - -/** - * LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS - * transport. IGMP is needed for IPv4 multicast. - */ -#ifndef LWIP_MDNS_RESPONDER -#define LWIP_MDNS_RESPONDER 0 -#endif /* LWIP_MDNS_RESPONDER */ - -/** The maximum number of services per netif */ -#ifndef MDNS_MAX_SERVICES -#define MDNS_MAX_SERVICES 1 -#endif - -/** - * MDNS_DEBUG: Enable debugging for multicast DNS. - */ -#ifndef MDNS_DEBUG -#define MDNS_DEBUG LWIP_DBG_OFF -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_MDNS_OPTS_H */ - diff --git a/include/net/apps/mdns_priv.h b/include/net/apps/mdns_priv.h deleted file mode 100644 index 9a48b5f..0000000 --- a/include/net/apps/mdns_priv.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file - * MDNS responder private definitions - */ - - /* - * Copyright (c) 2015 Verisure Innovation AB - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Ekman - * - */ -#ifndef LWIP_HDR_MDNS_PRIV_H -#define LWIP_HDR_MDNS_PRIV_H - -#include "lwip/apps/mdns_opts.h" -#include "lwip/pbuf.h" - -#if LWIP_MDNS_RESPONDER - -/* Domain struct and methods - visible for unit tests */ - -#define MDNS_DOMAIN_MAXLEN 256 -#define MDNS_READNAME_ERROR 0xFFFF - -struct mdns_domain { - /* Encoded domain name */ - u8_t name[MDNS_DOMAIN_MAXLEN]; - /* Total length of domain name, including zero */ - u16_t length; - /* Set if compression of this domain is not allowed */ - u8_t skip_compression; -}; - -err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len); -u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain); -int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b); -u16_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain); - -#endif /* LWIP_MDNS_RESPONDER */ - -#endif /* LWIP_HDR_MDNS_PRIV_H */ diff --git a/include/net/apps/mqtt.h b/include/net/apps/mqtt.h deleted file mode 100644 index f0f5bab..0000000 --- a/include/net/apps/mqtt.h +++ /dev/null @@ -1,244 +0,0 @@ -/** - * @file - * MQTT client - */ - -/* - * Copyright (c) 2016 Erik Andersson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Andersson - * - */ -#ifndef LWIP_HDR_APPS_MQTT_CLIENT_H -#define LWIP_HDR_APPS_MQTT_CLIENT_H - -#include "lwip/apps/mqtt_opts.h" -#include "lwip/err.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct mqtt_client_t mqtt_client_t; - -/** @ingroup mqtt - * Default MQTT port */ -#define MQTT_PORT 1883 - -/*---------------------------------------------------------------------------------------------- */ -/* Connection with server */ - -/** - * @ingroup mqtt - * Client information and connection parameters */ -struct mqtt_connect_client_info_t { - /** Client identifier, must be set by caller */ - const char *client_id; - /** User name and password, set to NULL if not used */ - const char* client_user; - const char* client_pass; - /** keep alive time in seconds, 0 to disable keep alive functionality*/ - u16_t keep_alive; - /** will topic, set to NULL if will is not to be used, - will_msg, will_qos and will retain are then ignored */ - const char* will_topic; - const char* will_msg; - u8_t will_qos; - u8_t will_retain; -}; - -/** - * @ingroup mqtt - * Connection status codes */ -typedef enum -{ - MQTT_CONNECT_ACCEPTED = 0, - MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1, - MQTT_CONNECT_REFUSED_IDENTIFIER = 2, - MQTT_CONNECT_REFUSED_SERVER = 3, - MQTT_CONNECT_REFUSED_USERNAME_PASS = 4, - MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5, - MQTT_CONNECT_DISCONNECTED = 256, - MQTT_CONNECT_TIMEOUT = 257 -} mqtt_connection_status_t; - -/** - * @ingroup mqtt - * Function prototype for mqtt connection status callback. Called when - * client has connected to the server after initiating a mqtt connection attempt by - * calling mqtt_connect() or when connection is closed by server or an error - * - * @param client MQTT client itself - * @param arg Additional argument to pass to the callback function - * @param status Connect result code or disconnection notification @see mqtt_connection_status_t - * - */ -typedef void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status); - - -/** - * @ingroup mqtt - * Data callback flags */ -enum { - /** Flag set when last fragment of data arrives in data callback */ - MQTT_DATA_FLAG_LAST = 1 -}; - -/** - * @ingroup mqtt - * Function prototype for MQTT incoming publish data callback function. Called when data - * arrives to a subscribed topic @see mqtt_subscribe - * - * @param arg Additional argument to pass to the callback function - * @param data User data, pointed object, data may not be referenced after callback return, - NULL is passed when all publish data are delivered - * @param len Length of publish data fragment - * @param flags MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message - * - */ -typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags); - - -/** - * @ingroup mqtt - * Function prototype for MQTT incoming publish function. Called when an incoming publish - * arrives to a subscribed topic @see mqtt_subscribe - * - * @param arg Additional argument to pass to the callback function - * @param topic Zero terminated Topic text string, topic may not be referenced after callback return - * @param tot_len Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked - */ -typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len); - - -/** - * @ingroup mqtt - * Function prototype for mqtt request callback. Called when a subscribe, unsubscribe - * or publish request has completed - * @param arg Pointer to user data supplied when invoking request - * @param err ERR_OK on success - * ERR_TIMEOUT if no response was received within timeout, - * ERR_ABRT if (un)subscribe was denied - */ -typedef void (*mqtt_request_cb_t)(void *arg, err_t err); - - -/** - * Pending request item, binds application callback to pending server requests - */ -struct mqtt_request_t -{ - /** Next item in list, NULL means this is the last in chain, - next pointing at itself means request is unallocated */ - struct mqtt_request_t *next; - /** Callback to upper layer */ - mqtt_request_cb_t cb; - void *arg; - /** MQTT packet identifier */ - u16_t pkt_id; - /** Expire time relative to element before this */ - u16_t timeout_diff; -}; - -/** Ring buffer */ -struct mqtt_ringbuf_t { - u16_t put; - u16_t get; - u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE]; -}; - -/** MQTT client */ -struct mqtt_client_t -{ - /** Timers and timeouts */ - u16_t cyclic_tick; - u16_t keep_alive; - u16_t server_watchdog; - /** Packet identifier generator*/ - u16_t pkt_id_seq; - /** Packet identifier of pending incoming publish */ - u16_t inpub_pkt_id; - /** Connection state */ - u8_t conn_state; - struct tcp_pcb *conn; - /** Connection callback */ - void *connect_arg; - mqtt_connection_cb_t connect_cb; - /** Pending requests to server */ - struct mqtt_request_t *pend_req_queue; - struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT]; - void *inpub_arg; - /** Incoming data callback */ - mqtt_incoming_data_cb_t data_cb; - mqtt_incoming_publish_cb_t pub_cb; - /** Input */ - u32_t msg_idx; - u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN]; - /** Output ring-buffer */ - struct mqtt_ringbuf_t output; -}; - - -/** Connect to server */ -err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg, - const struct mqtt_connect_client_info_t *client_info); - -/** Disconnect from server */ -void mqtt_disconnect(mqtt_client_t *client); - -/** Create new client */ -mqtt_client_t *mqtt_client_new(void); - -/** Check connection status */ -u8_t mqtt_client_is_connected(mqtt_client_t *client); - -/** Set callback to call for incoming publish */ -void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t, - mqtt_incoming_data_cb_t data_cb, void *arg); - -/** Common function for subscribe and unsubscribe */ -err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub); - -/** @ingroup mqtt - *Subscribe to topic */ -#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1) -/** @ingroup mqtt - * Unsubscribe to topic */ -#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0) - - -/** Publish data to topic */ -err_t mqtt_publish(mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain, - mqtt_request_cb_t cb, void *arg); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_MQTT_CLIENT_H */ diff --git a/include/net/apps/mqtt_opts.h b/include/net/apps/mqtt_opts.h deleted file mode 100644 index 7d07829..0000000 --- a/include/net/apps/mqtt_opts.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file - * MQTT client options - */ - -/* - * Copyright (c) 2016 Erik Andersson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Andersson - * - */ -#ifndef LWIP_HDR_APPS_MQTT_OPTS_H -#define LWIP_HDR_APPS_MQTT_OPTS_H - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup mqtt_opts Options - * @ingroup mqtt - * @{ - */ - -/** - * Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads - */ -#ifndef MQTT_OUTPUT_RINGBUF_SIZE -#define MQTT_OUTPUT_RINGBUF_SIZE 256 -#endif - -/** - * Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8 - * If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8 - */ -#ifndef MQTT_VAR_HEADER_BUFFER_LEN -#define MQTT_VAR_HEADER_BUFFER_LEN 128 -#endif - -/** - * Maximum number of pending subscribe, unsubscribe and publish requests to server . - */ -#ifndef MQTT_REQ_MAX_IN_FLIGHT -#define MQTT_REQ_MAX_IN_FLIGHT 4 -#endif - -/** - * Seconds between each cyclic timer call. - */ -#ifndef MQTT_CYCLIC_TIMER_INTERVAL -#define MQTT_CYCLIC_TIMER_INTERVAL 5 -#endif - -/** - * Publish, subscribe and unsubscribe request timeout in seconds. - */ -#ifndef MQTT_REQ_TIMEOUT -#define MQTT_REQ_TIMEOUT 30 -#endif - -/** - * Seconds for MQTT connect response timeout after sending connect request - */ -#ifndef MQTT_CONNECT_TIMOUT -#define MQTT_CONNECT_TIMOUT 100 -#endif - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_MQTT_OPTS_H */ diff --git a/include/net/apps/netbiosns.h b/include/net/apps/netbiosns.h deleted file mode 100644 index 4126606..0000000 --- a/include/net/apps/netbiosns.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file - * NETBIOS name service responder - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ -#ifndef LWIP_HDR_APPS_NETBIOS_H -#define LWIP_HDR_APPS_NETBIOS_H - -#include "lwip/apps/netbiosns_opts.h" - -void netbiosns_init(void); -#ifndef NETBIOS_LWIP_NAME -void netbiosns_set_name(const char* hostname); -#endif -void netbiosns_stop(void); - -#endif /* LWIP_HDR_APPS_NETBIOS_H */ diff --git a/include/net/apps/netbiosns_opts.h b/include/net/apps/netbiosns_opts.h deleted file mode 100644 index f4d2039..0000000 --- a/include/net/apps/netbiosns_opts.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file - * NETBIOS name service responder options - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ -#ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H -#define LWIP_HDR_APPS_NETBIOS_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup netbiosns_opts Options - * @ingroup netbiosns - * @{ - */ - -/** NetBIOS name of lwip device - * This must be uppercase until NETBIOS_STRCMP() is defined to a string - * comparision function that is case insensitive. - * If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME): - * (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "") - * - * If this is not defined, netbiosns_set_name() can be called at runtime to change the name. - */ -#ifdef __DOXYGEN__ -#define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV" -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */ diff --git a/include/net/apps/snmp.h b/include/net/apps/snmp.h deleted file mode 100644 index 5f267be..0000000 --- a/include/net/apps/snmp.h +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @file - * SNMP server main API - start and basic configuration - */ - -/* - * Copyright (c) 2001, 2002 Leon Woestenberg - * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Leon Woestenberg - * Martin Hentschel - * - */ -#ifndef LWIP_HDR_APPS_SNMP_H -#define LWIP_HDR_APPS_SNMP_H - -#include "lwip/apps/snmp_opts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/err.h" -#include "lwip/apps/snmp_core.h" - -/** SNMP variable binding descriptor (publically needed for traps) */ -struct snmp_varbind -{ - /** pointer to next varbind, NULL for last in list */ - struct snmp_varbind *next; - /** pointer to previous varbind, NULL for first in list */ - struct snmp_varbind *prev; - - /** object identifier */ - struct snmp_obj_id oid; - - /** value ASN1 type */ - u8_t type; - /** object value length */ - u16_t value_len; - /** object value */ - void *value; -}; - -/** - * @ingroup snmp_core - * Agent setup, start listening to port 161. - */ -void snmp_init(void); -void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs); - -void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid); -const struct snmp_obj_id* snmp_get_device_enterprise_oid(void); - -void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); -void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst); - -/** Generic trap: cold start */ -#define SNMP_GENTRAP_COLDSTART 0 -/** Generic trap: warm start */ -#define SNMP_GENTRAP_WARMSTART 1 -/** Generic trap: link down */ -#define SNMP_GENTRAP_LINKDOWN 2 -/** Generic trap: link up */ -#define SNMP_GENTRAP_LINKUP 3 -/** Generic trap: authentication failure */ -#define SNMP_GENTRAP_AUTH_FAILURE 4 -/** Generic trap: EGP neighbor lost */ -#define SNMP_GENTRAP_EGP_NEIGHBOR_LOSS 5 -/** Generic trap: enterprise specific */ -#define SNMP_GENTRAP_ENTERPRISE_SPECIFIC 6 - -err_t snmp_send_trap_generic(s32_t generic_trap); -err_t snmp_send_trap_specific(s32_t specific_trap, struct snmp_varbind *varbinds); -err_t snmp_send_trap(const struct snmp_obj_id* oid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds); - -#define SNMP_AUTH_TRAPS_DISABLED 0 -#define SNMP_AUTH_TRAPS_ENABLED 1 -void snmp_set_auth_traps_enabled(u8_t enable); -u8_t snmp_get_auth_traps_enabled(void); - -const char * snmp_get_community(void); -const char * snmp_get_community_write(void); -const char * snmp_get_community_trap(void); -void snmp_set_community(const char * const community); -void snmp_set_community_write(const char * const community); -void snmp_set_community_trap(const char * const community); - -void snmp_coldstart_trap(void); -void snmp_authfail_trap(void); - -typedef void (*snmp_write_callback_fct)(const u32_t* oid, u8_t oid_len, void* callback_arg); -void snmp_set_write_callback(snmp_write_callback_fct write_callback, void* callback_arg); - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_H */ diff --git a/include/net/apps/snmp_core.h b/include/net/apps/snmp_core.h deleted file mode 100644 index a832572..0000000 --- a/include/net/apps/snmp_core.h +++ /dev/null @@ -1,364 +0,0 @@ -/** - * @file - * SNMP core API for implementing MIBs - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - * Martin Hentschel - */ - -#ifndef LWIP_HDR_APPS_SNMP_CORE_H -#define LWIP_HDR_APPS_SNMP_CORE_H - -#include "lwip/apps/snmp_opts.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/ip_addr.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* basic ASN1 defines */ -#define SNMP_ASN1_CLASS_UNIVERSAL 0x00 -#define SNMP_ASN1_CLASS_APPLICATION 0x40 -#define SNMP_ASN1_CLASS_CONTEXT 0x80 -#define SNMP_ASN1_CLASS_PRIVATE 0xC0 - -#define SNMP_ASN1_CONTENTTYPE_PRIMITIVE 0x00 -#define SNMP_ASN1_CONTENTTYPE_CONSTRUCTED 0x20 - -/* universal tags (from ASN.1 spec.) */ -#define SNMP_ASN1_UNIVERSAL_END_OF_CONTENT 0 -#define SNMP_ASN1_UNIVERSAL_INTEGER 2 -#define SNMP_ASN1_UNIVERSAL_OCTET_STRING 4 -#define SNMP_ASN1_UNIVERSAL_NULL 5 -#define SNMP_ASN1_UNIVERSAL_OBJECT_ID 6 -#define SNMP_ASN1_UNIVERSAL_SEQUENCE_OF 16 - -/* application specific (SNMP) tags (from SNMPv2-SMI) */ -#define SNMP_ASN1_APPLICATION_IPADDR 0 /* [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4)) */ -#define SNMP_ASN1_APPLICATION_COUNTER 1 /* [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) => u32_t */ -#define SNMP_ASN1_APPLICATION_GAUGE 2 /* [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) => u32_t */ -#define SNMP_ASN1_APPLICATION_TIMETICKS 3 /* [APPLICATION 3] IMPLICIT INTEGER (0..4294967295) => u32_t */ -#define SNMP_ASN1_APPLICATION_OPAQUE 4 /* [APPLICATION 4] IMPLICIT OCTET STRING */ -#define SNMP_ASN1_APPLICATION_COUNTER64 6 /* [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615) */ - -/* context specific (SNMP) tags (from RFC 1905) */ -#define SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE 1 - -/* full ASN1 type defines */ -#define SNMP_ASN1_TYPE_END_OF_CONTENT (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_END_OF_CONTENT) -#define SNMP_ASN1_TYPE_INTEGER (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_INTEGER) -#define SNMP_ASN1_TYPE_OCTET_STRING (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OCTET_STRING) -#define SNMP_ASN1_TYPE_NULL (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_NULL) -#define SNMP_ASN1_TYPE_OBJECT_ID (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OBJECT_ID) -#define SNMP_ASN1_TYPE_SEQUENCE (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_CONSTRUCTED | SNMP_ASN1_UNIVERSAL_SEQUENCE_OF) -#define SNMP_ASN1_TYPE_IPADDR (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_IPADDR) -#define SNMP_ASN1_TYPE_IPADDRESS SNMP_ASN1_TYPE_IPADDR -#define SNMP_ASN1_TYPE_COUNTER (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER) -#define SNMP_ASN1_TYPE_COUNTER32 SNMP_ASN1_TYPE_COUNTER -#define SNMP_ASN1_TYPE_GAUGE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_GAUGE) -#define SNMP_ASN1_TYPE_GAUGE32 SNMP_ASN1_TYPE_GAUGE -#define SNMP_ASN1_TYPE_UNSIGNED32 SNMP_ASN1_TYPE_GAUGE -#define SNMP_ASN1_TYPE_TIMETICKS (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_TIMETICKS) -#define SNMP_ASN1_TYPE_OPAQUE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_OPAQUE) -#define SNMP_ASN1_TYPE_COUNTER64 (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER64) - -#define SNMP_VARBIND_EXCEPTION_OFFSET 0xF0 -#define SNMP_VARBIND_EXCEPTION_MASK 0x0F - -/** error codes predefined by SNMP prot. */ -typedef enum { - SNMP_ERR_NOERROR = 0, -/* -outdated v1 error codes. do not use anmore! -#define SNMP_ERR_NOSUCHNAME 2 use SNMP_ERR_NOSUCHINSTANCE instead -#define SNMP_ERR_BADVALUE 3 use SNMP_ERR_WRONGTYPE,SNMP_ERR_WRONGLENGTH,SNMP_ERR_WRONGENCODING or SNMP_ERR_WRONGVALUE instead -#define SNMP_ERR_READONLY 4 use SNMP_ERR_NOTWRITABLE instead -*/ - SNMP_ERR_GENERROR = 5, - SNMP_ERR_NOACCESS = 6, - SNMP_ERR_WRONGTYPE = 7, - SNMP_ERR_WRONGLENGTH = 8, - SNMP_ERR_WRONGENCODING = 9, - SNMP_ERR_WRONGVALUE = 10, - SNMP_ERR_NOCREATION = 11, - SNMP_ERR_INCONSISTENTVALUE = 12, - SNMP_ERR_RESOURCEUNAVAILABLE = 13, - SNMP_ERR_COMMITFAILED = 14, - SNMP_ERR_UNDOFAILED = 15, - SNMP_ERR_NOTWRITABLE = 17, - SNMP_ERR_INCONSISTENTNAME = 18, - - SNMP_ERR_NOSUCHINSTANCE = SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE -} snmp_err_t; - -/** internal object identifier representation */ -struct snmp_obj_id -{ - u8_t len; - u32_t id[SNMP_MAX_OBJ_ID_LEN]; -}; - -struct snmp_obj_id_const_ref -{ - u8_t len; - const u32_t* id; -}; - -extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero; /* administrative identifier from SNMPv2-SMI */ - -/** SNMP variant value, used as reference in struct snmp_node_instance and table implementation */ -union snmp_variant_value -{ - void* ptr; - const void* const_ptr; - u32_t u32; - s32_t s32; -}; - - -/** -SNMP MIB node types - tree node is the only node the stack can process in order to walk the tree, - all other nodes are assumed to be leaf nodes. - This cannot be an enum because users may want to define their own node types. -*/ -#define SNMP_NODE_TREE 0x00 -/* predefined leaf node types */ -#define SNMP_NODE_SCALAR 0x01 -#define SNMP_NODE_SCALAR_ARRAY 0x02 -#define SNMP_NODE_TABLE 0x03 -#define SNMP_NODE_THREADSYNC 0x04 - -/** node "base class" layout, the mandatory fields for a node */ -struct snmp_node -{ - /** one out of SNMP_NODE_TREE or any leaf node type (like SNMP_NODE_SCALAR) */ - u8_t node_type; - /** the number assigned to this node which used as part of the full OID */ - u32_t oid; -}; - -/** SNMP node instance access types */ -typedef enum { - SNMP_NODE_INSTANCE_ACCESS_READ = 1, - SNMP_NODE_INSTANCE_ACCESS_WRITE = 2, - SNMP_NODE_INSTANCE_READ_ONLY = SNMP_NODE_INSTANCE_ACCESS_READ, - SNMP_NODE_INSTANCE_READ_WRITE = (SNMP_NODE_INSTANCE_ACCESS_READ | SNMP_NODE_INSTANCE_ACCESS_WRITE), - SNMP_NODE_INSTANCE_WRITE_ONLY = SNMP_NODE_INSTANCE_ACCESS_WRITE, - SNMP_NODE_INSTANCE_NOT_ACCESSIBLE = 0 -} snmp_access_t; - -struct snmp_node_instance; - -typedef s16_t (*node_instance_get_value_method)(struct snmp_node_instance*, void*); -typedef snmp_err_t (*node_instance_set_test_method)(struct snmp_node_instance*, u16_t, void*); -typedef snmp_err_t (*node_instance_set_value_method)(struct snmp_node_instance*, u16_t, void*); -typedef void (*node_instance_release_method)(struct snmp_node_instance*); - -#define SNMP_GET_VALUE_RAW_DATA 0x8000 - -/** SNMP node instance */ -struct snmp_node_instance -{ - /** prefilled with the node, get_instance() is called on; may be changed by user to any value to pass an arbitrary node between calls to get_instance() and get_value/test_value/set_value */ - const struct snmp_node* node; - /** prefilled with the instance id requested; for get_instance() this is the exact oid requested; for get_next_instance() this is the relative starting point, stack expects relative oid of next node here */ - struct snmp_obj_id instance_oid; - - /** ASN type for this object (see snmp_asn1.h for definitions) */ - u8_t asn1_type; - /** one out of instance access types defined above (SNMP_NODE_INSTANCE_READ_ONLY,...) */ - snmp_access_t access; - - /** returns object value for the given object identifier. Return values <0 to indicate an error */ - node_instance_get_value_method get_value; - /** tests length and/or range BEFORE setting */ - node_instance_set_test_method set_test; - /** sets object value, only called when set_test() was successful */ - node_instance_set_value_method set_value; - /** called in any case when the instance is not required anymore by stack (useful for freeing memory allocated in get_instance/get_next_instance methods) */ - node_instance_release_method release_instance; - - /** reference to pass arbitrary value between calls to get_instance() and get_value/test_value/set_value */ - union snmp_variant_value reference; - /** see reference (if reference is a pointer, the length of underlying data may be stored here or anything else) */ - u32_t reference_len; -}; - - -/** SNMP tree node */ -struct snmp_tree_node -{ - /** inherited "base class" members */ - struct snmp_node node; - u16_t subnode_count; - const struct snmp_node* const *subnodes; -}; - -#define SNMP_CREATE_TREE_NODE(oid, subnodes) \ - {{ SNMP_NODE_TREE, (oid) }, \ - (u16_t)LWIP_ARRAYSIZE(subnodes), (subnodes) } - -#define SNMP_CREATE_EMPTY_TREE_NODE(oid) \ - {{ SNMP_NODE_TREE, (oid) }, \ - 0, NULL } - -/** SNMP leaf node */ -struct snmp_leaf_node -{ - /** inherited "base class" members */ - struct snmp_node node; - snmp_err_t (*get_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - snmp_err_t (*get_next_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -}; - -/** represents a single mib with its base oid and root node */ -struct snmp_mib -{ - const u32_t *base_oid; - u8_t base_oid_len; - const struct snmp_node *root_node; -}; - -#define SNMP_MIB_CREATE(oid_list, root_node) { (oid_list), (u8_t)LWIP_ARRAYSIZE(oid_list), root_node } - -/** OID range structure */ -struct snmp_oid_range -{ - u32_t min; - u32_t max; -}; - -/** checks if incoming OID length and values are in allowed ranges */ -u8_t snmp_oid_in_range(const u32_t *oid_in, u8_t oid_len, const struct snmp_oid_range *oid_ranges, u8_t oid_ranges_len); - -typedef enum { - SNMP_NEXT_OID_STATUS_SUCCESS, - SNMP_NEXT_OID_STATUS_NO_MATCH, - SNMP_NEXT_OID_STATUS_BUF_TO_SMALL -} snmp_next_oid_status_t; - -/** state for next_oid_init / next_oid_check functions */ -struct snmp_next_oid_state -{ - const u32_t* start_oid; - u8_t start_oid_len; - - u32_t* next_oid; - u8_t next_oid_len; - u8_t next_oid_max_len; - - snmp_next_oid_status_t status; - void* reference; -}; - -void snmp_next_oid_init(struct snmp_next_oid_state *state, - const u32_t *start_oid, u8_t start_oid_len, - u32_t *next_oid_buf, u8_t next_oid_max_len); -u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len); -u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference); - -void snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len); -void snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len); -void snmp_oid_prefix(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len); -void snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len); -u8_t snmp_oid_equal(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len); -s8_t snmp_oid_compare(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len); - -#if LWIP_IPV4 -u8_t snmp_oid_to_ip4(const u32_t *oid, ip4_addr_t *ip); -void snmp_ip4_to_oid(const ip4_addr_t *ip, u32_t *oid); -#endif /* LWIP_IPV4 */ -#if LWIP_IPV6 -u8_t snmp_oid_to_ip6(const u32_t *oid, ip6_addr_t *ip); -void snmp_ip6_to_oid(const ip6_addr_t *ip, u32_t *oid); -#endif /* LWIP_IPV6 */ -#if LWIP_IPV4 || LWIP_IPV6 -u8_t snmp_ip_to_oid(const ip_addr_t *ip, u32_t *oid); -u8_t snmp_ip_port_to_oid(const ip_addr_t *ip, u16_t port, u32_t *oid); - -u8_t snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip); -u8_t snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port); -#endif /* LWIP_IPV4 || LWIP_IPV6 */ - -struct netif; -u8_t netif_to_num(const struct netif *netif); - -snmp_err_t snmp_set_test_ok(struct snmp_node_instance* instance, u16_t value_len, void* value); /* generic function which can be used if test is always successful */ - -err_t snmp_decode_bits(const u8_t *buf, u32_t buf_len, u32_t *bit_value); -err_t snmp_decode_truthvalue(const s32_t *asn1_value, u8_t *bool_value); -u8_t snmp_encode_bits(u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count); -u8_t snmp_encode_truthvalue(s32_t *asn1_value, u32_t bool_value); - -struct snmp_statistics -{ - u32_t inpkts; - u32_t outpkts; - u32_t inbadversions; - u32_t inbadcommunitynames; - u32_t inbadcommunityuses; - u32_t inasnparseerrs; - u32_t intoobigs; - u32_t innosuchnames; - u32_t inbadvalues; - u32_t inreadonlys; - u32_t ingenerrs; - u32_t intotalreqvars; - u32_t intotalsetvars; - u32_t ingetrequests; - u32_t ingetnexts; - u32_t insetrequests; - u32_t ingetresponses; - u32_t intraps; - u32_t outtoobigs; - u32_t outnosuchnames; - u32_t outbadvalues; - u32_t outgenerrs; - u32_t outgetrequests; - u32_t outgetnexts; - u32_t outsetrequests; - u32_t outgetresponses; - u32_t outtraps; -}; - -extern struct snmp_statistics snmp_stats; - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* LWIP_HDR_APPS_SNMP_CORE_H */ diff --git a/include/net/apps/snmp_mib2.h b/include/net/apps/snmp_mib2.h deleted file mode 100644 index 392ee25..0000000 --- a/include/net/apps/snmp_mib2.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file - * SNMP MIB2 API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Dirk Ziegelmeier - * - */ -#ifndef LWIP_HDR_APPS_SNMP_MIB2_H -#define LWIP_HDR_APPS_SNMP_MIB2_H - -#include "lwip/apps/snmp_opts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ -#if SNMP_LWIP_MIB2 - -#include "lwip/apps/snmp_core.h" - -extern const struct snmp_mib mib2; - -#if SNMP_USE_NETCONN -#include "lwip/apps/snmp_threadsync.h" -void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg); -extern struct snmp_threadsync_instance snmp_mib2_lwip_locks; -#endif - -#ifndef SNMP_SYSSERVICES -#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) -#endif - -void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */ -void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); -void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen); -void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); -void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen); -void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); -void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen); - -#endif /* SNMP_LWIP_MIB2 */ -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_MIB2_H */ diff --git a/include/net/apps/snmp_opts.h b/include/net/apps/snmp_opts.h deleted file mode 100644 index d4ae068..0000000 --- a/include/net/apps/snmp_opts.h +++ /dev/null @@ -1,293 +0,0 @@ -/** - * @file - * SNMP server options list - */ - -/* - * Copyright (c) 2015 Dirk Ziegelmeier - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Dirk Ziegelmeier - * - */ -#ifndef LWIP_HDR_SNMP_OPTS_H -#define LWIP_HDR_SNMP_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup snmp_opts Options - * @ingroup snmp - * @{ - */ - -/** - * LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available - * for SNMP transport. - * If you want to use your own SNMP agent, leave this disabled. - * To integrate MIB2 of an external agent, you need to enable - * LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks - * and statistics counters you need to get MIB2 working. - */ -#if !defined LWIP_SNMP || defined __DOXYGEN__ -#define LWIP_SNMP 0 -#endif - -/** - * SNMP_USE_NETCONN: Use netconn API instead of raw API. - * Makes SNMP agent run in a worker thread, so blocking operations - * can be done in MIB calls. - */ -#if !defined SNMP_USE_NETCONN || defined __DOXYGEN__ -#define SNMP_USE_NETCONN 0 -#endif - -/** - * SNMP_USE_RAW: Use raw API. - * SNMP agent does not run in a worker thread, so blocking operations - * should not be done in MIB calls. - */ -#if !defined SNMP_USE_RAW || defined __DOXYGEN__ -#define SNMP_USE_RAW 1 -#endif - -#if SNMP_USE_NETCONN && SNMP_USE_RAW -#error SNMP stack can use only one of the APIs {raw, netconn} -#endif - -#if LWIP_SNMP && !SNMP_USE_NETCONN && !SNMP_USE_RAW -#error SNMP stack needs a receive API and UDP {raw, netconn} -#endif - -#if SNMP_USE_NETCONN -/** - * SNMP_STACK_SIZE: Stack size of SNMP netconn worker thread - */ -#if !defined SNMP_STACK_SIZE || defined __DOXYGEN__ -#define SNMP_STACK_SIZE DEFAULT_THREAD_STACKSIZE -#endif - -/** - * SNMP_THREAD_PRIO: SNMP netconn worker thread priority - */ -#if !defined SNMP_THREAD_PRIO || defined __DOXYGEN__ -#define SNMP_THREAD_PRIO DEFAULT_THREAD_PRIO -#endif -#endif /* SNMP_USE_NETCONN */ - -/** - * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap - * destination is required - */ -#if !defined SNMP_TRAP_DESTINATIONS || defined __DOXYGEN__ -#define SNMP_TRAP_DESTINATIONS 1 -#endif - -/** - * Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not - * a safe action and disabled when SNMP_SAFE_REQUESTS = 1). - * Unsafe requests are disabled by default! - */ -#if !defined SNMP_SAFE_REQUESTS || defined __DOXYGEN__ -#define SNMP_SAFE_REQUESTS 1 -#endif - -/** - * The maximum length of strings used. - */ -#if !defined SNMP_MAX_OCTET_STRING_LEN || defined __DOXYGEN__ -#define SNMP_MAX_OCTET_STRING_LEN 127 -#endif - -/** - * The maximum number of Sub ID's inside an object identifier. - * Indirectly this also limits the maximum depth of SNMP tree. - */ -#if !defined SNMP_MAX_OBJ_ID_LEN || defined __DOXYGEN__ -#define SNMP_MAX_OBJ_ID_LEN 50 -#endif - -#if !defined SNMP_MAX_VALUE_SIZE || defined __DOXYGEN__ -/** - * The maximum size of a value. - */ -#define SNMP_MIN_VALUE_SIZE (2 * sizeof(u32_t*)) /* size required to store the basic types (8 bytes for counter64) */ -/** - * The minimum size of a value. - */ -#define SNMP_MAX_VALUE_SIZE LWIP_MAX(LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN), sizeof(u32_t)*(SNMP_MAX_OBJ_ID_LEN)), SNMP_MIN_VALUE_SIZE) -#endif - -/** - * The snmp read-access community. Used for write-access and traps, too - * unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively. - */ -#if !defined SNMP_COMMUNITY || defined __DOXYGEN__ -#define SNMP_COMMUNITY "public" -#endif - -/** - * The snmp write-access community. - * Set this community to "" in order to disallow any write access. - */ -#if !defined SNMP_COMMUNITY_WRITE || defined __DOXYGEN__ -#define SNMP_COMMUNITY_WRITE "private" -#endif - -/** - * The snmp community used for sending traps. - */ -#if !defined SNMP_COMMUNITY_TRAP || defined __DOXYGEN__ -#define SNMP_COMMUNITY_TRAP "public" -#endif - -/** - * The maximum length of community string. - * If community names shall be adjusted at runtime via snmp_set_community() calls, - * enter here the possible maximum length (+1 for terminating null character). - */ -#if !defined SNMP_MAX_COMMUNITY_STR_LEN || defined __DOXYGEN__ -#define SNMP_MAX_COMMUNITY_STR_LEN LWIP_MAX(LWIP_MAX(sizeof(SNMP_COMMUNITY), sizeof(SNMP_COMMUNITY_WRITE)), sizeof(SNMP_COMMUNITY_TRAP)) -#endif - -/** - * The OID identifiying the device. This may be the enterprise OID itself or any OID located below it in tree. - */ -#if !defined SNMP_DEVICE_ENTERPRISE_OID || defined __DOXYGEN__ -#define SNMP_LWIP_ENTERPRISE_OID 26381 -/** - * IANA assigned enterprise ID for lwIP is 26381 - * @see http://www.iana.org/assignments/enterprise-numbers - * - * @note this enterprise ID is assigned to the lwIP project, - * all object identifiers living under this ID are assigned - * by the lwIP maintainers! - * @note don't change this define, use snmp_set_device_enterprise_oid() - * - * If you need to create your own private MIB you'll need - * to apply for your own enterprise ID with IANA: - * http://www.iana.org/numbers.html - */ -#define SNMP_DEVICE_ENTERPRISE_OID {1, 3, 6, 1, 4, 1, SNMP_LWIP_ENTERPRISE_OID} -/** - * Length of SNMP_DEVICE_ENTERPRISE_OID - */ -#define SNMP_DEVICE_ENTERPRISE_OID_LEN 7 -#endif - -/** - * SNMP_DEBUG: Enable debugging for SNMP messages. - */ -#if !defined SNMP_DEBUG || defined __DOXYGEN__ -#define SNMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs. - */ -#if !defined SNMP_MIB_DEBUG || defined __DOXYGEN__ -#define SNMP_MIB_DEBUG LWIP_DBG_OFF -#endif - -/** - * Indicates if the MIB2 implementation of LWIP SNMP stack is used. - */ -#if !defined SNMP_LWIP_MIB2 || defined __DOXYGEN__ -#define SNMP_LWIP_MIB2 LWIP_SNMP -#endif - -/** - * Value return for sysDesc field of MIB2. - */ -#if !defined SNMP_LWIP_MIB2_SYSDESC || defined __DOXYGEN__ -#define SNMP_LWIP_MIB2_SYSDESC "lwIP" -#endif - -/** - * Value return for sysName field of MIB2. - * To make sysName field settable, call snmp_mib2_set_sysname() to provide the necessary buffers. - */ -#if !defined SNMP_LWIP_MIB2_SYSNAME || defined __DOXYGEN__ -#define SNMP_LWIP_MIB2_SYSNAME "FQDN-unk" -#endif - -/** - * Value return for sysContact field of MIB2. - * To make sysContact field settable, call snmp_mib2_set_syscontact() to provide the necessary buffers. - */ -#if !defined SNMP_LWIP_MIB2_SYSCONTACT || defined __DOXYGEN__ -#define SNMP_LWIP_MIB2_SYSCONTACT "" -#endif - -/** - * Value return for sysLocation field of MIB2. - * To make sysLocation field settable, call snmp_mib2_set_syslocation() to provide the necessary buffers. - */ -#if !defined SNMP_LWIP_MIB2_SYSLOCATION || defined __DOXYGEN__ -#define SNMP_LWIP_MIB2_SYSLOCATION "" -#endif - -/** - * This value is used to limit the repetitions processed in GetBulk requests (value == 0 means no limitation). - * This may be useful to limit the load for a single request. - * According to SNMP RFC 1905 it is allowed to not return all requested variables from a GetBulk request if system load would be too high. - * so the effect is that the client will do more requests to gather all data. - * For the stack this could be useful in case that SNMP processing is done in TCP/IP thread. In this situation a request with many - * repetitions could block the thread for a longer time. Setting limit here will keep the stack more responsive. - */ -#if !defined SNMP_LWIP_GETBULK_MAX_REPETITIONS || defined __DOXYGEN__ -#define SNMP_LWIP_GETBULK_MAX_REPETITIONS 0 -#endif - -/** - * @} - */ - -/* - ------------------------------------ - ---------- SNMPv3 options ---------- - ------------------------------------ -*/ - -/** - * LWIP_SNMP_V3==1: This enables EXPERIMENTAL SNMPv3 support. LWIP_SNMP must - * also be enabled. - * THIS IS UNDER DEVELOPMENT AND SHOULD NOT BE ENABLED IN PRODUCTS. - */ -#ifndef LWIP_SNMP_V3 -#define LWIP_SNMP_V3 0 -#endif - -#ifndef LWIP_SNMP_V3_CRYPTO -#define LWIP_SNMP_V3_CRYPTO LWIP_SNMP_V3 -#endif - -#ifndef LWIP_SNMP_V3_MBEDTLS -#define LWIP_SNMP_V3_MBEDTLS LWIP_SNMP_V3 -#endif - -#endif /* LWIP_HDR_SNMP_OPTS_H */ diff --git a/include/net/apps/snmp_scalar.h b/include/net/apps/snmp_scalar.h deleted file mode 100644 index 99bcdf9..0000000 --- a/include/net/apps/snmp_scalar.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file - * SNMP server MIB API to implement scalar nodes - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Martin Hentschel - * - */ - -#ifndef LWIP_HDR_APPS_SNMP_SCALAR_H -#define LWIP_HDR_APPS_SNMP_SCALAR_H - -#include "lwip/apps/snmp_opts.h" -#include "lwip/apps/snmp_core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -/** basic scalar node */ -struct snmp_scalar_node -{ - /** inherited "base class" members */ - struct snmp_leaf_node node; - u8_t asn1_type; - snmp_access_t access; - node_instance_get_value_method get_value; - node_instance_set_test_method set_test; - node_instance_set_value_method set_value; -}; - - -snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -#define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \ - {{{ SNMP_NODE_SCALAR, (oid) }, \ - snmp_scalar_get_instance, \ - snmp_scalar_get_next_instance }, \ - (asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) } - -#define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL) - -/** scalar array node - a tree node which contains scalars only as children */ -struct snmp_scalar_array_node_def -{ - u32_t oid; - u8_t asn1_type; - snmp_access_t access; -}; - -typedef s16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*); -typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*); -typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*); - -/** basic scalar array node */ -struct snmp_scalar_array_node -{ - /** inherited "base class" members */ - struct snmp_leaf_node node; - u16_t array_node_count; - const struct snmp_scalar_array_node_def* array_nodes; - snmp_scalar_array_get_value_method get_value; - snmp_scalar_array_set_test_method set_test; - snmp_scalar_array_set_value_method set_value; -}; - -snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -#define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \ - {{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \ - snmp_scalar_array_get_instance, \ - snmp_scalar_array_get_next_instance }, \ - (u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) } - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */ diff --git a/include/net/apps/snmp_table.h b/include/net/apps/snmp_table.h deleted file mode 100644 index 6930d0b..0000000 --- a/include/net/apps/snmp_table.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file - * SNMP server MIB API to implement table nodes - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Martin Hentschel - * - */ - -#ifndef LWIP_HDR_APPS_SNMP_TABLE_H -#define LWIP_HDR_APPS_SNMP_TABLE_H - -#include "lwip/apps/snmp_opts.h" -#include "lwip/apps/snmp_core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -/** default (customizable) read/write table */ -struct snmp_table_col_def -{ - u32_t index; - u8_t asn1_type; - snmp_access_t access; -}; - -/** table node */ -struct snmp_table_node -{ - /** inherited "base class" members */ - struct snmp_leaf_node node; - u16_t column_count; - const struct snmp_table_col_def* columns; - snmp_err_t (*get_cell_instance)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, struct snmp_node_instance* cell_instance); - snmp_err_t (*get_next_cell_instance)(const u32_t* column, struct snmp_obj_id* row_oid, struct snmp_node_instance* cell_instance); - /** returns object value for the given object identifier */ - node_instance_get_value_method get_value; - /** tests length and/or range BEFORE setting */ - node_instance_set_test_method set_test; - /** sets object value, only called when set_test() was successful */ - node_instance_set_value_method set_value; -}; - -snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -#define SNMP_TABLE_CREATE(oid, columns, get_cell_instance_method, get_next_cell_instance_method, get_value_method, set_test_method, set_value_method) \ - {{{ SNMP_NODE_TABLE, (oid) }, \ - snmp_table_get_instance, \ - snmp_table_get_next_instance }, \ - (u16_t)LWIP_ARRAYSIZE(columns), (columns), \ - (get_cell_instance_method), (get_next_cell_instance_method), \ - (get_value_method), (set_test_method), (set_value_method)} - -#define SNMP_TABLE_GET_COLUMN_FROM_OID(oid) ((oid)[1]) /* first array value is (fixed) row entry (fixed to 1) and 2nd value is column, follow3ed by instance */ - - -/** simple read-only table */ -typedef enum { - SNMP_VARIANT_VALUE_TYPE_U32, - SNMP_VARIANT_VALUE_TYPE_S32, - SNMP_VARIANT_VALUE_TYPE_PTR, - SNMP_VARIANT_VALUE_TYPE_CONST_PTR -} snmp_table_column_data_type_t; - -struct snmp_table_simple_col_def -{ - u32_t index; - u8_t asn1_type; - snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/ -}; - -/** simple read-only table node */ -struct snmp_table_simple_node -{ - /* inherited "base class" members */ - struct snmp_leaf_node node; - u16_t column_count; - const struct snmp_table_simple_col_def* columns; - snmp_err_t (*get_cell_value)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len); - snmp_err_t (*get_next_cell_instance_and_value)(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len); -}; - -snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -#define SNMP_TABLE_CREATE_SIMPLE(oid, columns, get_cell_value_method, get_next_cell_instance_and_value_method) \ - {{{ SNMP_NODE_TABLE, (oid) }, \ - snmp_table_simple_get_instance, \ - snmp_table_simple_get_next_instance }, \ - (u16_t)LWIP_ARRAYSIZE(columns), (columns), (get_cell_value_method), (get_next_cell_instance_and_value_method) } - -s16_t snmp_table_extract_value_from_s32ref(struct snmp_node_instance* instance, void* value); -s16_t snmp_table_extract_value_from_u32ref(struct snmp_node_instance* instance, void* value); -s16_t snmp_table_extract_value_from_refconstptr(struct snmp_node_instance* instance, void* value); - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_TABLE_H */ diff --git a/include/net/apps/snmp_threadsync.h b/include/net/apps/snmp_threadsync.h deleted file mode 100644 index 5eb3538..0000000 --- a/include/net/apps/snmp_threadsync.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @file - * SNMP server MIB API to implement thread synchronization - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Dirk Ziegelmeier - * - */ - -#ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H -#define LWIP_HDR_APPS_SNMP_THREADSYNC_H - -#include "lwip/apps/snmp_opts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/apps/snmp_core.h" -#include "lwip/sys.h" - -typedef void (*snmp_threadsync_called_fn)(void* arg); -typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg); - - -/** Thread sync runtime data. For internal usage only. */ -struct threadsync_data -{ - union { - snmp_err_t err; - s16_t s16; - } retval; - union { - const u32_t *root_oid; - void *value; - } arg1; - union { - u8_t root_oid_len; - u16_t len; - } arg2; - const struct snmp_threadsync_node *threadsync_node; - struct snmp_node_instance proxy_instance; -}; - -/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */ -struct snmp_threadsync_instance -{ - sys_sem_t sem; - sys_mutex_t sem_usage_mutex; - snmp_threadsync_synchronizer_fn sync_fn; - struct threadsync_data data; -}; - -/** SNMP thread sync proxy leaf node */ -struct snmp_threadsync_node -{ - /* inherited "base class" members */ - struct snmp_leaf_node node; - - const struct snmp_leaf_node *target; - struct snmp_threadsync_instance *instance; -}; - -snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -/** Create thread sync proxy node */ -#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \ - {{{ SNMP_NODE_THREADSYNC, (oid) }, \ - snmp_threadsync_get_instance, \ - snmp_threadsync_get_next_instance }, \ - (target_leaf_node), \ - (threadsync_instance) } - -/** Create thread sync instance data */ -void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn); - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */ diff --git a/include/net/apps/snmpv3.h b/include/net/apps/snmpv3.h deleted file mode 100644 index 99a7fd2..0000000 --- a/include/net/apps/snmpv3.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file - * Additional SNMPv3 functionality RFC3414 and RFC3826. - */ - -/* - * Copyright (c) 2016 Elias Oenal. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Elias Oenal - */ - -#ifndef LWIP_HDR_APPS_SNMP_V3_H -#define LWIP_HDR_APPS_SNMP_V3_H - -#include "lwip/apps/snmp_opts.h" -#include "lwip/err.h" - -#if LWIP_SNMP && LWIP_SNMP_V3 - -#define SNMP_V3_AUTH_ALGO_INVAL 0 -#define SNMP_V3_AUTH_ALGO_MD5 1 -#define SNMP_V3_AUTH_ALGO_SHA 2 - -#define SNMP_V3_PRIV_ALGO_INVAL 0 -#define SNMP_V3_PRIV_ALGO_DES 1 -#define SNMP_V3_PRIV_ALGO_AES 2 - -#define SNMP_V3_PRIV_MODE_DECRYPT 0 -#define SNMP_V3_PRIV_MODE_ENCRYPT 1 - -/* - * The following callback functions must be implemented by the application. - * There is a dummy implementation in snmpv3_dummy.c. - */ - -void snmpv3_get_engine_id(const char **id, u8_t *len); -err_t snmpv3_set_engine_id(const char* id, u8_t len); - -u32_t snmpv3_get_engine_boots(void); -void snmpv3_set_engine_boots(u32_t boots); - -u32_t snmpv3_get_engine_time(void); -void snmpv3_reset_engine_time(void); - -err_t snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *priv_algo, u8_t *priv_key); - -/* The following functions are provided by the SNMPv3 agent */ - -void snmpv3_engine_id_changed(void); - -void snmpv3_password_to_key_md5( - const u8_t *password, /* IN */ - u8_t passwordlen, /* IN */ - const u8_t *engineID, /* IN - pointer to snmpEngineID */ - u8_t engineLength, /* IN - length of snmpEngineID */ - u8_t *key); /* OUT - pointer to caller 16-octet buffer */ - -void snmpv3_password_to_key_sha( - const u8_t *password, /* IN */ - u8_t passwordlen, /* IN */ - const u8_t *engineID, /* IN - pointer to snmpEngineID */ - u8_t engineLength, /* IN - length of snmpEngineID */ - u8_t *key); /* OUT - pointer to caller 20-octet buffer */ - -#endif - -#endif /* LWIP_HDR_APPS_SNMP_V3_H */ diff --git a/include/net/apps/sntp.h b/include/net/apps/sntp.h deleted file mode 100644 index 3910917..0000000 --- a/include/net/apps/sntp.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file - * SNTP client API - */ - -/* - * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Frédéric Bernon, Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_APPS_SNTP_H -#define LWIP_HDR_APPS_SNTP_H - -#include "lwip/apps/sntp_opts.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* SNTP operating modes: default is to poll using unicast. - The mode has to be set before calling sntp_init(). */ -#define SNTP_OPMODE_POLL 0 -#define SNTP_OPMODE_LISTENONLY 1 -void sntp_setoperatingmode(u8_t operating_mode); -u8_t sntp_getoperatingmode(void); - -void sntp_init(void); -void sntp_stop(void); -u8_t sntp_enabled(void); - -void sntp_setserver(u8_t idx, const ip_addr_t *addr); -const ip_addr_t* sntp_getserver(u8_t idx); - -#if SNTP_SERVER_DNS -void sntp_setservername(u8_t idx, char *server); -char *sntp_getservername(u8_t idx); -#endif /* SNTP_SERVER_DNS */ - -#if SNTP_GET_SERVERS_FROM_DHCP -void sntp_servermode_dhcp(int set_servers_from_dhcp); -#else /* SNTP_GET_SERVERS_FROM_DHCP */ -#define sntp_servermode_dhcp(x) -#endif /* SNTP_GET_SERVERS_FROM_DHCP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNTP_H */ diff --git a/include/net/apps/sntp_opts.h b/include/net/apps/sntp_opts.h deleted file mode 100644 index c28b864..0000000 --- a/include/net/apps/sntp_opts.h +++ /dev/null @@ -1,173 +0,0 @@ -/** - * @file - * SNTP client options list - */ - -/* - * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Frédéric Bernon, Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_APPS_SNTP_OPTS_H -#define LWIP_HDR_APPS_SNTP_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup sntp_opts Options - * @ingroup sntp - * @{ - */ - -/** SNTP macro to change system time in seconds - * Define SNTP_SET_SYSTEM_TIME_US(sec, us) to set the time in microseconds instead of this one - * if you need the additional precision. - */ -#if !defined SNTP_SET_SYSTEM_TIME || defined __DOXYGEN__ -#define SNTP_SET_SYSTEM_TIME(sec) LWIP_UNUSED_ARG(sec) -#endif - -/** The maximum number of SNTP servers that can be set */ -#if !defined SNTP_MAX_SERVERS || defined __DOXYGEN__ -#define SNTP_MAX_SERVERS LWIP_DHCP_MAX_NTP_SERVERS -#endif - -/** Set this to 1 to implement the callback function called by dhcp when - * NTP servers are received. */ -#if !defined SNTP_GET_SERVERS_FROM_DHCP || defined __DOXYGEN__ -#define SNTP_GET_SERVERS_FROM_DHCP LWIP_DHCP_GET_NTP_SRV -#endif - -/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers - * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: - * \#define SNTP_SERVER_ADDRESS "pool.ntp.org" - */ -#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__ -#define SNTP_SERVER_DNS 0 -#endif - -/** - * SNTP_DEBUG: Enable debugging for SNTP. - */ -#if !defined SNTP_DEBUG || defined __DOXYGEN__ -#define SNTP_DEBUG LWIP_DBG_OFF -#endif - -/** SNTP server port */ -#if !defined SNTP_PORT || defined __DOXYGEN__ -#define SNTP_PORT 123 -#endif - -/** Set this to 1 to allow config of SNTP server(s) by DNS name */ -#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__ -#define SNTP_SERVER_DNS 0 -#endif - -/** Sanity check: - * Define this to - * - 0 to turn off sanity checks (default; smaller code) - * - >= 1 to check address and port of the response packet to ensure the - * response comes from the server we sent the request to. - * - >= 2 to check returned Originate Timestamp against Transmit Timestamp - * sent to the server (to ensure response to older request). - * - >= 3 @todo: discard reply if any of the LI, Stratum, or Transmit Timestamp - * fields is 0 or the Mode field is not 4 (unicast) or 5 (broadcast). - * - >= 4 @todo: to check that the Root Delay and Root Dispersion fields are each - * greater than or equal to 0 and less than infinity, where infinity is - * currently a cozy number like one second. This check avoids using a - * server whose synchronization source has expired for a very long time. - */ -#if !defined SNTP_CHECK_RESPONSE || defined __DOXYGEN__ -#define SNTP_CHECK_RESPONSE 0 -#endif - -/** According to the RFC, this shall be a random delay - * between 1 and 5 minutes (in milliseconds) to prevent load peaks. - * This can be defined to a random generation function, - * which must return the delay in milliseconds as u32_t. - * Turned off by default. - */ -#if !defined SNTP_STARTUP_DELAY || defined __DOXYGEN__ -#define SNTP_STARTUP_DELAY 0 -#endif - -/** If you want the startup delay to be a function, define this - * to a function (including the brackets) and define SNTP_STARTUP_DELAY to 1. - */ -#if !defined SNTP_STARTUP_DELAY_FUNC || defined __DOXYGEN__ -#define SNTP_STARTUP_DELAY_FUNC SNTP_STARTUP_DELAY -#endif - -/** SNTP receive timeout - in milliseconds - * Also used as retry timeout - this shouldn't be too low. - * Default is 3 seconds. - */ -#if !defined SNTP_RECV_TIMEOUT || defined __DOXYGEN__ -#define SNTP_RECV_TIMEOUT 3000 -#endif - -/** SNTP update delay - in milliseconds - * Default is 1 hour. Must not be beolw 15 seconds by specification (i.e. 15000) - */ -#if !defined SNTP_UPDATE_DELAY || defined __DOXYGEN__ -#define SNTP_UPDATE_DELAY 3600000 -#endif - -/** SNTP macro to get system time, used with SNTP_CHECK_RESPONSE >= 2 - * to send in request and compare in response. - */ -#if !defined SNTP_GET_SYSTEM_TIME || defined __DOXYGEN__ -#define SNTP_GET_SYSTEM_TIME(sec, us) do { (sec) = 0; (us) = 0; } while(0) -#endif - -/** Default retry timeout (in milliseconds) if the response - * received is invalid. - * This is doubled with each retry until SNTP_RETRY_TIMEOUT_MAX is reached. - */ -#if !defined SNTP_RETRY_TIMEOUT || defined __DOXYGEN__ -#define SNTP_RETRY_TIMEOUT SNTP_RECV_TIMEOUT -#endif - -/** Maximum retry timeout (in milliseconds). */ -#if !defined SNTP_RETRY_TIMEOUT_MAX || defined __DOXYGEN__ -#define SNTP_RETRY_TIMEOUT_MAX (SNTP_RETRY_TIMEOUT * 10) -#endif - -/** Increase retry timeout with every retry sent - * Default is on to conform to RFC. - */ -#if !defined SNTP_RETRY_TIMEOUT_EXP || defined __DOXYGEN__ -#define SNTP_RETRY_TIMEOUT_EXP 1 -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_SNTP_OPTS_H */ diff --git a/include/net/apps/tftp_opts.h b/include/net/apps/tftp_opts.h deleted file mode 100644 index bf115dc..0000000 --- a/include/net/apps/tftp_opts.h +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************//** - * - * @file tftp_opts.h - * - * @author Logan Gunthorpe - * - * @brief Trivial File Transfer Protocol (RFC 1350) implementation options - * - * Copyright (c) Deltatee Enterprises Ltd. 2013 - * All rights reserved. - * - ********************************************************************/ - -/* - * Redistribution and use in source and binary forms, with or without - * modification,are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Author: Logan Gunthorpe - * - */ - -#ifndef LWIP_HDR_APPS_TFTP_OPTS_H -#define LWIP_HDR_APPS_TFTP_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup tftp_opts Options - * @ingroup tftp - * @{ - */ - -/** - * Enable TFTP debug messages - */ -#if !defined TFTP_DEBUG || defined __DOXYGEN__ -#define TFTP_DEBUG LWIP_DBG_ON -#endif - -/** - * TFTP server port - */ -#if !defined TFTP_PORT || defined __DOXYGEN__ -#define TFTP_PORT 69 -#endif - -/** - * TFTP timeout - */ -#if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__ -#define TFTP_TIMEOUT_MSECS 10000 -#endif - -/** - * Max. number of retries when a file is read from server - */ -#if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__ -#define TFTP_MAX_RETRIES 5 -#endif - -/** - * TFTP timer cyclic interval - */ -#if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__ -#define TFTP_TIMER_MSECS 50 -#endif - -/** - * Max. length of TFTP filename - */ -#if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__ -#define TFTP_MAX_FILENAME_LEN 20 -#endif - -/** - * Max. length of TFTP mode - */ -#if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__ -#define TFTP_MAX_MODE_LEN 7 -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_TFTP_OPTS_H */ diff --git a/include/net/apps/tftp_server.h b/include/net/apps/tftp_server.h deleted file mode 100644 index 1ad91dc..0000000 --- a/include/net/apps/tftp_server.h +++ /dev/null @@ -1,94 +0,0 @@ -/****************************************************************//** - * - * @file tftp_server.h - * - * @author Logan Gunthorpe - * - * @brief Trivial File Transfer Protocol (RFC 1350) - * - * Copyright (c) Deltatee Enterprises Ltd. 2013 - * All rights reserved. - * - ********************************************************************/ - -/* - * Redistribution and use in source and binary forms, with or without - * modification,are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Author: Logan Gunthorpe - * - */ - -#ifndef LWIP_HDR_APPS_TFTP_SERVER_H -#define LWIP_HDR_APPS_TFTP_SERVER_H - -#include "lwip/apps/tftp_opts.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup tftp - * TFTP context containing callback functions for TFTP transfers - */ -struct tftp_context { - /** - * Open file for read/write. - * @param fname Filename - * @param mode Mode string from TFTP RFC 1350 (netascii, octet, mail) - * @param write Flag indicating read (0) or write (!= 0) access - * @returns File handle supplied to other functions - */ - void* (*open)(const char* fname, const char* mode, u8_t write); - /** - * Close file handle - * @param handle File handle returned by open() - */ - void (*close)(void* handle); - /** - * Read from file - * @param handle File handle returned by open() - * @param buf Target buffer to copy read data to - * @param bytes Number of bytes to copy to buf - * @returns >= 0: Success; < 0: Error - */ - int (*read)(void* handle, void* buf, int bytes); - /** - * Write to file - * @param handle File handle returned by open() - * @param pbuf PBUF adjusted such that payload pointer points - * to the beginning of write data. In other words, - * TFTP headers are stripped off. - * @returns >= 0: Success; < 0: Error - */ - int (*write)(void* handle, struct pbuf* p); -}; - -err_t tftp_init(const struct tftp_context* ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_TFTP_SERVER_H */ diff --git a/include/net/arch.h b/include/net/arch.h deleted file mode 100644 index da0a1d8..0000000 --- a/include/net/arch.h +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @file - * Support for different processor and compiler architectures - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_ARCH_H -#define LWIP_HDR_ARCH_H - -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1234 -#endif - -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 4321 -#endif - -#include -#include -#include -#include - -/** - * @defgroup compiler_abstraction Compiler/platform abstraction - * @ingroup sys_layer - * All defines related to this section must not be placed in lwipopts.h, - * but in arch/cc.h! - * These options cannot be \#defined in lwipopts.h since they are not options - * of lwIP itself, but options of the lwIP port to your system. - * @{ - */ - -/** Define the byte order of the system. - * Needed for conversion of network data to host byte order. - * Allowed values: LITTLE_ENDIAN and BIG_ENDIAN - */ -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif - -/** Define random number generator function of your system */ -#ifdef __DOXYGEN__ -#define LWIP_RAND() ((u32_t)rand()) -#endif - -/** Platform specific diagnostic output.\n - * Note the default implementation pulls in printf, which may - * in turn pull in a lot of standard libary code. In resource-constrained - * systems, this should be defined to something less resource-consuming. - */ -#ifndef LWIP_PLATFORM_DIAG -#define LWIP_PLATFORM_DIAG(x) do {kprintf x;} while(0) -#endif - -/** Platform specific assertion handling.\n - * Note the default implementation pulls in printf, fflush and abort, which may - * in turn pull in a lot of standard libary code. In resource-constrained - * systems, this should be defined to something less resource-consuming. - */ -#ifndef LWIP_PLATFORM_ASSERT -#define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); kpanic("asserted");} while(0) -#endif - -/** Define this to 1 in arch/cc.h of your port if you do not want to - * include stddef.h header to get size_t. You need to typedef size_t - * by yourself in this case. - */ -#ifndef LWIP_NO_STDDEF_H -#define LWIP_NO_STDDEF_H 0 -#endif - -#if !LWIP_NO_STDDEF_H -/* for size_t */ -/* MrOlsen 2017-12-17 -#include -*/ -#endif - -/** Define this to 1 in arch/cc.h of your port if your compiler does not provide - * the stdint.h header. You need to typedef the generic types listed in - * lwip/arch.h yourself in this case (u8_t, u16_t...). - */ -#ifndef LWIP_NO_STDINT_H -#define LWIP_NO_STDINT_H 0 -#endif - -/* Define generic types used in lwIP */ -#if !LWIP_NO_STDINT_H -/* MrOlsen 2017-12-17 -#include -*/ -typedef uint8_t u8_t; -typedef int8_t s8_t; -typedef uint16_t u16_t; -typedef int16_t s16_t; -typedef uint32_t u32_t; -typedef int32_t s32_t; -typedef uintptr_t mem_ptr_t; -#endif - -/** Define this to 1 in arch/cc.h of your port if your compiler does not provide - * the inttypes.h header. You need to define the format strings listed in - * lwip/arch.h yourself in this case (X8_F, U16_F...). - */ -#ifndef LWIP_NO_INTTYPES_H -#define LWIP_NO_INTTYPES_H 0 -#endif - -/* Define (sn)printf formatters for these lwIP types */ -#if !LWIP_NO_INTTYPES_H -/* MrOlsen -#include -*/ -#ifndef X8_F -#define X8_F "02" PRIx8 -#endif -#ifndef U16_F -#define U16_F PRIu16 -#endif -#ifndef S16_F -#define S16_F PRId16 -#endif -#ifndef X16_F -#define X16_F PRIx16 -#endif -#ifndef U32_F -#define U32_F PRIu32 -#endif -#ifndef S32_F -#define S32_F PRId32 -#endif -#ifndef X32_F -#define X32_F PRIx32 -#endif -#ifndef SZT_F -#define SZT_F PRIuPTR -#endif -#endif - -/** Define this to 1 in arch/cc.h of your port if your compiler does not provide - * the limits.h header. You need to define the type limits yourself in this case - * (e.g. INT_MAX). - */ -#ifndef LWIP_NO_LIMITS_H -#define LWIP_NO_LIMITS_H 0 -#endif - -/* Include limits.h? */ -#if !LWIP_NO_LIMITS_H -/* -#include -*/ -#endif - -/** C++ const_cast(val) equivalent to remove constness from a value (GCC -Wcast-qual) */ -#ifndef LWIP_CONST_CAST -#define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val)) -#endif - -/** Get rid of alignment cast warnings (GCC -Wcast-align) */ -#ifndef LWIP_ALIGNMENT_CAST -#define LWIP_ALIGNMENT_CAST(target_type, val) LWIP_CONST_CAST(target_type, val) -#endif - -/** Get rid of warnings related to pointer-to-numeric and vice-versa casts, - * e.g. "conversion from 'u8_t' to 'void *' of greater size" - */ -#ifndef LWIP_PTR_NUMERIC_CAST -#define LWIP_PTR_NUMERIC_CAST(target_type, val) LWIP_CONST_CAST(target_type, val) -#endif - -/** Allocates a memory buffer of specified size that is of sufficient size to align - * its start address using LWIP_MEM_ALIGN. - * You can declare your own version here e.g. to enforce alignment without adding - * trailing padding bytes (see LWIP_MEM_ALIGN_BUFFER) or your own section placement - * requirements.\n - * e.g. if you use gcc and need 32 bit alignment:\n - * \#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[size] \_\_attribute\_\_((aligned(4)))\n - * or more portable:\n - * \#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u32_t variable_name[(size + sizeof(u32_t) - 1) / sizeof(u32_t)] - */ -#ifndef LWIP_DECLARE_MEMORY_ALIGNED -#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)] -#endif - -/** Calculate memory size for an aligned buffer - returns the next highest - * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and - * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4). - */ -#ifndef LWIP_MEM_ALIGN_SIZE -#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U)) -#endif - -/** Calculate safe memory size for an aligned buffer when using an unaligned - * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the - * start (e.g. if buffer is u8_t[] and actual data will be u32_t*) - */ -#ifndef LWIP_MEM_ALIGN_BUFFER -#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1U)) -#endif - -/** Align a memory pointer to the alignment defined by MEM_ALIGNMENT - * so that ADDR % MEM_ALIGNMENT == 0 - */ -#ifndef LWIP_MEM_ALIGN -#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** Packed structs support. - * Placed BEFORE declaration of a packed struct.\n - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifndef PACK_STRUCT_BEGIN -#define PACK_STRUCT_BEGIN -#endif /* PACK_STRUCT_BEGIN */ - -/** Packed structs support. - * Placed AFTER declaration of a packed struct.\n - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifndef PACK_STRUCT_END -#define PACK_STRUCT_END -#endif /* PACK_STRUCT_END */ - -/** Packed structs support. - * Placed between end of declaration of a packed struct and trailing semicolon.\n - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifndef PACK_STRUCT_STRUCT -#if defined(__GNUC__) || defined(__clang__) -#define PACK_STRUCT_STRUCT __attribute__((packed)) -#else -#define PACK_STRUCT_STRUCT -#endif -#endif /* PACK_STRUCT_STRUCT */ - -/** Packed structs support. - * Wraps u32_t and u16_t members.\n - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifndef PACK_STRUCT_FIELD -#define PACK_STRUCT_FIELD(x) x -#endif /* PACK_STRUCT_FIELD */ - -/** Packed structs support. - * Wraps u8_t members, where some compilers warn that packing is not necessary.\n - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifndef PACK_STRUCT_FLD_8 -#define PACK_STRUCT_FLD_8(x) PACK_STRUCT_FIELD(x) -#endif /* PACK_STRUCT_FLD_8 */ - -/** Packed structs support. - * Wraps members that are packed structs themselves, where some compilers warn that packing is not necessary.\n - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifndef PACK_STRUCT_FLD_S -#define PACK_STRUCT_FLD_S(x) PACK_STRUCT_FIELD(x) -#endif /* PACK_STRUCT_FLD_S */ - -/** Packed structs support using \#include files before and after struct to be packed.\n - * The file included BEFORE the struct is "arch/bpstruct.h".\n - * The file included AFTER the struct is "arch/epstruct.h".\n - * This can be used to implement struct packing on MS Visual C compilers, see - * the Win32 port in the lwIP contrib repository for reference. - * For examples of packed struct declarations, see include/lwip/prot/ subfolder.\n - * A port to GCC/clang is included in lwIP, if you use these compilers there is nothing to do here. - */ -#ifdef __DOXYGEN__ -#define PACK_STRUCT_USE_INCLUDES -#endif - -/** Eliminates compiler warning about unused arguments (GCC -Wextra -Wunused). */ -#ifndef LWIP_UNUSED_ARG -#define LWIP_UNUSED_ARG(x) (void)x -#endif /* LWIP_UNUSED_ARG */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_ARCH_H */ diff --git a/include/net/arch/cc.h b/include/net/arch/cc.h deleted file mode 100644 index e910ab9..0000000 --- a/include/net/arch/cc.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ARCH_CC_H__ -#define __ARCH_CC_H__ - -#include - -#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) -#define PACK_STRUCT_STRUCT __attribute__((packed)) -#define PACK_STRUCT_BEGIN -#define PACK_STRUCT_END - -#define LWIP_ERR_T int -/* -#ifdef LWIP_ERR_T -typedef uint8_t err_t; -#endif -*/ - -#endif diff --git a/include/net/arch/cpu.h b/include/net/arch/cpu.h deleted file mode 100644 index aba02eb..0000000 --- a/include/net/arch/cpu.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __ARCH_CPU_H__ -#define __ARCH_CPU_H__ - -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif /* BYTE_ORDER */ - -#endif diff --git a/include/net/arch/init.h b/include/net/arch/init.h deleted file mode 100644 index 3967942..0000000 --- a/include/net/arch/init.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __ARCH_INIT_H__ -#define __ARCH_INIT_H__ - -#define TCPIP_INIT_DONE(arg) sys_sem_signal(*(sys_sem_t *)arg) - -#endif diff --git a/include/net/arch/lib.h b/include/net/arch/lib.h deleted file mode 100644 index 3f2385f..0000000 --- a/include/net/arch/lib.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __ARCH_LIB_H__ -#define __ARCH_LIB_H__ - -#ifndef _STRING_H_ -#ifndef _STRING_H -int strlen(const char *str); -int strncmp(const char *str1, const char *str2, int len); -void bcopy(const void *src, void *dest, int len); -void bzero(void *data, int n); -#endif /* _STRING_H */ -#endif /* _STRING_H_ */ - -#endif diff --git a/include/net/arch/perf.h b/include/net/arch/perf.h deleted file mode 100644 index ab8135a..0000000 --- a/include/net/arch/perf.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __ARCH_PERF_H__ -#define __ARCH_PERF_H__ - -#include - -#ifdef PERF -#define PERF_START { \ - unsigned long __c1l, __c1h, __c2l, __c2h; \ - __asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h)) -#define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \ - perf_print(__c1l, __c1h, __c2l, __c2h, x);} - -/*#define PERF_START do { \ - struct tms __perf_start, __perf_end; \ - times(&__perf_start) -#define PERF_STOP(x) times(&__perf_end); \ - perf_print_times(&__perf_start, &__perf_end, x);\ - } while(0)*/ -#else /* PERF */ -#define PERF_START /* null definition */ -#define PERF_STOP(x) /* null definition */ -#endif /* PERF */ - -void perf_print(unsigned long c1l, unsigned long c1h, - unsigned long c2l, unsigned long c2h, - char *key); - -void perf_print_times(struct tms *start, struct tms *end, char *key); - -void perf_init(char *fname); - -#endif diff --git a/include/net/arch/sys_arch.h b/include/net/arch/sys_arch.h deleted file mode 100644 index f228e5a..0000000 --- a/include/net/arch/sys_arch.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __ARCH_SYS_ARCH_H__ -#define __ARCH_SYS_ARCH_H__ - -#include -#include - -#define SYS_MBOX_NULL NULL -#define SYS_SEM_NULL NULL -#define SYS_MBOX_SIZE 100 - -/* Structs */ -struct sys_timeouts { - struct sys_timeout *next; -}; - -struct sys_mutex { - ubthread_mutex_t mutex; -}; - -typedef struct sys_mutex sys_mutex_t; - -struct sys_mbox { - uint32_t head; - uint32_t tail; - - //MrOlsen (2017-12-28) - This will break because size is passable - void *msgs[SYS_MBOX_SIZE]; - - //struct ubthread_mutex *lock; - - struct sys_sem *empty; - struct sys_sem *full; - struct sys_sem *lock; - - int wait_send; - - //void **queue; - //uint32_t size; -}; - -typedef struct sys_mbox sys_mbox_t; - -struct sys_thread { - struct sys_thread *next; - struct sys_timeouts timeouts; - kTask_t *ubthread; - char name[128]; -}; - -typedef struct sys_thread * sys_thread_t; - - -#endif diff --git a/include/net/autoip.h b/include/net/autoip.h deleted file mode 100644 index 7899e40..0000000 --- a/include/net/autoip.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file - * - * AutoIP Automatic LinkLocal IP Configuration - */ - -/* - * - * Copyright (c) 2007 Dominik Spies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Dominik Spies - * - * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform - * with RFC 3927. - * - */ - -#ifndef LWIP_HDR_AUTOIP_H -#define LWIP_HDR_AUTOIP_H - -#include "net/opt.h" - -#if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ - -#include "net/netif.h" -/* #include "net/udp.h" */ -#include "net/etharp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** AutoIP Timing */ -#define AUTOIP_TMR_INTERVAL 100 -#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) - -/** AutoIP state information per netif */ -struct autoip -{ - /** the currently selected, probed, announced or used LL IP-Address */ - ip4_addr_t llipaddr; - /** current AutoIP state machine state */ - u8_t state; - /** sent number of probes or announces, dependent on state */ - u8_t sent_num; - /** ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ - u16_t ttw; - /** ticks until a conflict can be solved by defending */ - u8_t lastconflict; - /** total number of probed/used Link Local IP-Addresses */ - u8_t tried_llipaddr; -}; - - -void autoip_set_struct(struct netif *netif, struct autoip *autoip); -/** Remove a struct autoip previously set to the netif using autoip_set_struct() */ -#define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0) -err_t autoip_start(struct netif *netif); -err_t autoip_stop(struct netif *netif); -void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); -void autoip_tmr(void); -void autoip_network_changed(struct netif *netif); -u8_t autoip_supplied_address(const struct netif *netif); - -/* for lwIP internal use by ip4.c */ -u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr); - -#define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP)) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV4 && LWIP_AUTOIP */ - -#endif /* LWIP_HDR_AUTOIP_H */ diff --git a/include/net/debug.h b/include/net/debug.h deleted file mode 100644 index 2244253..0000000 --- a/include/net/debug.h +++ /dev/null @@ -1,167 +0,0 @@ -/** - * @file - * Debug messages infrastructure - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_DEBUG_H -#define LWIP_HDR_DEBUG_H - -#include -#include - -/** - * @defgroup debugging_levels LWIP_DBG_MIN_LEVEL and LWIP_DBG_TYPES_ON values - * @ingroup lwip_opts_debugmsg - * @{ - */ - -/** @name Debug level (LWIP_DBG_MIN_LEVEL) - * @{ - */ -/** Debug level: ALL messages*/ -#define LWIP_DBG_LEVEL_ALL 0x00 -/** Debug level: Warnings. bad checksums, dropped packets, ... */ -#define LWIP_DBG_LEVEL_WARNING 0x01 -/** Debug level: Serious. memory allocation failures, ... */ -#define LWIP_DBG_LEVEL_SERIOUS 0x02 -/** Debug level: Severe */ -#define LWIP_DBG_LEVEL_SEVERE 0x03 -/** - * @} - */ - -#define LWIP_DBG_MASK_LEVEL 0x03 -/* compatibility define only */ -#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL - -/** @name Enable/disable debug messages completely (LWIP_DBG_TYPES_ON) - * @{ - */ -/** flag for LWIP_DEBUGF to enable that debug message */ -#define LWIP_DBG_ON 0x80U -/** flag for LWIP_DEBUGF to disable that debug message */ -#define LWIP_DBG_OFF 0x00U -/** - * @} - */ - -/** @name Debug message types (LWIP_DBG_TYPES_ON) - * @{ - */ -/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ -#define LWIP_DBG_TRACE 0x40U -/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ -#define LWIP_DBG_STATE 0x20U -/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ -#define LWIP_DBG_FRESH 0x10U -/** flag for LWIP_DEBUGF to halt after printing this debug message */ -#define LWIP_DBG_HALT 0x08U -/** - * @} - */ - -/** - * @} - */ - -/** - * @defgroup lwip_assertions Assertion handling - * @ingroup lwip_opts_debug - * @{ - */ -/** - * LWIP_NOASSERT: Disable LWIP_ASSERT checks: - * To disable assertions define LWIP_NOASSERT in arch/cc.h. - */ -#ifdef __DOXYGEN__ -#define LWIP_NOASSERT -#undef LWIP_NOASSERT -#endif -/** - * @} - */ - -#ifndef LWIP_NOASSERT -#define LWIP_ASSERT(message, assertion) do { if (!(assertion)) { \ - LWIP_PLATFORM_ASSERT(message); }} while(0) -#ifndef LWIP_PLATFORM_ASSERT -#error "If you want to use LWIP_ASSERT, LWIP_PLATFORM_ASSERT(message) needs to be defined in your arch/cc.h" -#endif -#else /* LWIP_NOASSERT */ -#define LWIP_ASSERT(message, assertion) -#endif /* LWIP_NOASSERT */ - -#ifndef LWIP_ERROR -#ifndef LWIP_NOASSERT -#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message) -#elif defined LWIP_DEBUG -#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message)) -#else -#define LWIP_PLATFORM_ERROR(message) -#endif - -/* if "expression" isn't true, then print "message" and execute "handler" expression */ -#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ - LWIP_PLATFORM_ERROR(message); handler;}} while(0) -#endif /* LWIP_ERROR */ - -/** Enable debug message printing, but only if debug message type is enabled - * AND is of correct type AND is at least LWIP_DBG_LEVEL. - */ -#ifdef __DOXYGEN__ -#define LWIP_DEBUG -#undef LWIP_DEBUG -#endif - -#ifdef LWIP_DEBUG -#ifndef LWIP_PLATFORM_DIAG -#error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h" -#endif -#define LWIP_DEBUGF(debug, message) do { \ - if ( \ - ((debug) & LWIP_DBG_ON) && \ - ((debug) & LWIP_DBG_TYPES_ON) && \ - ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ - LWIP_PLATFORM_DIAG(message); \ - if ((debug) & LWIP_DBG_HALT) { \ - while(1); \ - } \ - } \ - } while(0) - -#else /* LWIP_DEBUG */ -#define LWIP_DEBUGF(debug, message) -#endif /* LWIP_DEBUG */ - -#endif /* LWIP_HDR_DEBUG_H */ diff --git a/include/net/def.h b/include/net/def.h deleted file mode 100644 index cf33beb..0000000 --- a/include/net/def.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file - * various utility macros - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_DEF_H -#define LWIP_HDR_DEF_H - -/* arch.h might define NULL already */ -#include -#include -#if LWIP_PERF -#include -#else /* LWIP_PERF */ -#define PERF_START /* null definition */ -#define PERF_STOP(x) /* null definition */ -#endif /* LWIP_PERF */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) -#define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) - -/* Get the number of entries in an array ('x' must NOT be a pointer!) */ -#define LWIP_ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0])) - -/** Create u32_t value from bytes */ -#define LWIP_MAKEU32(a,b,c,d) (((u32_t)((a) & 0xff) << 24) | \ - ((u32_t)((b) & 0xff) << 16) | \ - ((u32_t)((c) & 0xff) << 8) | \ - (u32_t)((d) & 0xff)) - -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif - -#if BYTE_ORDER == BIG_ENDIAN -#define lwip_htons(x) (x) -#define lwip_ntohs(x) (x) -#define lwip_htonl(x) (x) -#define lwip_ntohl(x) (x) -#define PP_HTONS(x) (x) -#define PP_NTOHS(x) (x) -#define PP_HTONL(x) (x) -#define PP_NTOHL(x) (x) -#else /* BYTE_ORDER != BIG_ENDIAN */ -#ifndef lwip_htons -u16_t lwip_htons(u16_t x); -#endif -#define lwip_ntohs(x) lwip_htons(x) - -#ifndef lwip_htonl -u32_t lwip_htonl(u32_t x); -#endif -#define lwip_ntohl(x) lwip_htonl(x) - -/* These macros should be calculated by the preprocessor and are used - with compile-time constants only (so that there is no little-endian - overhead at runtime). */ -#define PP_HTONS(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8)) -#define PP_NTOHS(x) PP_HTONS(x) -#define PP_HTONL(x) ((((x) & 0x000000ffUL) << 24) | \ - (((x) & 0x0000ff00UL) << 8) | \ - (((x) & 0x00ff0000UL) >> 8) | \ - (((x) & 0xff000000UL) >> 24)) -#define PP_NTOHL(x) PP_HTONL(x) -#endif /* BYTE_ORDER == BIG_ENDIAN */ - -/* Provide usual function names as macros for users, but this can be turned off */ -#ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS -#define htons(x) lwip_htons(x) -#define ntohs(x) lwip_ntohs(x) -#define htonl(x) lwip_htonl(x) -#define ntohl(x) lwip_ntohl(x) -#endif - -/* Functions that are not available as standard implementations. - * In cc.h, you can #define these to implementations available on - * your platform to save some code bytes if you use these functions - * in your application, too. - */ - -#ifndef lwip_itoa -/* This can be #defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform */ -void lwip_itoa(char* result, size_t bufsize, int number); -#endif -#ifndef lwip_strnicmp -/* This can be #defined to strnicmp() or strncasecmp() depending on your platform */ -int lwip_strnicmp(const char* str1, const char* str2, size_t len); -#endif -#ifndef lwip_stricmp -/* This can be #defined to stricmp() or strcasecmp() depending on your platform */ -int lwip_stricmp(const char* str1, const char* str2); -#endif -#ifndef lwip_strnstr -/* This can be #defined to strnstr() depending on your platform */ -char* lwip_strnstr(const char* buffer, const char* token, size_t n); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_DEF_H */ diff --git a/include/net/dhcp.h b/include/net/dhcp.h deleted file mode 100644 index 9f972b7..0000000 --- a/include/net/dhcp.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file - * DHCP client API - */ - -/* - * Copyright (c) 2001-2004 Leon Woestenberg - * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Leon Woestenberg - * - */ -#ifndef LWIP_HDR_DHCP_H -#define LWIP_HDR_DHCP_H - -#include "net/opt.h" - -#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ - -#include "net/netif.h" -#include "net/udp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** period (in seconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_SECS 60 -/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) -/** period (in milliseconds) of the application calling dhcp_fine_tmr() */ -#define DHCP_FINE_TIMER_MSECS 500 - -#define DHCP_BOOT_FILE_LEN 128U - -/* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */ -typedef enum { - DHCP_AUTOIP_COOP_STATE_OFF = 0, - DHCP_AUTOIP_COOP_STATE_ON = 1 -} dhcp_autoip_coop_state_enum_t; - -struct dhcp -{ - /** transaction identifier of last sent request */ - u32_t xid; - /** incoming msg */ - struct dhcp_msg *msg_in; - /** track PCB allocation state */ - u8_t pcb_allocated; - /** current DHCP state machine state */ - u8_t state; - /** retries of current request */ - u8_t tries; -#if LWIP_DHCP_AUTOIP_COOP - u8_t autoip_coop_state; -#endif - u8_t subnet_mask_given; - - struct pbuf *p_out; /* pbuf of outcoming msg */ - struct dhcp_msg *msg_out; /* outgoing msg */ - u16_t options_out_len; /* outgoing msg options length */ - u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ - u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ - u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ - u16_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */ - u16_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */ - u16_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */ - u16_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */ - ip_addr_t server_ip_addr; /* dhcp server address that offered this lease (ip_addr_t because passed to UDP) */ - ip4_addr_t offered_ip_addr; - ip4_addr_t offered_sn_mask; - ip4_addr_t offered_gw_addr; - - u32_t offered_t0_lease; /* lease period (in seconds) */ - u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ - u32_t offered_t2_rebind; /* recommended rebind time (usually 87.5 of lease period) */ -#if LWIP_DHCP_BOOTP_FILE - ip4_addr_t offered_si_addr; - char boot_file_name[DHCP_BOOT_FILE_LEN]; -#endif /* LWIP_DHCP_BOOTPFILE */ -}; - - -void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); -/** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */ -#define dhcp_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL) -void dhcp_cleanup(struct netif *netif); -err_t dhcp_start(struct netif *netif); -err_t dhcp_renew(struct netif *netif); -err_t dhcp_release(struct netif *netif); -void dhcp_stop(struct netif *netif); -void dhcp_inform(struct netif *netif); -void dhcp_network_changed(struct netif *netif); -#if DHCP_DOES_ARP_CHECK -void dhcp_arp_reply(struct netif *netif, const ip4_addr_t *addr); -#endif -u8_t dhcp_supplied_address(const struct netif *netif); -/* to be called every minute */ -void dhcp_coarse_tmr(void); -/* to be called every half second */ -void dhcp_fine_tmr(void); - -#if LWIP_DHCP_GET_NTP_SRV -/** This function must exist, in other to add offered NTP servers to - * the NTP (or SNTP) engine. - * See LWIP_DHCP_MAX_NTP_SERVERS */ -extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_server_addrs); -#endif /* LWIP_DHCP_GET_NTP_SRV */ - -#define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP)) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DHCP */ - -#endif /*LWIP_HDR_DHCP_H*/ diff --git a/include/net/dhcp6.h b/include/net/dhcp6.h deleted file mode 100644 index 39f6902..0000000 --- a/include/net/dhcp6.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * - * IPv6 address autoconfiguration as per RFC 4862. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * IPv6 address autoconfiguration as per RFC 4862. - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_IP6_DHCP6_H -#define LWIP_HDR_IP6_DHCP6_H - -#include "net/opt.h" - -#if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */ - - -struct dhcp6 -{ - /*@todo: implement DHCP6*/ -}; - -#endif /* LWIP_IPV6_DHCP6 */ - -#endif /* LWIP_HDR_IP6_DHCP6_H */ diff --git a/include/net/dns.h b/include/net/dns.h deleted file mode 100644 index e09d812..0000000 --- a/include/net/dns.h +++ /dev/null @@ -1,130 +0,0 @@ -/** - * @file - * DNS API - */ - -/** - * lwip DNS resolver header file. - - * Author: Jim Pettinato - * April 2007 - - * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LWIP_HDR_DNS_H -#define LWIP_HDR_DNS_H - -#include "net/opt.h" - -#if LWIP_DNS - -#include "net/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** DNS timer period */ -#define DNS_TMR_INTERVAL 1000 - -/* DNS resolve types: */ -#define LWIP_DNS_ADDRTYPE_IPV4 0 -#define LWIP_DNS_ADDRTYPE_IPV6 1 -#define LWIP_DNS_ADDRTYPE_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */ -#define LWIP_DNS_ADDRTYPE_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */ -#if LWIP_IPV4 && LWIP_IPV6 -#ifndef LWIP_DNS_ADDRTYPE_DEFAULT -#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4_IPV6 -#endif -#elif LWIP_IPV4 -#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4 -#else -#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV6 -#endif - -#if DNS_LOCAL_HOSTLIST -/** struct used for local host-list */ -struct local_hostlist_entry { - /** static hostname */ - const char *name; - /** static host address in network byteorder */ - ip_addr_t addr; - struct local_hostlist_entry *next; -}; -#define DNS_LOCAL_HOSTLIST_ELEM(name, addr_init) {name, addr_init, NULL} -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC -#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN -#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH -#endif -#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ -#endif /* DNS_LOCAL_HOSTLIST */ - -#if LWIP_IPV4 -extern const ip_addr_t dns_mquery_v4group; -#endif /* LWIP_IPV4 */ -#if LWIP_IPV6 -extern const ip_addr_t dns_mquery_v6group; -#endif /* LWIP_IPV6 */ - -/** Callback which is invoked when a hostname is found. - * A function of this type must be implemented by the application using the DNS resolver. - * @param name pointer to the name that was looked up. - * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, - * or NULL if the name could not be found (or on any other error). - * @param callback_arg a user-specified callback argument passed to dns_gethostbyname -*/ -typedef void (*dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg); - -void dns_init(void); -void dns_tmr(void); -void dns_setserver(u8_t numdns, const ip_addr_t *dnsserver); -const ip_addr_t* dns_getserver(u8_t numdns); -err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, - dns_found_callback found, void *callback_arg); -err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, - dns_found_callback found, void *callback_arg, - u8_t dns_addrtype); - - -#if DNS_LOCAL_HOSTLIST -size_t dns_local_iterate(dns_found_callback iterator_fn, void *iterator_arg); -err_t dns_local_lookup(const char *hostname, ip_addr_t *addr, u8_t dns_addrtype); -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC -int dns_local_removehost(const char *hostname, const ip_addr_t *addr); -err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ -#endif /* DNS_LOCAL_HOSTLIST */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DNS */ - -#endif /* LWIP_HDR_DNS_H */ diff --git a/include/net/err.h b/include/net/err.h deleted file mode 100644 index fc982bb..0000000 --- a/include/net/err.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @file - * lwIP Error codes - */ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_ERR_H -#define LWIP_HDR_ERR_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup infrastructure_errors Error codes - * @ingroup infrastructure - * @{ - */ - -/** Define LWIP_ERR_T in cc.h if you want to use - * a different type for your platform (must be signed). */ -#ifdef LWIP_ERR_T -typedef LWIP_ERR_T err_t; -#else /* LWIP_ERR_T */ -typedef s8_t err_t; -#endif /* LWIP_ERR_T*/ - -/** Definitions for error constants. */ -typedef enum { -/** No error, everything OK. */ - ERR_OK = 0, -/** Out of memory error. */ - ERR_MEM = -1, -/** Buffer error. */ - ERR_BUF = -2, -/** Timeout. */ - ERR_TIMEOUT = -3, -/** Routing problem. */ - ERR_RTE = -4, -/** Operation in progress */ - ERR_INPROGRESS = -5, -/** Illegal value. */ - ERR_VAL = -6, -/** Operation would block. */ - ERR_WOULDBLOCK = -7, -/** Address in use. */ - ERR_USE = -8, -/** Already connecting. */ - ERR_ALREADY = -9, -/** Conn already established.*/ - ERR_ISCONN = -10, -/** Not connected. */ - ERR_CONN = -11, -/** Low-level netif error */ - ERR_IF = -12, - -/** Connection aborted. */ - ERR_ABRT = -13, -/** Connection reset. */ - ERR_RST = -14, -/** Connection closed. */ - ERR_CLSD = -15, -/** Illegal argument. */ - ERR_ARG = -16 -} err_enum_t; - -#define ERR_IS_FATAL(e) ((e) <= ERR_ABRT) - -/** - * @} - */ - -#ifdef LWIP_DEBUG -extern const char *lwip_strerr(err_t err); -#else -#define lwip_strerr(x) "" -#endif /* LWIP_DEBUG */ - -#if !NO_SYS -int err_to_errno(err_t err); -#endif /* !NO_SYS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_ERR_H */ diff --git a/include/net/errno.h b/include/net/errno.h deleted file mode 100644 index 1ee024d..0000000 --- a/include/net/errno.h +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @file - * Posix Errno defines - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_ERRNO_H -#define LWIP_HDR_ERRNO_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef LWIP_PROVIDE_ERRNO - -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No child processes */ -#define EAGAIN 11 /* Try again */ -#define ENOMEM 12 /* Out of memory */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device or resource busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math argument out of domain of func */ -#define ERANGE 34 /* Math result not representable */ -#define EDEADLK 35 /* Resource deadlock would occur */ -#define ENAMETOOLONG 36 /* File name too long */ -#define ENOLCK 37 /* No record locks available */ -#define ENOSYS 38 /* Function not implemented */ -#define ENOTEMPTY 39 /* Directory not empty */ -#define ELOOP 40 /* Too many symbolic links encountered */ -#define EWOULDBLOCK EAGAIN /* Operation would block */ -#define ENOMSG 42 /* No message of desired type */ -#define EIDRM 43 /* Identifier removed */ -#define ECHRNG 44 /* Channel number out of range */ -#define EL2NSYNC 45 /* Level 2 not synchronized */ -#define EL3HLT 46 /* Level 3 halted */ -#define EL3RST 47 /* Level 3 reset */ -#define ELNRNG 48 /* Link number out of range */ -#define EUNATCH 49 /* Protocol driver not attached */ -#define ENOCSI 50 /* No CSI structure available */ -#define EL2HLT 51 /* Level 2 halted */ -#define EBADE 52 /* Invalid exchange */ -#define EBADR 53 /* Invalid request descriptor */ -#define EXFULL 54 /* Exchange full */ -#define ENOANO 55 /* No anode */ -#define EBADRQC 56 /* Invalid request code */ -#define EBADSLT 57 /* Invalid slot */ - -#define EDEADLOCK EDEADLK - -#define EBFONT 59 /* Bad font file format */ -#define ENOSTR 60 /* Device not a stream */ -#define ENODATA 61 /* No data available */ -#define ETIME 62 /* Timer expired */ -#define ENOSR 63 /* Out of streams resources */ -#define ENONET 64 /* Machine is not on the network */ -#define ENOPKG 65 /* Package not installed */ -#define EREMOTE 66 /* Object is remote */ -#define ENOLINK 67 /* Link has been severed */ -#define EADV 68 /* Advertise error */ -#define ESRMNT 69 /* Srmount error */ -#define ECOMM 70 /* Communication error on send */ -#define EPROTO 71 /* Protocol error */ -#define EMULTIHOP 72 /* Multihop attempted */ -#define EDOTDOT 73 /* RFS specific error */ -#define EBADMSG 74 /* Not a data message */ -#define EOVERFLOW 75 /* Value too large for defined data type */ -#define ENOTUNIQ 76 /* Name not unique on network */ -#define EBADFD 77 /* File descriptor in bad state */ -#define EREMCHG 78 /* Remote address changed */ -#define ELIBACC 79 /* Can not access a needed shared library */ -#define ELIBBAD 80 /* Accessing a corrupted shared library */ -#define ELIBSCN 81 /* .lib section in a.out corrupted */ -#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ -#define ELIBEXEC 83 /* Cannot exec a shared library directly */ -#define EILSEQ 84 /* Illegal byte sequence */ -#define ERESTART 85 /* Interrupted system call should be restarted */ -#define ESTRPIPE 86 /* Streams pipe error */ -#define EUSERS 87 /* Too many users */ -#define ENOTSOCK 88 /* Socket operation on non-socket */ -#define EDESTADDRREQ 89 /* Destination address required */ -#define EMSGSIZE 90 /* Message too long */ -#define EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 92 /* Protocol not available */ -#define EPROTONOSUPPORT 93 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define EADDRINUSE 98 /* Address already in use */ -#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define ENETDOWN 100 /* Network is down */ -#define ENETUNREACH 101 /* Network is unreachable */ -#define ENETRESET 102 /* Network dropped connection because of reset */ -#define ECONNABORTED 103 /* Software caused connection abort */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EISCONN 106 /* Transport endpoint is already connected */ -#define ENOTCONN 107 /* Transport endpoint is not connected */ -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define ETIMEDOUT 110 /* Connection timed out */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EHOSTDOWN 112 /* Host is down */ -#define EHOSTUNREACH 113 /* No route to host */ -#define EALREADY 114 /* Operation already in progress */ -#define EINPROGRESS 115 /* Operation now in progress */ -#define ESTALE 116 /* Stale NFS file handle */ -#define EUCLEAN 117 /* Structure needs cleaning */ -#define ENOTNAM 118 /* Not a XENIX named type file */ -#define ENAVAIL 119 /* No XENIX semaphores available */ -#define EISNAM 120 /* Is a named type file */ -#define EREMOTEIO 121 /* Remote I/O error */ -#define EDQUOT 122 /* Quota exceeded */ - -#define ENOMEDIUM 123 /* No medium found */ -#define EMEDIUMTYPE 124 /* Wrong medium type */ - -#ifndef errno -extern int errno; -#endif - -#else /* LWIP_PROVIDE_ERRNO */ - -/* Define LWIP_ERRNO_INCLUDE to to include the error defines here */ -#ifdef LWIP_ERRNO_INCLUDE -#include LWIP_ERRNO_INCLUDE -#endif /* LWIP_ERRNO_INCLUDE */ - -#endif /* LWIP_PROVIDE_ERRNO */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_ERRNO_H */ diff --git a/include/net/etharp.h b/include/net/etharp.h deleted file mode 100644 index 86bda36..0000000 --- a/include/net/etharp.h +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @file - * Ethernet output function - handles OUTGOING ethernet level traffic, implements - * ARP resolving. - * To be used in most low-level netif implementations - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * Copyright (c) 2003-2004 Leon Woestenberg - * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef LWIP_HDR_NETIF_ETHARP_H -#define LWIP_HDR_NETIF_ETHARP_H - -#include "net/opt.h" - -#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/ip4_addr.h" -#include "net/netif.h" -#include "net/ip4.h" -#include "net/prot/ethernet.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */ - -#include "net/prot/etharp.h" - -/** 1 seconds period */ -#define ARP_TMR_INTERVAL 1000 - -#if ARP_QUEUEING -/** struct for queueing outgoing packets for unknown address - * defined here to be accessed by memp.h - */ -struct etharp_q_entry { - struct etharp_q_entry *next; - struct pbuf *p; -}; -#endif /* ARP_QUEUEING */ - -#define etharp_init() /* Compatibility define, no init needed. */ -void etharp_tmr(void); -s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr, - struct eth_addr **eth_ret, const ip4_addr_t **ip_ret); -u8_t etharp_get_entry(u8_t i, ip4_addr_t **ipaddr, struct netif **netif, struct eth_addr **eth_ret); -err_t etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); -err_t etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q); -err_t etharp_request(struct netif *netif, const ip4_addr_t *ipaddr); -/** For Ethernet network interfaces, we might want to send "gratuitous ARP"; - * this is an ARP packet sent by a node in order to spontaneously cause other - * nodes to update an entry in their ARP cache. - * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ -#define etharp_gratuitous(netif) etharp_request((netif), netif_ip4_addr(netif)) -void etharp_cleanup_netif(struct netif *netif); - -#if ETHARP_SUPPORT_STATIC_ENTRIES -err_t etharp_add_static_entry(const ip4_addr_t *ipaddr, struct eth_addr *ethaddr); -err_t etharp_remove_static_entry(const ip4_addr_t *ipaddr); -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - -#endif /* LWIP_IPV4 && LWIP_ARP */ - -void etharp_input(struct pbuf *p, struct netif *netif); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_ARP || LWIP_ETHERNET */ - -#endif /* LWIP_HDR_NETIF_ETHARP_H */ diff --git a/include/net/ethip6.h b/include/net/ethip6.h deleted file mode 100644 index f2d0dfd..0000000 --- a/include/net/ethip6.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file - * - * Ethernet output for IPv6. Uses ND tables for link-layer addressing. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_ETHIP6_H -#define LWIP_HDR_ETHIP6_H - -#include "net/opt.h" - -#if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/ip6.h" -#include "net/ip6_addr.h" -#include "net/netif.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 && LWIP_ETHERNET */ - -#endif /* LWIP_HDR_ETHIP6_H */ diff --git a/include/net/icmp.h b/include/net/icmp.h deleted file mode 100644 index 844a611..0000000 --- a/include/net/icmp.h +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @file - * ICMP API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_ICMP_H -#define LWIP_HDR_ICMP_H - -#include "net/opt.h" -#include "net/pbuf.h" -#include "net/ip_addr.h" -#include "net/netif.h" -#include "net/prot/icmp.h" - -#if LWIP_IPV6 && LWIP_ICMP6 -#include "net/icmp6.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** ICMP destination unreachable codes */ -enum icmp_dur_type { - /** net unreachable */ - ICMP_DUR_NET = 0, - /** host unreachable */ - ICMP_DUR_HOST = 1, - /** protocol unreachable */ - ICMP_DUR_PROTO = 2, - /** port unreachable */ - ICMP_DUR_PORT = 3, - /** fragmentation needed and DF set */ - ICMP_DUR_FRAG = 4, - /** source route failed */ - ICMP_DUR_SR = 5 -}; - -/** ICMP time exceeded codes */ -enum icmp_te_type { - /** time to live exceeded in transit */ - ICMP_TE_TTL = 0, - /** fragment reassembly time exceeded */ - ICMP_TE_FRAG = 1 -}; - -#if LWIP_IPV4 && LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -void icmp_input(struct pbuf *p, struct netif *inp); -void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); -void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); - -#endif /* LWIP_IPV4 && LWIP_ICMP */ - -#if LWIP_IPV4 && LWIP_IPV6 -#if LWIP_ICMP && LWIP_ICMP6 -#define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \ - icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \ - icmp_dest_unreach(pbuf, ICMP_DUR_PORT)) -#elif LWIP_ICMP -#define icmp_port_unreach(isipv6, pbuf) do{ if(!(isipv6)) { icmp_dest_unreach(pbuf, ICMP_DUR_PORT);}}while(0) -#elif LWIP_ICMP6 -#define icmp_port_unreach(isipv6, pbuf) do{ if(isipv6) { icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT);}}while(0) -#else -#define icmp_port_unreach(isipv6, pbuf) -#endif -#elif LWIP_IPV6 && LWIP_ICMP6 -#define icmp_port_unreach(isipv6, pbuf) icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) -#elif LWIP_IPV4 && LWIP_ICMP -#define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT) -#else /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) */ -#define icmp_port_unreach(isipv6, pbuf) -#endif /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) LWIP_IPV4*/ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_ICMP_H */ diff --git a/include/net/icmp6.h b/include/net/icmp6.h deleted file mode 100644 index 6ce3a2a..0000000 --- a/include/net/icmp6.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * - * IPv6 version of ICMP, as per RFC 4443. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef LWIP_HDR_ICMP6_H -#define LWIP_HDR_ICMP6_H - -#include "net/opt.h" -#include "net/pbuf.h" -#include "net/ip6_addr.h" -#include "net/netif.h" -#include "net/prot/icmp6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -void icmp6_input(struct pbuf *p, struct netif *inp); -void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c); -void icmp6_packet_too_big(struct pbuf *p, u32_t mtu); -void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c); -void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, u32_t pointer); - -#endif /* LWIP_ICMP6 && LWIP_IPV6 */ - - -#ifdef __cplusplus -} -#endif - - -#endif /* LWIP_HDR_ICMP6_H */ diff --git a/include/net/igmp.h b/include/net/igmp.h deleted file mode 100644 index 571684c..0000000 --- a/include/net/igmp.h +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @file - * IGMP API - */ - -/* - * Copyright (c) 2002 CITEL Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is a contribution to the lwIP TCP/IP stack. - * The Swedish Institute of Computer Science and Adam Dunkels - * are specifically granted permission to redistribute this - * source code. -*/ - -#ifndef LWIP_HDR_IGMP_H -#define LWIP_HDR_IGMP_H - -#include "net/opt.h" -#include "net/ip_addr.h" -#include "net/netif.h" -#include "net/pbuf.h" - -#if LWIP_IPV4 && LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* IGMP timer */ -#define IGMP_TMR_INTERVAL 100 /* Milliseconds */ -#define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) -#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) - -/* Compatibility defines (don't use for new code) */ -#define IGMP_DEL_MAC_FILTER NETIF_DEL_MAC_FILTER -#define IGMP_ADD_MAC_FILTER NETIF_ADD_MAC_FILTER - -/** - * igmp group structure - there is - * a list of groups for each interface - * these should really be linked from the interface, but - * if we keep them separate we will not affect the lwip original code - * too much - * - * There will be a group for the all systems group address but this - * will not run the state machine as it is used to kick off reports - * from all the other groups - */ -struct igmp_group { - /** next link */ - struct igmp_group *next; - /** multicast address */ - ip4_addr_t group_address; - /** signifies we were the last person to report */ - u8_t last_reporter_flag; - /** current state of the group */ - u8_t group_state; - /** timer for reporting, negative is OFF */ - u16_t timer; - /** counter of simultaneous uses */ - u8_t use; -}; - -/* Prototypes */ -void igmp_init(void); -err_t igmp_start(struct netif *netif); -err_t igmp_stop(struct netif *netif); -void igmp_report_groups(struct netif *netif); -struct igmp_group *igmp_lookfor_group(struct netif *ifp, const ip4_addr_t *addr); -void igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest); -err_t igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr); -err_t igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr); -err_t igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr); -err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr); -void igmp_tmr(void); - -/** @ingroup igmp - * Get list head of IGMP groups for netif. - * Note: The allsystems group IP is contained in the list as first entry. - * @see @ref netif_set_igmp_mac_filter() - */ -#define netif_igmp_data(netif) ((struct igmp_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP)) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV4 && LWIP_IGMP */ - -#endif /* LWIP_HDR_IGMP_H */ diff --git a/include/net/inet.h b/include/net/inet.h deleted file mode 100644 index 63a6862..0000000 --- a/include/net/inet.h +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @file - * This file (together with sockets.h) aims to provide structs and functions from - * - arpa/inet.h - * - netinet/in.h - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_INET_H -#define LWIP_HDR_INET_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* If your port already typedef's in_addr_t, define IN_ADDR_T_DEFINED - to prevent this code from redefining it. */ -#if !defined(in_addr_t) && !defined(IN_ADDR_T_DEFINED) -typedef u32_t in_addr_t; -#endif - -struct in_addr { - in_addr_t s_addr; -}; - -struct in6_addr { - union { - u32_t u32_addr[4]; - u8_t u8_addr[16]; - } un; -#define s6_addr un.u8_addr -}; - -/** 255.255.255.255 */ -#define INADDR_NONE IPADDR_NONE -/** 127.0.0.1 */ -#define INADDR_LOOPBACK IPADDR_LOOPBACK -/** 0.0.0.0 */ -#define INADDR_ANY IPADDR_ANY -/** 255.255.255.255 */ -#define INADDR_BROADCAST IPADDR_BROADCAST - -/** This macro can be used to initialize a variable of type struct in6_addr - to the IPv6 wildcard address. */ -#define IN6ADDR_ANY_INIT {{{0,0,0,0}}} -/** This macro can be used to initialize a variable of type struct in6_addr - to the IPv6 loopback address. */ -#define IN6ADDR_LOOPBACK_INIT {{{0,0,0,PP_HTONL(1)}}} -/** This variable is initialized by the system to contain the wildcard IPv6 address. */ -extern const struct in6_addr in6addr_any; - -/* Definitions of the bits in an (IPv4) Internet address integer. - - On subnets, host and network parts are found according to - the subnet mask, not these masks. */ -#define IN_CLASSA(a) IP_CLASSA(a) -#define IN_CLASSA_NET IP_CLASSA_NET -#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT -#define IN_CLASSA_HOST IP_CLASSA_HOST -#define IN_CLASSA_MAX IP_CLASSA_MAX - -#define IN_CLASSB(b) IP_CLASSB(b) -#define IN_CLASSB_NET IP_CLASSB_NET -#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT -#define IN_CLASSB_HOST IP_CLASSB_HOST -#define IN_CLASSB_MAX IP_CLASSB_MAX - -#define IN_CLASSC(c) IP_CLASSC(c) -#define IN_CLASSC_NET IP_CLASSC_NET -#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT -#define IN_CLASSC_HOST IP_CLASSC_HOST -#define IN_CLASSC_MAX IP_CLASSC_MAX - -#define IN_CLASSD(d) IP_CLASSD(d) -#define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ -#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ -#define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ -#define IN_CLASSD_MAX IP_CLASSD_MAX - -#define IN_MULTICAST(a) IP_MULTICAST(a) - -#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) -#define IN_BADCLASS(a) IP_BADCLASS(a) - -#define IN_LOOPBACKNET IP_LOOPBACKNET - - -#ifndef INET_ADDRSTRLEN -#define INET_ADDRSTRLEN IP4ADDR_STRLEN_MAX -#endif -#if LWIP_IPV6 -#ifndef INET6_ADDRSTRLEN -#define INET6_ADDRSTRLEN IP6ADDR_STRLEN_MAX -#endif -#endif - -#if LWIP_IPV4 - -#define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) -#define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) -/* ATTENTION: the next define only works because both s_addr and ip4_addr_t are an u32_t effectively! */ -#define inet_addr_to_ip4addr_p(target_ip4addr_p, source_inaddr) ((target_ip4addr_p) = (ip4_addr_t*)&((source_inaddr)->s_addr)) - -/* directly map this to the lwip internal functions */ -#define inet_addr(cp) ipaddr_addr(cp) -#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr) -#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr)) -#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen) - -#endif /* LWIP_IPV4 */ - -#if LWIP_IPV6 -#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \ - (target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \ - (target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \ - (target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];} -#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \ - (target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \ - (target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \ - (target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3];} -/* ATTENTION: the next define only works because both in6_addr and ip6_addr_t are an u32_t[4] effectively! */ -#define inet6_addr_to_ip6addr_p(target_ip6addr_p, source_in6addr) ((target_ip6addr_p) = (ip6_addr_t*)(source_in6addr)) - -/* directly map this to the lwip internal functions */ -#define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr) -#define inet6_ntoa(addr) ip6addr_ntoa((const ip6_addr_t*)&(addr)) -#define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((const ip6_addr_t*)&(addr), buf, buflen) - -#endif /* LWIP_IPV6 */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_INET_H */ diff --git a/include/net/inet_chksum.h b/include/net/inet_chksum.h deleted file mode 100644 index a00ab6d..0000000 --- a/include/net/inet_chksum.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file - * IP checksum calculation functions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_INET_CHKSUM_H -#define LWIP_HDR_INET_CHKSUM_H - -#include "net/opt.h" - -#include "net/pbuf.h" -#include "net/ip_addr.h" - -/** Swap the bytes in an u16_t: much like lwip_htons() for little-endian */ -#ifndef SWAP_BYTES_IN_WORD -#define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) -#endif /* SWAP_BYTES_IN_WORD */ - -/** Split an u32_t in two u16_ts and add them up */ -#ifndef FOLD_U32T -#define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) -#endif - -#if LWIP_CHECKSUM_ON_COPY -/** Function-like macro: same as MEMCPY but returns the checksum of copied data - as u16_t */ -# ifndef LWIP_CHKSUM_COPY -# define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) -# ifndef LWIP_CHKSUM_COPY_ALGORITHM -# define LWIP_CHKSUM_COPY_ALGORITHM 1 -# endif /* LWIP_CHKSUM_COPY_ALGORITHM */ -# else /* LWIP_CHKSUM_COPY */ -# define LWIP_CHKSUM_COPY_ALGORITHM 0 -# endif /* LWIP_CHKSUM_COPY */ -#else /* LWIP_CHECKSUM_ON_COPY */ -# define LWIP_CHKSUM_COPY_ALGORITHM 0 -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#ifdef __cplusplus -extern "C" { -#endif - -u16_t inet_chksum(const void *dataptr, u16_t len); -u16_t inet_chksum_pbuf(struct pbuf *p); -#if LWIP_CHKSUM_COPY_ALGORITHM -u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); -#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ - -#if LWIP_IPV4 -u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - const ip4_addr_t *src, const ip4_addr_t *dest); -u16_t inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, - u16_t proto_len, u16_t chksum_len, const ip4_addr_t *src, const ip4_addr_t *dest); -#endif /* LWIP_IPV4 */ - -#if LWIP_IPV6 -u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - const ip6_addr_t *src, const ip6_addr_t *dest); -u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, const ip6_addr_t *src, const ip6_addr_t *dest); -#endif /* LWIP_IPV6 */ - - -u16_t ip_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - const ip_addr_t *src, const ip_addr_t *dest); -u16_t ip_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, const ip_addr_t *src, const ip_addr_t *dest); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_INET_H */ - diff --git a/include/net/init.h b/include/net/init.h deleted file mode 100644 index 11a57d8..0000000 --- a/include/net/init.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @file - * lwIP initialization API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_INIT_H -#define LWIP_HDR_INIT_H - -#include "net/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup lwip_version Version - * @ingroup lwip - * @{ - */ - -/** X.x.x: Major version of the stack */ -#define LWIP_VERSION_MAJOR 2 -/** x.X.x: Minor version of the stack */ -#define LWIP_VERSION_MINOR 0 -/** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 3 -/** For release candidates, this is set to 1..254 - * For official releases, this is set to 255 (LWIP_RC_RELEASE) - * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ -#define LWIP_VERSION_RC LWIP_RC_RELEASE - -/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ -#define LWIP_RC_RELEASE 255 -/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions */ -#define LWIP_RC_DEVELOPMENT 0 - -#define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) -#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) -#define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) - -/* Some helper defines to get a version string */ -#define LWIP_VERSTR2(x) #x -#define LWIP_VERSTR(x) LWIP_VERSTR2(x) -#if LWIP_VERSION_IS_RELEASE -#define LWIP_VERSION_STRING_SUFFIX "" -#elif LWIP_VERSION_IS_DEVELOPMENT -#define LWIP_VERSION_STRING_SUFFIX "d" -#else -#define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) -#endif - -/** Provides the version of the stack */ -#define LWIP_VERSION (((u32_t)LWIP_VERSION_MAJOR) << 24 | ((u32_t)LWIP_VERSION_MINOR) << 16 | \ - ((u32_t)LWIP_VERSION_REVISION) << 8 | ((u32_t)LWIP_VERSION_RC)) -/** Provides the version of the stack as string */ -#define LWIP_VERSION_STRING LWIP_VERSTR(LWIP_VERSION_MAJOR) "." LWIP_VERSTR(LWIP_VERSION_MINOR) "." LWIP_VERSTR(LWIP_VERSION_REVISION) LWIP_VERSION_STRING_SUFFIX - -/** - * @} - */ - -/* Modules initialization */ -void lwip_init(void); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_INIT_H */ diff --git a/include/net/ip.h b/include/net/ip.h deleted file mode 100644 index 1bdd55f..0000000 --- a/include/net/ip.h +++ /dev/null @@ -1,319 +0,0 @@ -/** - * @file - * IP API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_IP_H -#define LWIP_HDR_IP_H - -#include "net/opt.h" - -#include "net/def.h" -#include "net/pbuf.h" -#include "net/ip_addr.h" -#include "net/err.h" -#include "net/netif.h" -#include "net/ip4.h" -#include "net/ip6.h" -#include "net/prot/ip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* This is passed as the destination address to ip_output_if (not - to ip_output), meaning that an IP header already is constructed - in the pbuf. This is used when TCP retransmits. */ -#define LWIP_IP_HDRINCL NULL - -/** pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ -#ifndef LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX -#define LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p) LWIP_ASSERT("p->ref == 1", (p)->ref == 1) -#endif - -#if LWIP_NETIF_HWADDRHINT -#define IP_PCB_ADDRHINT ;u8_t addr_hint -#else -#define IP_PCB_ADDRHINT -#endif /* LWIP_NETIF_HWADDRHINT */ - -/** This is the common part of all PCB types. It needs to be at the - beginning of a PCB type definition. It is located here so that - changes to this common part are made in one location instead of - having to change all PCB structs. */ -#define IP_PCB \ - /* ip addresses in network byte order */ \ - ip_addr_t local_ip; \ - ip_addr_t remote_ip; \ - /* Socket options */ \ - u8_t so_options; \ - /* Type Of Service */ \ - u8_t tos; \ - /* Time To Live */ \ - u8_t ttl \ - /* link layer address resolution hint */ \ - IP_PCB_ADDRHINT - -struct ip_pcb { -/* Common members of all PCB types */ - IP_PCB; -}; - -/* - * Option flags per-socket. These are the same like SO_XXX in sockets.h - */ -#define SOF_REUSEADDR 0x04U /* allow local address reuse */ -#define SOF_KEEPALIVE 0x08U /* keep connections alive */ -#define SOF_BROADCAST 0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ - -/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */ -#define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE) - -/** Global variables of this module, kept in a struct for efficient access using base+index. */ -struct ip_globals -{ - /** The interface that accepted the packet for the current callback invocation. */ - struct netif *current_netif; - /** The interface that received the packet for the current callback invocation. */ - struct netif *current_input_netif; -#if LWIP_IPV4 - /** Header of the input packet currently being processed. */ - struct ip_hdr *current_ip4_header; -#endif /* LWIP_IPV4 */ -#if LWIP_IPV6 - /** Header of the input IPv6 packet currently being processed. */ - struct ip6_hdr *current_ip6_header; -#endif /* LWIP_IPV6 */ - /** Total header length of current_ip4/6_header (i.e. after this, the UDP/TCP header starts) */ - u16_t current_ip_header_tot_len; - /** Source IP address of current_header */ - ip_addr_t current_iphdr_src; - /** Destination IP address of current_header */ - ip_addr_t current_iphdr_dest; -}; -extern struct ip_globals ip_data; - - -/** Get the interface that accepted the current packet. - * This may or may not be the receiving netif, depending on your netif/network setup. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip_current_netif() (ip_data.current_netif) -/** Get the interface that received the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip_current_input_netif() (ip_data.current_input_netif) -/** Total header length of ip(6)_current_header() (i.e. after this, the UDP/TCP header starts) */ -#define ip_current_header_tot_len() (ip_data.current_ip_header_tot_len) -/** Source IP address of current_header */ -#define ip_current_src_addr() (&ip_data.current_iphdr_src) -/** Destination IP address of current_header */ -#define ip_current_dest_addr() (&ip_data.current_iphdr_dest) - -#if LWIP_IPV4 && LWIP_IPV6 -/** Get the IPv4 header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip4_current_header() ((const struct ip_hdr*)(ip_data.current_ip4_header)) -/** Get the IPv6 header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip6_current_header() ((const struct ip6_hdr*)(ip_data.current_ip6_header)) -/** Returns TRUE if the current IP input packet is IPv6, FALSE if it is IPv4 */ -#define ip_current_is_v6() (ip6_current_header() != NULL) -/** Source IPv6 address of current_header */ -#define ip6_current_src_addr() (ip_2_ip6(&ip_data.current_iphdr_src)) -/** Destination IPv6 address of current_header */ -#define ip6_current_dest_addr() (ip_2_ip6(&ip_data.current_iphdr_dest)) -/** Get the transport layer protocol */ -#define ip_current_header_proto() (ip_current_is_v6() ? \ - IP6H_NEXTH(ip6_current_header()) :\ - IPH_PROTO(ip4_current_header())) -/** Get the transport layer header */ -#define ip_next_header_ptr() ((const void*)((ip_current_is_v6() ? \ - (const u8_t*)ip6_current_header() : (const u8_t*)ip4_current_header()) + ip_current_header_tot_len())) - -/** Source IP4 address of current_header */ -#define ip4_current_src_addr() (ip_2_ip4(&ip_data.current_iphdr_src)) -/** Destination IP4 address of current_header */ -#define ip4_current_dest_addr() (ip_2_ip4(&ip_data.current_iphdr_dest)) - -#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */ - -/** Get the IPv4 header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip4_current_header() ((const struct ip_hdr*)(ip_data.current_ip4_header)) -/** Always returns FALSE when only supporting IPv4 only */ -#define ip_current_is_v6() 0 -/** Get the transport layer protocol */ -#define ip_current_header_proto() IPH_PROTO(ip4_current_header()) -/** Get the transport layer header */ -#define ip_next_header_ptr() ((const void*)((const u8_t*)ip4_current_header() + ip_current_header_tot_len())) -/** Source IP4 address of current_header */ -#define ip4_current_src_addr() (&ip_data.current_iphdr_src) -/** Destination IP4 address of current_header */ -#define ip4_current_dest_addr() (&ip_data.current_iphdr_dest) - -#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */ - -/** Get the IPv6 header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip6_current_header() ((const struct ip6_hdr*)(ip_data.current_ip6_header)) -/** Always returns TRUE when only supporting IPv6 only */ -#define ip_current_is_v6() 1 -/** Get the transport layer protocol */ -#define ip_current_header_proto() IP6H_NEXTH(ip6_current_header()) -/** Get the transport layer header */ -#define ip_next_header_ptr() ((const void*)((const u8_t*)ip6_current_header())) -/** Source IP6 address of current_header */ -#define ip6_current_src_addr() (&ip_data.current_iphdr_src) -/** Destination IP6 address of current_header */ -#define ip6_current_dest_addr() (&ip_data.current_iphdr_dest) - -#endif /* LWIP_IPV6 */ - -/** Union source address of current_header */ -#define ip_current_src_addr() (&ip_data.current_iphdr_src) -/** Union destination address of current_header */ -#define ip_current_dest_addr() (&ip_data.current_iphdr_dest) - -/** Gets an IP pcb option (SOF_* flags) */ -#define ip_get_option(pcb, opt) ((pcb)->so_options & (opt)) -/** Sets an IP pcb option (SOF_* flags) */ -#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) -/** Resets an IP pcb option (SOF_* flags) */ -#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt)) - -#if LWIP_IPV4 && LWIP_IPV6 -/** - * @ingroup ip - * Output IP packet, netif is selected by source address - */ -#define ip_output(p, src, dest, ttl, tos, proto) \ - (IP_IS_V6(dest) ? \ - ip6_output(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto) : \ - ip4_output(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto)) -/** - * @ingroup ip - * Output IP packet to specified interface - */ -#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \ - (IP_IS_V6(dest) ? \ - ip6_output_if(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \ - ip4_output_if(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif)) -/** - * @ingroup ip - * Output IP packet to interface specifying source address - */ -#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif) \ - (IP_IS_V6(dest) ? \ - ip6_output_if_src(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \ - ip4_output_if_src(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif)) -/** Output IP packet with addr_hint */ -#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \ - (IP_IS_V6(dest) ? \ - ip6_output_hinted(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, addr_hint) : \ - ip4_output_hinted(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, addr_hint)) -/** - * @ingroup ip - * Get netif for address combination. See \ref ip6_route and \ref ip4_route - */ -#define ip_route(src, dest) \ - (IP_IS_V6(dest) ? \ - ip6_route(ip_2_ip6(src), ip_2_ip6(dest)) : \ - ip4_route_src(ip_2_ip4(dest), ip_2_ip4(src))) -/** - * @ingroup ip - * Get netif for IP. - */ -#define ip_netif_get_local_ip(netif, dest) (IP_IS_V6(dest) ? \ - ip6_netif_get_local_ip(netif, ip_2_ip6(dest)) : \ - ip4_netif_get_local_ip(netif)) -#define ip_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip4_debug_print(p)) - -err_t ip_input(struct pbuf *p, struct netif *inp); - -#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */ - -#define ip_output(p, src, dest, ttl, tos, proto) \ - ip4_output(p, src, dest, ttl, tos, proto) -#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \ - ip4_output_if(p, src, dest, ttl, tos, proto, netif) -#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif) \ - ip4_output_if_src(p, src, dest, ttl, tos, proto, netif) -#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \ - ip4_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) -#define ip_route(src, dest) \ - ip4_route_src(dest, src) -#define ip_netif_get_local_ip(netif, dest) \ - ip4_netif_get_local_ip(netif) -#define ip_debug_print(is_ipv6, p) ip4_debug_print(p) - -#define ip_input ip4_input - -#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */ - -#define ip_output(p, src, dest, ttl, tos, proto) \ - ip6_output(p, src, dest, ttl, tos, proto) -#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \ - ip6_output_if(p, src, dest, ttl, tos, proto, netif) -#define ip_output_if_src(p, src, dest, ttl, tos, proto, netif) \ - ip6_output_if_src(p, src, dest, ttl, tos, proto, netif) -#define ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) \ - ip6_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) -#define ip_route(src, dest) \ - ip6_route(src, dest) -#define ip_netif_get_local_ip(netif, dest) \ - ip6_netif_get_local_ip(netif, dest) -#define ip_debug_print(is_ipv6, p) ip6_debug_print(p) - -#define ip_input ip6_input - -#endif /* LWIP_IPV6 */ - -#define ip_route_get_local_ip(src, dest, netif, ipaddr) do { \ - (netif) = ip_route(src, dest); \ - (ipaddr) = ip_netif_get_local_ip(netif, dest); \ -}while(0) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_IP_H */ - - diff --git a/include/net/ip4.h b/include/net/ip4.h deleted file mode 100644 index 79e1220..0000000 --- a/include/net/ip4.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file - * IPv4 API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_IP4_H -#define LWIP_HDR_IP4_H - -#include "net/opt.h" - -#if LWIP_IPV4 - -#include "net/def.h" -#include "net/pbuf.h" -#include "net/ip4_addr.h" -#include "net/err.h" -#include "net/netif.h" -#include "net/prot/ip4.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef LWIP_HOOK_IP4_ROUTE_SRC -#define LWIP_IPV4_SRC_ROUTING 1 -#else -#define LWIP_IPV4_SRC_ROUTING 0 -#endif - -/** Currently, the function ip_output_if_opt() is only used with IGMP */ -#define IP_OPTIONS_SEND (LWIP_IPV4 && LWIP_IGMP) - -#define ip_init() /* Compatibility define, no init needed. */ -struct netif *ip4_route(const ip4_addr_t *dest); -#if LWIP_IPV4_SRC_ROUTING -struct netif *ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src); -#else /* LWIP_IPV4_SRC_ROUTING */ -#define ip4_route_src(dest, src) ip4_route(dest) -#endif /* LWIP_IPV4_SRC_ROUTING */ -err_t ip4_input(struct pbuf *p, struct netif *inp); -err_t ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto); -err_t ip4_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif); -err_t ip4_output_if_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif); -#if LWIP_NETIF_HWADDRHINT -err_t ip4_output_hinted(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint); -#endif /* LWIP_NETIF_HWADDRHINT */ -#if IP_OPTIONS_SEND -err_t ip4_output_if_opt(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, - u16_t optlen); -err_t ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, - u16_t optlen); -#endif /* IP_OPTIONS_SEND */ - -#if LWIP_MULTICAST_TX_OPTIONS -void ip4_set_default_multicast_netif(struct netif* default_multicast_netif); -#endif /* LWIP_MULTICAST_TX_OPTIONS */ - -#define ip4_netif_get_local_ip(netif) (((netif) != NULL) ? netif_ip_addr4(netif) : NULL) - -#if IP_DEBUG -void ip4_debug_print(struct pbuf *p); -#else -#define ip4_debug_print(p) -#endif /* IP_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV4 */ - -#endif /* LWIP_HDR_IP_H */ - - diff --git a/include/net/ip4_addr.h b/include/net/ip4_addr.h deleted file mode 100644 index 52d3c96..0000000 --- a/include/net/ip4_addr.h +++ /dev/null @@ -1,227 +0,0 @@ -/** - * @file - * IPv4 address API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_IP4_ADDR_H -#define LWIP_HDR_IP4_ADDR_H - -#include -#include - -#if LWIP_IPV4 - -#ifdef __cplusplus -extern "C" { -#endif - -/** This is the aligned version of ip4_addr_t, - used as local variable, on the stack, etc. */ -struct ip4_addr { - u32_t addr; -}; - -/** ip4_addr_t uses a struct for convenience only, so that the same defines can - * operate both on ip4_addr_t as well as on ip4_addr_p_t. */ -typedef struct ip4_addr ip4_addr_t; - -/** - * struct ipaddr2 is used in the definition of the ARP packet format in - * order to support compilers that don't have structure packing. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip4_addr2 { - PACK_STRUCT_FIELD(u16_t addrw[2]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Forward declaration to not include netif.h */ -struct netif; - -/** 255.255.255.255 */ -#define IPADDR_NONE ((u32_t)0xffffffffUL) -/** 127.0.0.1 */ -#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) -/** 0.0.0.0 */ -#define IPADDR_ANY ((u32_t)0x00000000UL) -/** 255.255.255.255 */ -#define IPADDR_BROADCAST ((u32_t)0xffffffffUL) - -/* Definitions of the bits in an Internet address integer. - - On subnets, host and network parts are found according to - the subnet mask, not these masks. */ -#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) -#define IP_CLASSA_NET 0xff000000 -#define IP_CLASSA_NSHIFT 24 -#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) -#define IP_CLASSA_MAX 128 - -#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) -#define IP_CLASSB_NET 0xffff0000 -#define IP_CLASSB_NSHIFT 16 -#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET) -#define IP_CLASSB_MAX 65536 - -#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) -#define IP_CLASSC_NET 0xffffff00 -#define IP_CLASSC_NSHIFT 8 -#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET) - -#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) -#define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */ -#define IP_CLASSD_NSHIFT 28 /* net and host fields, but */ -#define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */ -#define IP_MULTICAST(a) IP_CLASSD(a) - -#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) -#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) - -#define IP_LOOPBACKNET 127 /* official! */ - -/** Set an IP address given by the four byte-parts */ -#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) - -/** MEMCPY-like copying of IP addresses where addresses are known to be - * 16-bit-aligned if the port is correctly configured (so a port could define - * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ -#ifndef IPADDR2_COPY -#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip4_addr_t)) -#endif - -/** Copy IP address - faster than ip4_addr_set: no NULL check */ -#define ip4_addr_copy(dest, src) ((dest).addr = (src).addr) -/** Safely copy one IP address to another (src may be NULL) */ -#define ip4_addr_set(dest, src) ((dest)->addr = \ - ((src) == NULL ? 0 : \ - (src)->addr)) -/** Set complete address to zero */ -#define ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) -/** Set address to IPADDR_ANY (no need for lwip_htonl()) */ -#define ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) -/** Set address to loopback address */ -#define ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) -/** Check if an address is in the loopback region */ -#define ip4_addr_isloopback(ipaddr) (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32_t)IP_LOOPBACKNET) << 24)) -/** Safely copy one IP address to another and change byte order - * from host- to network-order. */ -#define ip4_addr_set_hton(dest, src) ((dest)->addr = \ - ((src) == NULL ? 0:\ - lwip_htonl((src)->addr))) -/** IPv4 only: set the IP address given as an u32_t */ -#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) -/** IPv4 only: get the IP address as an u32_t */ -#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) - -/** Get the network address by combining host address with netmask */ -#define ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0) - -/** - * Determine if two address are on the same network. - * - * @arg addr1 IP address 1 - * @arg addr2 IP address 2 - * @arg mask network identifier mask - * @return !0 if the network identifiers of both address match - */ -#define ip4_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ - (mask)->addr) == \ - ((addr2)->addr & \ - (mask)->addr)) -#define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) - -#define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY) -#define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1))) - -#define ip4_addr_isbroadcast(addr1, netif) ip4_addr_isbroadcast_u32((addr1)->addr, netif) -u8_t ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif); - -#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr) -u8_t ip4_addr_netmask_valid(u32_t netmask); - -#define ip4_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL)) - -#define ip4_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) - -#define ip4_addr_debug_print_parts(debug, a, b, c, d) \ - LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d)) -#define ip4_addr_debug_print(debug, ipaddr) \ - ip4_addr_debug_print_parts(debug, \ - (u16_t)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0)) -#define ip4_addr_debug_print_val(debug, ipaddr) \ - ip4_addr_debug_print_parts(debug, \ - ip4_addr1_16(&(ipaddr)), \ - ip4_addr2_16(&(ipaddr)), \ - ip4_addr3_16(&(ipaddr)), \ - ip4_addr4_16(&(ipaddr))) - -/* Get one byte from the 4-byte address */ -#define ip4_addr1(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[0]) -#define ip4_addr2(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[1]) -#define ip4_addr3(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[2]) -#define ip4_addr4(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[3]) -/* These are cast to u16_t, with the intent that they are often arguments - * to printf using the U16_F format from cc.h. */ -#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) -#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) -#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) -#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) - -#define IP4ADDR_STRLEN_MAX 16 - -/** For backwards compatibility */ -#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) - -u32_t ipaddr_addr(const char *cp); -int ip4addr_aton(const char *cp, ip4_addr_t *addr); -/** returns ptr to static buffer; not reentrant! */ -char *ip4addr_ntoa(const ip4_addr_t *addr); -char *ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV4 */ - -#endif /* LWIP_HDR_IP_ADDR_H */ diff --git a/include/net/ip4_frag.h b/include/net/ip4_frag.h deleted file mode 100644 index b69d71d..0000000 --- a/include/net/ip4_frag.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @file - * IP fragmentation/reassembly - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Jani Monoses - * - */ - -#ifndef LWIP_HDR_IP4_FRAG_H -#define LWIP_HDR_IP4_FRAG_H - -#include "net/opt.h" -#include "net/err.h" -#include "net/pbuf.h" -#include "net/netif.h" -#include "net/ip_addr.h" -#include "net/ip.h" - -#if LWIP_IPV4 - -#ifdef __cplusplus -extern "C" { -#endif - -#if IP_REASSEMBLY -/* The IP reassembly timer interval in milliseconds. */ -#define IP_TMR_INTERVAL 1000 - -/** IP reassembly helper struct. - * This is exported because memp needs to know the size. - */ -struct ip_reassdata { - struct ip_reassdata *next; - struct pbuf *p; - struct ip_hdr iphdr; - u16_t datagram_len; - u8_t flags; - u8_t timer; -}; - -void ip_reass_init(void); -void ip_reass_tmr(void); -struct pbuf * ip4_reass(struct pbuf *p); -#endif /* IP_REASSEMBLY */ - -#if IP_FRAG -#if !LWIP_NETIF_TX_SINGLE_PBUF -#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED -#define LWIP_PBUF_CUSTOM_REF_DEFINED -/** A custom pbuf that holds a reference to another pbuf, which is freed - * when this custom pbuf is freed. This is used to create a custom PBUF_REF - * that points into the original pbuf. */ -struct pbuf_custom_ref { - /** 'base class' */ - struct pbuf_custom pc; - /** pointer to the original pbuf that is referenced */ - struct pbuf *original; -}; -#endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ -#endif /* !LWIP_NETIF_TX_SINGLE_PBUF */ - -err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest); -#endif /* IP_FRAG */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV4 */ - -#endif /* LWIP_HDR_IP4_FRAG_H */ diff --git a/include/net/ip6.h b/include/net/ip6.h deleted file mode 100644 index acc6b4b..0000000 --- a/include/net/ip6.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file - * - * IPv6 layer. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef LWIP_HDR_IP6_H -#define LWIP_HDR_IP6_H - -#include "net/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "net/ip6_addr.h" -#include "net/prot/ip6.h" -#include "net/def.h" -#include "net/pbuf.h" -#include "net/netif.h" - -#include "net/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest); -const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest); -err_t ip6_input(struct pbuf *p, struct netif *inp); -err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth); -err_t ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); -err_t ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); -#if LWIP_NETIF_HWADDRHINT -err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint); -#endif /* LWIP_NETIF_HWADDRHINT */ -#if LWIP_IPV6_MLD -err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value); -#endif /* LWIP_IPV6_MLD */ - -#define ip6_netif_get_local_ip(netif, dest) (((netif) != NULL) ? \ - ip6_select_source_address(netif, dest) : NULL) - -#if IP6_DEBUG -void ip6_debug_print(struct pbuf *p); -#else -#define ip6_debug_print(p) -#endif /* IP6_DEBUG */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* LWIP_HDR_IP6_H */ diff --git a/include/net/ip6_addr.h b/include/net/ip6_addr.h deleted file mode 100644 index 845a60c..0000000 --- a/include/net/ip6_addr.h +++ /dev/null @@ -1,285 +0,0 @@ -/** - * @file - * - * IPv6 addresses. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * Structs and macros for handling IPv6 addresses. - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef LWIP_HDR_IP6_ADDR_H -#define LWIP_HDR_IP6_ADDR_H - -#include -#include - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - - -#ifdef __cplusplus -extern "C" { -#endif - - -/** This is the aligned version of ip6_addr_t, - used as local variable, on the stack, etc. */ -struct ip6_addr { - u32_t addr[4]; -}; - -/** IPv6 address */ -typedef struct ip6_addr ip6_addr_t; - -/** Set an IPv6 partial address given by byte-parts */ -#define IP6_ADDR_PART(ip6addr, index, a,b,c,d) \ - (ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) - -/** Set a full IPv6 address by passing the 4 u32_t indices in network byte order - (use PP_HTONL() for constants) */ -#define IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3) do { \ - (ip6addr)->addr[0] = idx0; \ - (ip6addr)->addr[1] = idx1; \ - (ip6addr)->addr[2] = idx2; \ - (ip6addr)->addr[3] = idx3; } while(0) - -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff)) -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3])) & 0xffff)) - -/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */ -#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \ - (dest).addr[1] = (src).addr[1]; \ - (dest).addr[2] = (src).addr[2]; \ - (dest).addr[3] = (src).addr[3];}while(0) -/** Safely copy one IPv6 address to another (src may be NULL) */ -#define ip6_addr_set(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \ - (dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \ - (dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \ - (dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3];}while(0) - -/** Set complete address to zero */ -#define ip6_addr_set_zero(ip6addr) do{(ip6addr)->addr[0] = 0; \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = 0;}while(0) - -/** Set address to ipv6 'any' (no need for lwip_htonl()) */ -#define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr) -/** Set address to ipv6 loopback address */ -#define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) -/** Safely copy one IPv6 address to another and change byte order - * from host- to network-order. */ -#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : lwip_htonl((src)->addr[0]); \ - (dest)->addr[1] = (src) == NULL ? 0 : lwip_htonl((src)->addr[1]); \ - (dest)->addr[2] = (src) == NULL ? 0 : lwip_htonl((src)->addr[2]); \ - (dest)->addr[3] = (src) == NULL ? 0 : lwip_htonl((src)->addr[3]);}while(0) - - -/** - * Determine if two IPv6 address are on the same network. - * - * @arg addr1 IPv6 address 1 - * @arg addr2 IPv6 address 2 - * @return !0 if the network identifiers of both address match - */ -#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ - ((addr1)->addr[1] == (addr2)->addr[1])) - -#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ - ((addr1)->addr[1] == (addr2)->addr[1]) && \ - ((addr1)->addr[2] == (addr2)->addr[2]) && \ - ((addr1)->addr[3] == (addr2)->addr[3])) - -#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[2]) & 0x0000ffffUL) - -#define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \ - ((ip6addr).addr[1] == 0) && \ - ((ip6addr).addr[2] == 0) && \ - ((ip6addr).addr[3] == 0)) -#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || ip6_addr_isany_val(*(ip6addr))) - -#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) - -#define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL)) - -#define ip6_addr_islinklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfe800000UL)) - -#define ip6_addr_issitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfec00000UL)) - -#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL)) - -#define ip6_addr_isipv4mappedipv6(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL))) - -#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) -#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL)) -#define ip6_addr_multicast_prefix_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00200000UL)) -#define ip6_addr_multicast_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL)) -#define ip6_addr_multicast_scope(ip6addr) ((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xf) -#define IP6_MULTICAST_SCOPE_RESERVED 0x0 -#define IP6_MULTICAST_SCOPE_RESERVED0 0x0 -#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1 -#define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2 -#define IP6_MULTICAST_SCOPE_RESERVED3 0x3 -#define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4 -#define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5 -#define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8 -#define IP6_MULTICAST_SCOPE_GLOBAL 0xe -#define IP6_MULTICAST_SCOPE_RESERVEDF 0xf -#define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff010000UL)) -#define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff020000UL)) -#define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff040000UL)) -#define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff050000UL)) -#define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff080000UL)) -#define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff0e0000UL)) - -/* @todo define get/set for well-know multicast addresses, e.g. ff02::1 */ -#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) - -#define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) -#define ip6_addr_set_allnodes_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) - -#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000002UL))) -#define ip6_addr_set_allrouters_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = PP_HTONL(0x00000002UL);}while(0) - -#define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ - (((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) ) - -#define ip6_addr_set_solicitednode(ip6addr, if_id) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \ - (ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id));}while(0) - -#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[1] == 0) && \ - ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ - ((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3]))) - -/* IPv6 address states. */ -#define IP6_ADDR_INVALID 0x00 -#define IP6_ADDR_TENTATIVE 0x08 -#define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */ -#define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */ -#define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */ -#define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */ -#define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */ -#define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */ -#define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */ -#define IP6_ADDR_VALID 0x10 /* This bit marks an address as valid (preferred or deprecated) */ -#define IP6_ADDR_PREFERRED 0x30 -#define IP6_ADDR_DEPRECATED 0x10 /* Same as VALID (valid but not preferred) */ - -#define IP6_ADDR_TENTATIVE_COUNT_MASK 0x07 /* 1-7 probes sent */ - -#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID) -#define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE) -#define ip6_addr_isvalid(addr_state) (addr_state & IP6_ADDR_VALID) /* Include valid, preferred, and deprecated. */ -#define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED) -#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED) - -#define ip6_addr_debug_print_parts(debug, a, b, c, d, e, f, g, h) \ - LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \ - a, b, c, d, e, f, g, h)) -#define ip6_addr_debug_print(debug, ipaddr) \ - ip6_addr_debug_print_parts(debug, \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0), \ - (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)) -#define ip6_addr_debug_print_val(debug, ipaddr) \ - ip6_addr_debug_print_parts(debug, \ - IP6_ADDR_BLOCK1(&(ipaddr)), \ - IP6_ADDR_BLOCK2(&(ipaddr)), \ - IP6_ADDR_BLOCK3(&(ipaddr)), \ - IP6_ADDR_BLOCK4(&(ipaddr)), \ - IP6_ADDR_BLOCK5(&(ipaddr)), \ - IP6_ADDR_BLOCK6(&(ipaddr)), \ - IP6_ADDR_BLOCK7(&(ipaddr)), \ - IP6_ADDR_BLOCK8(&(ipaddr))) - -#define IP6ADDR_STRLEN_MAX 46 - -int ip6addr_aton(const char *cp, ip6_addr_t *addr); -/** returns ptr to static buffer; not reentrant! */ -char *ip6addr_ntoa(const ip6_addr_t *addr); -char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen); - - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* LWIP_HDR_IP6_ADDR_H */ diff --git a/include/net/ip6_frag.h b/include/net/ip6_frag.h deleted file mode 100644 index 8e65edc..0000000 --- a/include/net/ip6_frag.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file - * - * IPv6 fragmentation and reassembly. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef LWIP_HDR_IP6_FRAG_H -#define LWIP_HDR_IP6_FRAG_H - -#include "net/opt.h" -#include "net/pbuf.h" -#include "net/ip6_addr.h" -#include "net/ip6.h" -#include "net/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ - -/** IP6_FRAG_COPYHEADER==1: for platforms where sizeof(void*) > 4, this needs to - * be enabled (to not overwrite part of the data). When enabled, the IPv6 header - * is copied instead of referencing it, which gives more room for struct ip6_reass_helper */ -#ifndef IPV6_FRAG_COPYHEADER -#define IPV6_FRAG_COPYHEADER 0 -#endif - -/** The IPv6 reassembly timer interval in milliseconds. */ -#define IP6_REASS_TMR_INTERVAL 1000 - -/* Copy the complete header of the first fragment to struct ip6_reassdata - or just point to its original location in the first pbuf? */ -#if IPV6_FRAG_COPYHEADER -#define IPV6_FRAG_HDRPTR -#define IPV6_FRAG_HDRREF(hdr) (&(hdr)) -#else /* IPV6_FRAG_COPYHEADER */ -#define IPV6_FRAG_HDRPTR * -#define IPV6_FRAG_HDRREF(hdr) (hdr) -#endif /* IPV6_FRAG_COPYHEADER */ - -/** IPv6 reassembly helper struct. - * This is exported because memp needs to know the size. - */ -struct ip6_reassdata { - struct ip6_reassdata *next; - struct pbuf *p; - struct ip6_hdr IPV6_FRAG_HDRPTR iphdr; - u32_t identification; - u16_t datagram_len; - u8_t nexth; - u8_t timer; -}; - -#define ip6_reass_init() /* Compatibility define */ -void ip6_reass_tmr(void); -struct pbuf *ip6_reass(struct pbuf *p); - -#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ - -#if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */ - -#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED -#define LWIP_PBUF_CUSTOM_REF_DEFINED -/** A custom pbuf that holds a reference to another pbuf, which is freed - * when this custom pbuf is freed. This is used to create a custom PBUF_REF - * that points into the original pbuf. */ -struct pbuf_custom_ref { - /** 'base class' */ - struct pbuf_custom pc; - /** pointer to the original pbuf that is referenced */ - struct pbuf *original; -}; -#endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ - -err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest); - -#endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_IP6_FRAG_H */ diff --git a/include/net/ip_addr.h b/include/net/ip_addr.h deleted file mode 100644 index 2abb791..0000000 --- a/include/net/ip_addr.h +++ /dev/null @@ -1,407 +0,0 @@ -/** - * @file - * IP address API (common IPv4 and IPv6) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_IP_ADDR_H -#define LWIP_HDR_IP_ADDR_H - -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup ipaddr - * IP address types for use in ip_addr_t.type member. - * @see tcp_new_ip_type(), udp_new_ip_type(), raw_new_ip_type(). - */ -enum lwip_ip_addr_type { - /** IPv4 */ - IPADDR_TYPE_V4 = 0U, - /** IPv6 */ - IPADDR_TYPE_V6 = 6U, - /** IPv4+IPv6 ("dual-stack") */ - IPADDR_TYPE_ANY = 46U -}; - -#if LWIP_IPV4 && LWIP_IPV6 -/** - * @ingroup ipaddr - * A union struct for both IP version's addresses. - * ATTENTION: watch out for its size when adding IPv6 address scope! - */ -typedef struct ip_addr { - union { - ip6_addr_t ip6; - ip4_addr_t ip4; - } u_addr; - /** @ref lwip_ip_addr_type */ - u8_t type; -} ip_addr_t; - -extern const ip_addr_t ip_addr_any_type; - -/** @ingroup ip4addr */ -#define IPADDR4_INIT(u32val) { { { { u32val, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_V4 } -/** @ingroup ip4addr */ -#define IPADDR4_INIT_BYTES(a,b,c,d) IPADDR4_INIT(PP_HTONL(LWIP_MAKEU32(a,b,c,d))) -/** @ingroup ip6addr */ -#define IPADDR6_INIT(a, b, c, d) { { { { a, b, c, d } } }, IPADDR_TYPE_V6 } -/** @ingroup ip6addr */ -#define IPADDR6_INIT_HOST(a, b, c, d) { { { { PP_HTONL(a), PP_HTONL(b), PP_HTONL(c), PP_HTONL(d) } } }, IPADDR_TYPE_V6 } - -/** @ingroup ipaddr */ -#define IP_IS_ANY_TYPE_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_ANY) -/** @ingroup ipaddr */ -#define IPADDR_ANY_TYPE_INIT { { { { 0ul, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_ANY } - -/** @ingroup ip4addr */ -#define IP_IS_V4_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V4) -/** @ingroup ip6addr */ -#define IP_IS_V6_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V6) -/** @ingroup ip4addr */ -#define IP_IS_V4(ipaddr) (((ipaddr) == NULL) || IP_IS_V4_VAL(*(ipaddr))) -/** @ingroup ip6addr */ -#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr))) - -#define IP_SET_TYPE_VAL(ipaddr, iptype) do { (ipaddr).type = (iptype); }while(0) -#define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0) -#define IP_GET_TYPE(ipaddr) ((ipaddr)->type) - -#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) (IP_GET_TYPE(&pcb->local_ip) == IP_GET_TYPE(ipaddr)) -#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (IP_IS_ANY_TYPE_VAL(pcb->local_ip) || IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr)) - -/** @ingroup ip6addr - * Convert generic ip address to specific protocol version - */ -#define ip_2_ip6(ipaddr) (&((ipaddr)->u_addr.ip6)) -/** @ingroup ip4addr - * Convert generic ip address to specific protocol version - */ -#define ip_2_ip4(ipaddr) (&((ipaddr)->u_addr.ip4)) - -/** @ingroup ip4addr */ -#define IP_ADDR4(ipaddr,a,b,c,d) do { IP4_ADDR(ip_2_ip4(ipaddr),a,b,c,d); \ - IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V4); } while(0) -/** @ingroup ip6addr */ -#define IP_ADDR6(ipaddr,i0,i1,i2,i3) do { IP6_ADDR(ip_2_ip6(ipaddr),i0,i1,i2,i3); \ - IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V6); } while(0) -/** @ingroup ip6addr */ -#define IP_ADDR6_HOST(ipaddr,i0,i1,i2,i3) IP_ADDR6(ipaddr,PP_HTONL(i0),PP_HTONL(i1),PP_HTONL(i2),PP_HTONL(i3)) - -/** @ingroup ipaddr */ -#define ip_addr_copy(dest, src) do{ IP_SET_TYPE_VAL(dest, IP_GET_TYPE(&src)); if(IP_IS_V6_VAL(src)){ \ - ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); }else{ \ - ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); }}while(0) -/** @ingroup ip6addr */ -#define ip_addr_copy_from_ip6(dest, src) do{ \ - ip6_addr_copy(*ip_2_ip6(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); }while(0) -/** @ingroup ip4addr */ -#define ip_addr_copy_from_ip4(dest, src) do{ \ - ip4_addr_copy(*ip_2_ip4(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4); }while(0) -/** @ingroup ip4addr */ -#define ip_addr_set_ip4_u32(ipaddr, val) do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \ - IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0) -/** @ingroup ip4addr */ -#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && IP_IS_V4(ipaddr)) ? \ - ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0) -/** @ingroup ipaddr */ -#define ip_addr_set(dest, src) do{ IP_SET_TYPE(dest, IP_GET_TYPE(src)); if(IP_IS_V6(src)){ \ - ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); }else{ \ - ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); }}while(0) -/** @ingroup ipaddr */ -#define ip_addr_set_ipaddr(dest, src) ip_addr_set(dest, src) -/** @ingroup ipaddr */ -#define ip_addr_set_zero(ipaddr) do{ \ - ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); }while(0) -/** @ingroup ip5addr */ -#define ip_addr_set_zero_ip4(ipaddr) do{ \ - ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }while(0) -/** @ingroup ip6addr */ -#define ip_addr_set_zero_ip6(ipaddr) do{ \ - ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }while(0) -/** @ingroup ipaddr */ -#define ip_addr_set_any(is_ipv6, ipaddr) do{if(is_ipv6){ \ - ip6_addr_set_any(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }else{ \ - ip4_addr_set_any(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0) -/** @ingroup ipaddr */ -#define ip_addr_set_loopback(is_ipv6, ipaddr) do{if(is_ipv6){ \ - ip6_addr_set_loopback(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }else{ \ - ip4_addr_set_loopback(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0) -/** @ingroup ipaddr */ -#define ip_addr_set_hton(dest, src) do{if(IP_IS_V6(src)){ \ - ip6_addr_set_hton(ip_2_ip6(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \ - ip4_addr_set_hton(ip_2_ip4(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0) -/** @ingroup ipaddr */ -#define ip_addr_get_network(target, host, netmask) do{if(IP_IS_V6(host)){ \ - ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \ - ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); IP_SET_TYPE(target, IPADDR_TYPE_V4); }}while(0) -/** @ingroup ipaddr */ -#define ip_addr_netcmp(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \ - 0 : \ - ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask)) -/** @ingroup ipaddr */ -#define ip_addr_cmp(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \ - ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \ - ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2)))) -/** @ingroup ipaddr */ -#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \ - ip6_addr_isany(ip_2_ip6(ipaddr)) : \ - ip4_addr_isany(ip_2_ip4(ipaddr))) -/** @ingroup ipaddr */ -#define ip_addr_isany_val(ipaddr) ((IP_IS_V6_VAL(ipaddr)) ? \ - ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \ - ip4_addr_isany_val(*ip_2_ip4(&(ipaddr)))) -/** @ingroup ipaddr */ -#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \ - 0 : \ - ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif)) -/** @ingroup ipaddr */ -#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \ - ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \ - ip4_addr_ismulticast(ip_2_ip4(ipaddr))) -/** @ingroup ipaddr */ -#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \ - ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \ - ip4_addr_isloopback(ip_2_ip4(ipaddr))) -/** @ingroup ipaddr */ -#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \ - ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \ - ip4_addr_islinklocal(ip_2_ip4(ipaddr))) -#define ip_addr_debug_print(debug, ipaddr) do { if(IP_IS_V6(ipaddr)) { \ - ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); } else { \ - ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); }}while(0) -#define ip_addr_debug_print_val(debug, ipaddr) do { if(IP_IS_V6_VAL(ipaddr)) { \ - ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); } else { \ - ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); }}while(0) -/** @ingroup ipaddr */ -#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \ - ((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr)))) -/** @ingroup ipaddr */ -#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \ - ((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen))) -int ipaddr_aton(const char *cp, ip_addr_t *addr); - -/** @ingroup ipaddr */ -#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX - -/** @ingroup ipaddr */ -#define ip4_2_ipv4_mapped_ipv6(ip6addr, ip4addr) do { \ - (ip6addr)->addr[3] = (ip4addr)->addr; \ - (ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[0] = 0; } while(0); - -/** @ingroup ipaddr */ -#define unmap_ipv4_mapped_ipv6(ip4addr, ip6addr) \ - (ip4addr)->addr = (ip6addr)->addr[3]; - -#define IP46_ADDR_ANY(type) (((type) == IPADDR_TYPE_V6)? IP6_ADDR_ANY : IP4_ADDR_ANY) - -#else /* LWIP_IPV4 && LWIP_IPV6 */ - -#define IP_ADDR_PCB_VERSION_MATCH(addr, pcb) 1 -#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) 1 - -#if LWIP_IPV4 - -typedef ip4_addr_t ip_addr_t; -#define IPADDR4_INIT(u32val) { u32val } -#define IPADDR4_INIT_BYTES(a,b,c,d) IPADDR4_INIT(PP_HTONL(LWIP_MAKEU32(a,b,c,d))) -#define IP_IS_V4_VAL(ipaddr) 1 -#define IP_IS_V6_VAL(ipaddr) 0 -#define IP_IS_V4(ipaddr) 1 -#define IP_IS_V6(ipaddr) 0 -#define IP_IS_ANY_TYPE_VAL(ipaddr) 0 -#define IP_SET_TYPE_VAL(ipaddr, iptype) -#define IP_SET_TYPE(ipaddr, iptype) -#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V4 -#define ip_2_ip4(ipaddr) (ipaddr) -#define IP_ADDR4(ipaddr,a,b,c,d) IP4_ADDR(ipaddr,a,b,c,d) - -#define ip_addr_copy(dest, src) ip4_addr_copy(dest, src) -#define ip_addr_copy_from_ip4(dest, src) ip4_addr_copy(dest, src) -#define ip_addr_set_ip4_u32(ipaddr, val) ip4_addr_set_u32(ip_2_ip4(ipaddr), val) -#define ip_addr_get_ip4_u32(ipaddr) ip4_addr_get_u32(ip_2_ip4(ipaddr)) -#define ip_addr_set(dest, src) ip4_addr_set(dest, src) -#define ip_addr_set_ipaddr(dest, src) ip4_addr_set(dest, src) -#define ip_addr_set_zero(ipaddr) ip4_addr_set_zero(ipaddr) -#define ip_addr_set_zero_ip4(ipaddr) ip4_addr_set_zero(ipaddr) -#define ip_addr_set_any(is_ipv6, ipaddr) ip4_addr_set_any(ipaddr) -#define ip_addr_set_loopback(is_ipv6, ipaddr) ip4_addr_set_loopback(ipaddr) -#define ip_addr_set_hton(dest, src) ip4_addr_set_hton(dest, src) -#define ip_addr_get_network(target, host, mask) ip4_addr_get_network(target, host, mask) -#define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_netcmp(addr1, addr2, mask) -#define ip_addr_cmp(addr1, addr2) ip4_addr_cmp(addr1, addr2) -#define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr) -#define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr) -#define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr) -#define ip_addr_islinklocal(ipaddr) ip4_addr_islinklocal(ipaddr) -#define ip_addr_isbroadcast(addr, netif) ip4_addr_isbroadcast(addr, netif) -#define ip_addr_ismulticast(ipaddr) ip4_addr_ismulticast(ipaddr) -#define ip_addr_debug_print(debug, ipaddr) ip4_addr_debug_print(debug, ipaddr) -#define ip_addr_debug_print_val(debug, ipaddr) ip4_addr_debug_print_val(debug, ipaddr) -#define ipaddr_ntoa(ipaddr) ip4addr_ntoa(ipaddr) -#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip4addr_ntoa_r(ipaddr, buf, buflen) -#define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr) - -#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX - -#define IP46_ADDR_ANY(type) (IP4_ADDR_ANY) - -#else /* LWIP_IPV4 */ - -typedef ip6_addr_t ip_addr_t; -#define IPADDR6_INIT(a, b, c, d) { { a, b, c, d } } -#define IPADDR6_INIT_HOST(a, b, c, d) { { PP_HTONL(a), PP_HTONL(b), PP_HTONL(c), PP_HTONL(d) } } -#define IP_IS_V4_VAL(ipaddr) 0 -#define IP_IS_V6_VAL(ipaddr) 1 -#define IP_IS_V4(ipaddr) 0 -#define IP_IS_V6(ipaddr) 1 -#define IP_IS_ANY_TYPE_VAL(ipaddr) 0 -#define IP_SET_TYPE_VAL(ipaddr, iptype) -#define IP_SET_TYPE(ipaddr, iptype) -#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V6 -#define ip_2_ip6(ipaddr) (ipaddr) -#define IP_ADDR6(ipaddr,i0,i1,i2,i3) IP6_ADDR(ipaddr,i0,i1,i2,i3) -#define IP_ADDR6_HOST(ipaddr,i0,i1,i2,i3) IP_ADDR6(ipaddr,PP_HTONL(i0),PP_HTONL(i1),PP_HTONL(i2),PP_HTONL(i3)) - -#define ip_addr_copy(dest, src) ip6_addr_copy(dest, src) -#define ip_addr_copy_from_ip6(dest, src) ip6_addr_copy(dest, src) -#define ip_addr_set(dest, src) ip6_addr_set(dest, src) -#define ip_addr_set_ipaddr(dest, src) ip6_addr_set(dest, src) -#define ip_addr_set_zero(ipaddr) ip6_addr_set_zero(ipaddr) -#define ip_addr_set_zero_ip6(ipaddr) ip6_addr_set_zero(ipaddr) -#define ip_addr_set_any(is_ipv6, ipaddr) ip6_addr_set_any(ipaddr) -#define ip_addr_set_loopback(is_ipv6, ipaddr) ip6_addr_set_loopback(ipaddr) -#define ip_addr_set_hton(dest, src) ip6_addr_set_hton(dest, src) -#define ip_addr_get_network(target, host, mask) ip6_addr_set_zero(target) -#define ip_addr_netcmp(addr1, addr2, mask) 0 -#define ip_addr_cmp(addr1, addr2) ip6_addr_cmp(addr1, addr2) -#define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr) -#define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr) -#define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr) -#define ip_addr_islinklocal(ipaddr) ip6_addr_islinklocal(ipaddr) -#define ip_addr_isbroadcast(addr, netif) 0 -#define ip_addr_ismulticast(ipaddr) ip6_addr_ismulticast(ipaddr) -#define ip_addr_debug_print(debug, ipaddr) ip6_addr_debug_print(debug, ipaddr) -#define ip_addr_debug_print_val(debug, ipaddr) ip6_addr_debug_print_val(debug, ipaddr) -#define ipaddr_ntoa(ipaddr) ip6addr_ntoa(ipaddr) -#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip6addr_ntoa_r(ipaddr, buf, buflen) -#define ipaddr_aton(cp, addr) ip6addr_aton(cp, addr) - -#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX - -#define IP46_ADDR_ANY(type) (IP6_ADDR_ANY) - -#endif /* LWIP_IPV4 */ -#endif /* LWIP_IPV4 && LWIP_IPV6 */ - -#if LWIP_IPV4 - -extern const ip_addr_t ip_addr_any; -extern const ip_addr_t ip_addr_broadcast; - -/** - * @ingroup ip4addr - * Can be used as a fixed/const ip_addr_t - * for the IP wildcard. - * Defined to @ref IP4_ADDR_ANY when IPv4 is enabled. - * Defined to @ref IP6_ADDR_ANY in IPv6 only systems. - * Use this if you can handle IPv4 _AND_ IPv6 addresses. - * Use @ref IP4_ADDR_ANY or @ref IP6_ADDR_ANY when the IP - * type matters. - */ -#define IP_ADDR_ANY IP4_ADDR_ANY -/** - * @ingroup ip4addr - * Can be used as a fixed/const ip_addr_t - * for the IPv4 wildcard and the broadcast address - */ -#define IP4_ADDR_ANY (&ip_addr_any) -/** - * @ingroup ip4addr - * Can be used as a fixed/const ip4_addr_t - * for the wildcard and the broadcast address - */ -#define IP4_ADDR_ANY4 (ip_2_ip4(&ip_addr_any)) - -/** @ingroup ip4addr */ -#define IP_ADDR_BROADCAST (&ip_addr_broadcast) -/** @ingroup ip4addr */ -#define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast)) - -#endif /* LWIP_IPV4*/ - -#if LWIP_IPV6 - -extern const ip_addr_t ip6_addr_any; - -/** - * @ingroup ip6addr - * IP6_ADDR_ANY can be used as a fixed ip_addr_t - * for the IPv6 wildcard address - */ -#define IP6_ADDR_ANY (&ip6_addr_any) -/** - * @ingroup ip6addr - * IP6_ADDR_ANY6 can be used as a fixed ip6_addr_t - * for the IPv6 wildcard address - */ -#define IP6_ADDR_ANY6 (ip_2_ip6(&ip6_addr_any)) - -#if !LWIP_IPV4 -/** IPv6-only configurations */ -#define IP_ADDR_ANY IP6_ADDR_ANY -#endif /* !LWIP_IPV4 */ - -#endif - -#if LWIP_IPV4 && LWIP_IPV6 -/** @ingroup ipaddr */ -#define IP_ANY_TYPE (&ip_addr_any_type) -#else -#define IP_ANY_TYPE IP_ADDR_ANY -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_IP_ADDR_H */ diff --git a/include/net/lwipopts.h b/include/net/lwipopts.h deleted file mode 100644 index f648244..0000000 --- a/include/net/lwipopts.h +++ /dev/null @@ -1,497 +0,0 @@ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ - -#ifndef LWIP_HDR_LWIPOPTS_H -#define LWIP_HDR_LWIPOPTS_H - -/* NEVER Set To 1, 1 Will Remove OS Abstraction */ -#define NO_SYS 0 - -/* Timer Settings */ -#define LWIP_TIMERS 1 -#define LWIP_TIMERS_CUSTOM 0 - -#define MEMCPY(dst, src, len) memcpy(dst,src,len) -#define SMEMCPY(dst, src, len) memcpy(dst,src,len) - -/* Core locking and MPU */ -#define LWIP_MPU_COMPATIBLE 0 -#define LWIP_TCPIP_CORE_LOCKING 1 -#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 -#define SYS_LIGHTWEIGHT_PROT 0 - - -#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 -#define MEM_ALIGNMENT 1 -#define MEM_LIBC_MALLOC 0 -#define MEM_SIZE 1600 -#define MEM_USE_POOLS 0 -#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 - -#define MEMP_MEM_MALLOC 0 -#define MEMP_SANITY_CHECK 0 -#define MEMP_USE_CUSTOM_POOLS 0 -#define MEMP_OVERFLOW_CHECK 0 - -#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API -#define MEMP_NUM_ARP_QUEUE 30 -#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API -#define MEMP_NUM_FRAG_PBUF 15 -#define MEMP_NUM_IGMP_GROUP 8 -#define MEMP_NUM_LOCALHOSTLIST 1 -#define MEMP_NUM_NETBUF 2 -#define MEMP_NUM_NETCONN 4 -#define MEMP_NUM_NETDB 1 -#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API -#define MEMP_NUM_PBUF 16 -#define MEMP_NUM_RAW_PCB 4 -#define MEMP_NUM_REASSDATA 5 -#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API -#define MEMP_NUM_TCP_PCB 5 -#define MEMP_NUM_TCP_PCB_LISTEN 8 -#define MEMP_NUM_TCP_SEG 16 -#define MEMP_NUM_TCPIP_MSG_API 8 -#define MEMP_NUM_TCPIP_MSG_INPKT 8 -#define MEMP_NUM_UDP_PCB 4 -#define PBUF_POOL_SIZE 16 - -#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) - -#define LWIP_ARP 1 - -#define ARP_TABLE_SIZE 10 - -#define ARP_MAXAGE 300 - -#define ARP_QUEUEING 0 - -#define ARP_QUEUE_LEN 3 - -#define ETHARP_SUPPORT_VLAN 0 - -#define LWIP_ETHERNET LWIP_ARP - -#define ETH_PAD_SIZE 0 - -#define ETHARP_SUPPORT_STATIC_ENTRIES 0 - -#define ETHARP_TABLE_MATCH_NETIF 0 - -#define LWIP_IPV4 1 - -#define IP_FORWARD 0 - -#define IP_REASSEMBLY 1 - -#define IP_FRAG 1 - -#define IP_OPTIONS_ALLOWED 1 - -#define IP_REASS_MAXAGE 3 - -#define IP_REASS_MAX_PBUFS 10 - -#define IP_DEFAULT_TTL 255 - -#define IP_SOF_BROADCAST 0 - -#define IP_SOF_BROADCAST_RECV 0 - -#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0 - -#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0 - -#define LWIP_ICMP 1 - -#define ICMP_TTL (IP_DEFAULT_TTL) - -#define LWIP_BROADCAST_PING 1 - -#define LWIP_MULTICAST_PING 0 - -#define LWIP_RAW 1 - -#define RAW_TTL (IP_DEFAULT_TTL) - -#define LWIP_DHCP 0 -#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP)) -#define LWIP_DHCP_BOOTP_FILE 0 -#define LWIP_DHCP_GET_NTP_SRV 0 -#define LWIP_DHCP_MAX_NTP_SERVERS 1 -#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS -#define LWIP_AUTOIP 0 -#define LWIP_DHCP_AUTOIP_COOP 0 -#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 -#define LWIP_MIB2_CALLBACKS 0 -#define LWIP_IGMP 0 -#define LWIP_MULTICAST_TX_OPTIONS (LWIP_IGMP && LWIP_UDP) -#define LWIP_DNS 0 -#define DNS_TABLE_SIZE 4 -#define DNS_MAX_NAME_LENGTH 256 -#define DNS_MAX_SERVERS 2 -#define DNS_DOES_NAME_CHECK 1 -#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -#define DNS_LOCAL_HOSTLIST 0 -#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0 -#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0 -#define LWIP_UDP 1 -#define LWIP_UDPLITE 0 -#define UDP_TTL (IP_DEFAULT_TTL) -#define LWIP_NETBUF_RECVINFO 0 -#define LWIP_TCP 1 -#define TCP_TTL (IP_DEFAULT_TTL) -#define TCP_WND (4 * TCP_MSS) - -#define TCP_MAXRTX 12 - -#define TCP_SYNMAXRTX 6 - -#define TCP_QUEUE_OOSEQ (LWIP_TCP) - -#define TCP_MSS 536 - -#define TCP_CALCULATE_EFF_SEND_MSS 1 - -#define TCP_SND_BUF (2 * TCP_MSS) - -#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) - -#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) - -#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5) - -#define TCP_OOSEQ_MAX_BYTES 0 - -#define TCP_OOSEQ_MAX_PBUFS 0 - -#define TCP_LISTEN_BACKLOG 0 - -#define TCP_DEFAULT_LISTEN_BACKLOG 0xff - -#define TCP_OVERSIZE TCP_MSS - -#define LWIP_TCP_TIMESTAMPS 1 - -#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4)) - -#define LWIP_EVENT_API 0 -#define LWIP_WND_SCALE 0 - -#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) - -#define PBUF_LINK_ENCAPSULATION_HLEN 0u - -#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN) - -#define LWIP_NETIF_HOSTNAME 0 - -#define LWIP_NETIF_API 0 - -#define LWIP_NETIF_STATUS_CALLBACK 0 - -#define LWIP_NETIF_LINK_CALLBACK 0 - -#define LWIP_NETIF_REMOVE_CALLBACK 0 - -#define LWIP_NETIF_HWADDRHINT 0 - -#define LWIP_NETIF_TX_SINGLE_PBUF 0 - -#define LWIP_NUM_NETIF_CLIENT_DATA 0 - -#define LWIP_HAVE_LOOPIF LWIP_NETIF_LOOPBACK - -#define LWIP_LOOPIF_MULTICAST 0 - -#define LWIP_NETIF_LOOPBACK 1 - -#define LWIP_LOOPBACK_MAX_PBUFS 0 - -#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) - -#define TCPIP_THREAD_NAME "tcpip_thread" - -#define TCPIP_THREAD_STACKSIZE 0 - -#define TCPIP_THREAD_PRIO 1 - -#define TCPIP_MBOX_SIZE 6 - -#define LWIP_TCPIP_THREAD_ALIVE() - -#define SLIPIF_THREAD_NAME "slipif_loop" - -#define SLIPIF_THREAD_STACKSIZE 0 - -#define SLIPIF_THREAD_PRIO 1 - -#define DEFAULT_THREAD_NAME "lwIP" - -#define DEFAULT_THREAD_STACKSIZE 0 - -#define DEFAULT_THREAD_PRIO 1 - -#define DEFAULT_RAW_RECVMBOX_SIZE 0 - -#define DEFAULT_UDP_RECVMBOX_SIZE 0 - -#define DEFAULT_TCP_RECVMBOX_SIZE 0 - -#define DEFAULT_ACCEPTMBOX_SIZE 0 - -#define LWIP_NETCONN 1 - -#define LWIP_TCPIP_TIMEOUT 1 - -#define LWIP_NETCONN_SEM_PER_THREAD 0 - -#define LWIP_NETCONN_FULLDUPLEX 0 - -#define LWIP_SOCKET 1 - -#define LWIP_COMPAT_SOCKETS 1 - -#define LWIP_POSIX_SOCKETS_IO_NAMES 1 - -#define LWIP_SOCKET_OFFSET 0 - -#define LWIP_TCP_KEEPALIVE 0 - -#define LWIP_SO_SNDTIMEO 1 - -#define LWIP_SO_RCVTIMEO 1 - -#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0 - -#define LWIP_SO_RCVBUF 0 - -#define LWIP_SO_LINGER 0 - -#define RECV_BUFSIZE_DEFAULT INT_MAX - -#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000 - -#define SO_REUSE 0 - -#define SO_REUSE_RXTOALL 0 - -#define LWIP_FIONREAD_LINUXMODE 0 - -#define LWIP_STATS 1 - -#define LWIP_STATS_DISPLAY 0 - -#define LINK_STATS 1 - -#define ETHARP_STATS (LWIP_ARP) - -#define IP_STATS 1 - -#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG) - -#define ICMP_STATS 1 - -#define IGMP_STATS (LWIP_IGMP) - -#define UDP_STATS (LWIP_UDP) - -#define TCP_STATS (LWIP_TCP) - -#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0)) - -#define MEMP_STATS (MEMP_MEM_MALLOC == 0) - -#define SYS_STATS (NO_SYS == 0) - -#define IP6_STATS (LWIP_IPV6) - -#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6) - -#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS)) - -#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD) - -#define ND6_STATS (LWIP_IPV6) - -#define MIB2_STATS 0 - -#define LWIP_CHECKSUM_CTRL_PER_NETIF 0 - -#define CHECKSUM_GEN_IP 1 - -#define CHECKSUM_GEN_UDP 1 - -#define CHECKSUM_GEN_TCP 1 - -#define CHECKSUM_GEN_ICMP 1 - -#define CHECKSUM_GEN_ICMP6 1 - -#define CHECKSUM_CHECK_IP 1 -#define CHECKSUM_CHECK_UDP 1 - -#define CHECKSUM_CHECK_TCP 1 -#define CHECKSUM_CHECK_ICMP 1 -#define CHECKSUM_CHECK_ICMP6 1 -#define LWIP_CHECKSUM_ON_COPY 0 -#define LWIP_IPV6 0 -#define LWIP_IPV6_NUM_ADDRESSES 3 -#define LWIP_IPV6_FORWARD 0 -#define LWIP_IPV6_FRAG 0 -#define LWIP_IPV6_REASS (LWIP_IPV6) -#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1 -#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6) -#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1 -#define LWIP_ICMP6 (LWIP_IPV6) -#define LWIP_ICMP6_DATASIZE 8 -#define LWIP_ICMP6_HL 255 -#define LWIP_IPV6_MLD (LWIP_IPV6) -#define MEMP_NUM_MLD6_GROUP 4 -#define LWIP_ND6_QUEUEING (LWIP_IPV6) -#define MEMP_NUM_ND6_QUEUE 20 -#define LWIP_ND6_NUM_NEIGHBORS 10 -#define LWIP_ND6_NUM_DESTINATIONS 10 -#define LWIP_ND6_NUM_PREFIXES 5 -#define LWIP_ND6_NUM_ROUTERS 3 -#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3 -#define LWIP_ND6_MAX_UNICAST_SOLICIT 3 -#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000 -#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3 -#define LWIP_ND6_REACHABLE_TIME 30000 -#define LWIP_ND6_RETRANS_TIMER 1000 - -#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000 - -#define LWIP_ND6_ALLOW_RA_UPDATES 1 - -#define LWIP_ND6_TCP_REACHABILITY_HINTS 1 - -#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 - -#define LWIP_IPV6_DHCP6 0 - -//#define LWIP_HOOK_FILENAME "path/to/my/lwip_hooks.h" - -//#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port) - -//#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif) - -//#define LWIP_HOOK_IP4_ROUTE() - -//#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src) - -//#define LWIP_HOOK_ETHARP_GET_GW(netif, dest) - -//#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif) - -//#define LWIP_HOOK_IP6_ROUTE(src, dest) - -///#define LWIP_HOOK_ND6_GET_GW(netif, dest) - -//#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr) - -//#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type) - -//#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type) - -//#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) - -#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL -#define LWIP_DBG_TYPES_ON LWIP_DBG_ON - -#define ETHARP_DEBUG LWIP_DBG_OFF - -#define NETIF_DEBUG LWIP_DBG_OFF - -#define PBUF_DEBUG LWIP_DBG_OFF - -#define API_LIB_DEBUG LWIP_DBG_OFF - -#define API_MSG_DEBUG LWIP_DBG_OFF - -#define SOCKETS_DEBUG LWIP_DBG_OFF - -#define ICMP_DEBUG LWIP_DBG_OFF - -#define IGMP_DEBUG LWIP_DBG_OFF - -#define INET_DEBUG LWIP_DBG_OFF - -#define IP_DEBUG LWIP_DBG_ON - -#define IP_REASS_DEBUG LWIP_DBG_OFF - -#define RAW_DEBUG LWIP_DBG_OFF - -#define MEM_DEBUG LWIP_DBG_OFF - -#define MEMP_DEBUG LWIP_DBG_OFF - -#define SYS_DEBUG LWIP_DBG_OFF - -#define TIMERS_DEBUG LWIP_DBG_OFF - -#define TCP_DEBUG LWIP_DBG_OFF - -#define TCP_INPUT_DEBUG LWIP_DBG_OFF - -#define TCP_FR_DEBUG LWIP_DBG_OFF - -#define TCP_RTO_DEBUG LWIP_DBG_OFF - -#define TCP_CWND_DEBUG LWIP_DBG_OFF - -#define TCP_WND_DEBUG LWIP_DBG_OFF - -#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF - -#define TCP_RST_DEBUG LWIP_DBG_OFF - -#define TCP_QLEN_DEBUG LWIP_DBG_OFF - -#define UDP_DEBUG LWIP_DBG_OFF -#define TCPIP_DEBUG LWIP_DBG_OFF -#define SLIP_DEBUG LWIP_DBG_OFF -#define DHCP_DEBUG LWIP_DBG_OFF -#define AUTOIP_DEBUG LWIP_DBG_OFF -#define DNS_DEBUG LWIP_DBG_OFF -#define IP6_DEBUG LWIP_DBG_OFF -#define LWIP_PERF 0 - -//#define TCP_RCV_SCALE 0 -//#define PBUF_POOL_SIZE 400 /* pbuf tests need ~200KByte */ -#define LWIP_COMPAT_MUTEX 0 -#define LWIP_COMPAT_MUTEX_ALLOWED 1 -#define LWIP_TIMEVAL_PRIVATE 0 -#define LWIP_CALLBACK_API 1 -#define LWIP_PROVIDE_ERRNO 1 -#endif diff --git a/include/net/mem.h b/include/net/mem.h deleted file mode 100644 index f5360dd..0000000 --- a/include/net/mem.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @file - * Heap API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_MEM_H -#define LWIP_HDR_MEM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if MEM_LIBC_MALLOC - -#include - -typedef size_t mem_size_t; -#define MEM_SIZE_F SZT_F - -#elif MEM_USE_POOLS - -typedef u16_t mem_size_t; -#define MEM_SIZE_F U16_F - -#else - -/* MEM_SIZE would have to be aligned, but using 64000 here instead of - * 65535 leaves some room for alignment... - */ -#if MEM_SIZE > 64000L -typedef u32_t mem_size_t; -#define MEM_SIZE_F U32_F -#else -typedef u16_t mem_size_t; -#define MEM_SIZE_F U16_F -#endif /* MEM_SIZE > 64000 */ -#endif - -void mem_init(void); -void *mem_trim(void *mem, mem_size_t size); -void *mem_malloc(mem_size_t size); -void *mem_calloc(mem_size_t count, mem_size_t size); -void mem_free(void *mem); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_MEM_H */ diff --git a/include/net/memp.h b/include/net/memp.h deleted file mode 100644 index bae1b44..0000000 --- a/include/net/memp.h +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @file - * Memory pool API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef LWIP_HDR_MEMP_H -#define LWIP_HDR_MEMP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* run once with empty definition to handle all custom includes in lwippools.h */ -#define LWIP_MEMPOOL(name,num,size,desc) -#include - -/** Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ -typedef enum { -#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, -#include - MEMP_MAX -} memp_t; - -#include -#include - -extern const struct memp_desc* const memp_pools[MEMP_MAX]; - -/** - * @ingroup mempool - * Declare prototype for private memory pool if it is used in multiple files - */ -#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc memp_ ## name - -#if MEMP_MEM_MALLOC - -#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \ - LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \ - const struct memp_desc memp_ ## name = { \ - DECLARE_LWIP_MEMPOOL_DESC(desc) \ - LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \ - LWIP_MEM_ALIGN_SIZE(size) \ - }; - -#else /* MEMP_MEM_MALLOC */ - -/** - * @ingroup mempool - * Declare a private memory pool - * Private mempools example: - * .h: only when pool is used in multiple .c files: LWIP_MEMPOOL_PROTOTYPE(my_private_pool); - * .c: - * - in global variables section: LWIP_MEMPOOL_DECLARE(my_private_pool, 10, sizeof(foo), "Some description") - * - call ONCE before using pool (e.g. in some init() function): LWIP_MEMPOOL_INIT(my_private_pool); - * - allocate: void* my_new_mem = LWIP_MEMPOOL_ALLOC(my_private_pool); - * - free: LWIP_MEMPOOL_FREE(my_private_pool, my_new_mem); - * - * To relocate a pool, declare it as extern in cc.h. Example for GCC: - * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_my_private_pool[]; - */ -#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \ - LWIP_DECLARE_MEMORY_ALIGNED(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \ - \ - LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \ - \ - static struct memp *memp_tab_ ## name; \ - \ - const struct memp_desc memp_ ## name = { \ - DECLARE_LWIP_MEMPOOL_DESC(desc) \ - LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \ - LWIP_MEM_ALIGN_SIZE(size), \ - (num), \ - memp_memory_ ## name ## _base, \ - &memp_tab_ ## name \ - }; - -#endif /* MEMP_MEM_MALLOC */ - -/** - * @ingroup mempool - * Initialize a private memory pool - */ -#define LWIP_MEMPOOL_INIT(name) memp_init_pool(&memp_ ## name) -/** - * @ingroup mempool - * Allocate from a private memory pool - */ -#define LWIP_MEMPOOL_ALLOC(name) memp_malloc_pool(&memp_ ## name) -/** - * @ingroup mempool - * Free element from a private memory pool - */ -#define LWIP_MEMPOOL_FREE(name, x) memp_free_pool(&memp_ ## name, (x)) - -#if MEM_USE_POOLS -/** This structure is used to save the pool one element came from. - * This has to be defined here as it is required for pool size calculation. */ -struct memp_malloc_helper -{ - memp_t poolnr; -#if MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) - u16_t size; -#endif /* MEMP_OVERFLOW_CHECK || (LWIP_STATS && MEM_STATS) */ -}; -#endif /* MEM_USE_POOLS */ - -void memp_init(void); - -#if MEMP_OVERFLOW_CHECK -void *memp_malloc_fn(memp_t type, const char* file, const int line); -#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) -#else -void *memp_malloc(memp_t type); -#endif -void memp_free(memp_t type, void *mem); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_MEMP_H */ diff --git a/include/net/mld6.h b/include/net/mld6.h deleted file mode 100644 index 2c5c12a..0000000 --- a/include/net/mld6.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file - * - * Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710. - * No support for MLDv2. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_MLD6_H -#define LWIP_HDR_MLD6_H - -#include "net/opt.h" - -#if LWIP_IPV6_MLD && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** MLD group */ -struct mld_group { - /** next link */ - struct mld_group *next; - /** multicast address */ - ip6_addr_t group_address; - /** signifies we were the last person to report */ - u8_t last_reporter_flag; - /** current state of the group */ - u8_t group_state; - /** timer for reporting */ - u16_t timer; - /** counter of simultaneous uses */ - u8_t use; -}; - -#define MLD6_TMR_INTERVAL 100 /* Milliseconds */ - -err_t mld6_stop(struct netif *netif); -void mld6_report_groups(struct netif *netif); -void mld6_tmr(void); -struct mld_group *mld6_lookfor_group(struct netif *ifp, const ip6_addr_t *addr); -void mld6_input(struct pbuf *p, struct netif *inp); -err_t mld6_joingroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); -err_t mld6_joingroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); -err_t mld6_leavegroup(const ip6_addr_t *srcaddr, const ip6_addr_t *groupaddr); -err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); - -/** @ingroup mld6 - * Get list head of MLD6 groups for netif. - * Note: The allnodes group IP is NOT in the list, since it must always - * be received for correct IPv6 operation. - * @see @ref netif_set_mld_mac_filter() - */ -#define netif_mld6_data(netif) ((struct mld_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_MLD6)) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6_MLD && LWIP_IPV6 */ - -#endif /* LWIP_HDR_MLD6_H */ diff --git a/include/net/nd6.h b/include/net/nd6.h deleted file mode 100644 index f0dfca9..0000000 --- a/include/net/nd6.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file - * - * Neighbor discovery and stateless address autoconfiguration for IPv6. - * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 - * (Address autoconfiguration). - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_ND6_H -#define LWIP_HDR_ND6_H - -#include "net/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "net/ip6_addr.h" -#include "net/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** 1 second period */ -#define ND6_TMR_INTERVAL 1000 - -struct pbuf; -struct netif; - -void nd6_tmr(void); -void nd6_input(struct pbuf *p, struct netif *inp); -void nd6_clear_destination_cache(void); -struct netif *nd6_find_route(const ip6_addr_t *ip6addr); -err_t nd6_get_next_hop_addr_or_queue(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr, const u8_t **hwaddrp); -u16_t nd6_get_destination_mtu(const ip6_addr_t *ip6addr, struct netif *netif); -#if LWIP_ND6_TCP_REACHABILITY_HINTS -void nd6_reachability_hint(const ip6_addr_t *ip6addr); -#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ -void nd6_cleanup_netif(struct netif *netif); -#if LWIP_IPV6_MLD -void nd6_adjust_mld_membership(struct netif *netif, s8_t addr_idx, u8_t new_state); -#endif /* LWIP_IPV6_MLD */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* LWIP_HDR_ND6_H */ diff --git a/include/net/net.h b/include/net/net.h deleted file mode 100644 index 47308a6..0000000 --- a/include/net/net.h +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************************** - Copyright (c) 2002 The UbixOS Project - All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions, the following disclaimer and the list of authors. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions, the following disclaimer and the list of authors -in the documentation and/or other materials provided with the distribution. Neither the name of the UbixOS Project nor the names of its -contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id: net.h 79 2016-01-11 16:21:27Z reddawg $ - -**************************************************************************************/ - -#ifndef _NET_H -#define _NET_H - -#include -#include - -extern struct netif lnc_netif; - -int net_init(); - -#endif diff --git a/include/net/netbuf.h b/include/net/netbuf.h deleted file mode 100644 index c75bfa7..0000000 --- a/include/net/netbuf.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file - * netbuf API (for netconn API) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_NETBUF_H -#define LWIP_HDR_NETBUF_H - -#include "net/opt.h" - -#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ -/* Note: Netconn API is always available when sockets are enabled - - * sockets are implemented on top of them */ - -#include "net/pbuf.h" -#include "net/ip_addr.h" -#include "net/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** This netbuf has dest-addr/port set */ -#define NETBUF_FLAG_DESTADDR 0x01 -/** This netbuf includes a checksum */ -#define NETBUF_FLAG_CHKSUM 0x02 - -/** "Network buffer" - contains data and addressing info */ -struct netbuf { - struct pbuf *p, *ptr; - ip_addr_t addr; - u16_t port; -#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY -#if LWIP_CHECKSUM_ON_COPY - u8_t flags; -#endif /* LWIP_CHECKSUM_ON_COPY */ - u16_t toport_chksum; -#if LWIP_NETBUF_RECVINFO - ip_addr_t toaddr; -#endif /* LWIP_NETBUF_RECVINFO */ -#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ -}; - -/* Network buffer functions: */ -struct netbuf * netbuf_new (void); -void netbuf_delete (struct netbuf *buf); -void * netbuf_alloc (struct netbuf *buf, u16_t size); -void netbuf_free (struct netbuf *buf); -err_t netbuf_ref (struct netbuf *buf, - const void *dataptr, u16_t size); -void netbuf_chain (struct netbuf *head, struct netbuf *tail); - -err_t netbuf_data (struct netbuf *buf, - void **dataptr, u16_t *len); -s8_t netbuf_next (struct netbuf *buf); -void netbuf_first (struct netbuf *buf); - - -#define netbuf_copy_partial(buf, dataptr, len, offset) \ - pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) -#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) -#define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) -#define netbuf_len(buf) ((buf)->p->tot_len) -#define netbuf_fromaddr(buf) (&((buf)->addr)) -#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set(&((buf)->addr), fromaddr) -#define netbuf_fromport(buf) ((buf)->port) -#if LWIP_NETBUF_RECVINFO -#define netbuf_destaddr(buf) (&((buf)->toaddr)) -#define netbuf_set_destaddr(buf, destaddr) ip_addr_set(&((buf)->toaddr), destaddr) -#if LWIP_CHECKSUM_ON_COPY -#define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) -#else /* LWIP_CHECKSUM_ON_COPY */ -#define netbuf_destport(buf) ((buf)->toport_chksum) -#endif /* LWIP_CHECKSUM_ON_COPY */ -#endif /* LWIP_NETBUF_RECVINFO */ -#if LWIP_CHECKSUM_ON_COPY -#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ - (buf)->toport_chksum = chksum; } while(0) -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN || LWIP_SOCKET */ - -#endif /* LWIP_HDR_NETBUF_H */ diff --git a/include/net/netdb.h b/include/net/netdb.h deleted file mode 100644 index b9b919a..0000000 --- a/include/net/netdb.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @file - * NETDB API (sockets) - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_NETDB_H -#define LWIP_HDR_NETDB_H - -#include "net/opt.h" - -#if LWIP_DNS && LWIP_SOCKET - -#include "net/arch.h" -#include "net/inet.h" -#include "net/sockets.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* some rarely used options */ -#ifndef LWIP_DNS_API_DECLARE_H_ERRNO -#define LWIP_DNS_API_DECLARE_H_ERRNO 1 -#endif - -#ifndef LWIP_DNS_API_DEFINE_ERRORS -#define LWIP_DNS_API_DEFINE_ERRORS 1 -#endif - -#ifndef LWIP_DNS_API_DEFINE_FLAGS -#define LWIP_DNS_API_DEFINE_FLAGS 1 -#endif - -#ifndef LWIP_DNS_API_DECLARE_STRUCTS -#define LWIP_DNS_API_DECLARE_STRUCTS 1 -#endif - -#if LWIP_DNS_API_DEFINE_ERRORS -/** Errors used by the DNS API functions, h_errno can be one of them */ -#define EAI_NONAME 200 -#define EAI_SERVICE 201 -#define EAI_FAIL 202 -#define EAI_MEMORY 203 -#define EAI_FAMILY 204 - -#define HOST_NOT_FOUND 210 -#define NO_DATA 211 -#define NO_RECOVERY 212 -#define TRY_AGAIN 213 -#endif /* LWIP_DNS_API_DEFINE_ERRORS */ - -#if LWIP_DNS_API_DEFINE_FLAGS -/* input flags for struct addrinfo */ -#define AI_PASSIVE 0x01 -#define AI_CANONNAME 0x02 -#define AI_NUMERICHOST 0x04 -#define AI_NUMERICSERV 0x08 -#define AI_V4MAPPED 0x10 -#define AI_ALL 0x20 -#define AI_ADDRCONFIG 0x40 -#endif /* LWIP_DNS_API_DEFINE_FLAGS */ - -#if LWIP_DNS_API_DECLARE_STRUCTS -struct hostent { - char *h_name; /* Official name of the host. */ - char **h_aliases; /* A pointer to an array of pointers to alternative host names, - terminated by a null pointer. */ - int h_addrtype; /* Address type. */ - int h_length; /* The length, in bytes, of the address. */ - char **h_addr_list; /* A pointer to an array of pointers to network addresses (in - network byte order) for the host, terminated by a null pointer. */ -#define h_addr h_addr_list[0] /* for backward compatibility */ -}; - -struct addrinfo { - int ai_flags; /* Input flags. */ - int ai_family; /* Address family of socket. */ - int ai_socktype; /* Socket type. */ - int ai_protocol; /* Protocol of socket. */ - socklen_t ai_addrlen; /* Length of socket address. */ - struct sockaddr *ai_addr; /* Socket address of socket. */ - char *ai_canonname; /* Canonical name of service location. */ - struct addrinfo *ai_next; /* Pointer to next in list. */ -}; -#endif /* LWIP_DNS_API_DECLARE_STRUCTS */ - -#define NETDB_ELEM_SIZE (sizeof(struct addrinfo) + sizeof(struct sockaddr_storage) + DNS_MAX_NAME_LENGTH + 1) - -#if LWIP_DNS_API_DECLARE_H_ERRNO -/* application accessible error code set by the DNS API functions */ -extern int h_errno; -#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/ - -struct hostent *lwip_gethostbyname(const char *name); -int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, - size_t buflen, struct hostent **result, int *h_errnop); -void lwip_freeaddrinfo(struct addrinfo *ai); -int lwip_getaddrinfo(const char *nodename, - const char *servname, - const struct addrinfo *hints, - struct addrinfo **res); - -#if LWIP_COMPAT_SOCKETS -/** @ingroup netdbapi */ -#define gethostbyname(name) lwip_gethostbyname(name) -/** @ingroup netdbapi */ -#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \ - lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop) -/** @ingroup netdbapi */ -#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo) -/** @ingroup netdbapi */ -#define getaddrinfo(nodname, servname, hints, res) \ - lwip_getaddrinfo(nodname, servname, hints, res) -#endif /* LWIP_COMPAT_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DNS && LWIP_SOCKET */ - -#endif /* LWIP_HDR_NETDB_H */ diff --git a/include/net/netif.h b/include/net/netif.h deleted file mode 100644 index 1b30d2e..0000000 --- a/include/net/netif.h +++ /dev/null @@ -1,485 +0,0 @@ -/** - * @file - * netif API (to be used from TCPIP thread) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_NETIF_H -#define LWIP_HDR_NETIF_H - -#include - -#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) - -#include - -#include - -#include -#include -#include - -struct nicBuffer { - struct nicBuffer *next; - int length; - char *buffer; -}; - -extern struct nicBuffer *tmpBuf; - -#ifdef __cplusplus -extern "C" { -#endif - -/* Throughout this file, IP addresses are expected to be in - * the same byte order as in IP_PCB. */ - -/** Must be the maximum of all used hardware address lengths - across all types of interfaces in use. - This does not have to be changed, normally. */ -#ifndef NETIF_MAX_HWADDR_LEN -#define NETIF_MAX_HWADDR_LEN 6U -#endif - -/** - * @defgroup netif_flags Flags - * @ingroup netif - * @{ - */ - -/** Whether the network interface is 'up'. This is - * a software flag used to control whether this network - * interface is enabled and processes traffic. - * It must be set by the startup code before this netif can be used - * (also for dhcp/autoip). - */ -#define NETIF_FLAG_UP 0x01U -/** If set, the netif has broadcast capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_BROADCAST 0x02U -/** If set, the interface has an active link - * (set by the network interface driver). - * Either set by the netif driver in its init function (if the link - * is up at that time) or at a later point once the link comes up - * (if link detection is supported by the hardware). */ -#define NETIF_FLAG_LINK_UP 0x04U -/** If set, the netif is an ethernet device using ARP. - * Set by the netif driver in its init function. - * Used to check input packet types and use of DHCP. */ -#define NETIF_FLAG_ETHARP 0x08U -/** If set, the netif is an ethernet device. It might not use - * ARP or TCP/IP if it is used for PPPoE only. - */ -#define NETIF_FLAG_ETHERNET 0x10U -/** If set, the netif has IGMP capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_IGMP 0x20U -/** If set, the netif has MLD6 capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_MLD6 0x40U - -/** - * @} - */ - -enum lwip_internal_netif_client_data_index -{ -#if LWIP_DHCP - LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, -#endif -#if LWIP_AUTOIP - LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, -#endif -#if LWIP_IGMP - LWIP_NETIF_CLIENT_DATA_INDEX_IGMP, -#endif -#if LWIP_IPV6_MLD - LWIP_NETIF_CLIENT_DATA_INDEX_MLD6, -#endif - LWIP_NETIF_CLIENT_DATA_INDEX_MAX -}; - -#if LWIP_CHECKSUM_CTRL_PER_NETIF -#define NETIF_CHECKSUM_GEN_IP 0x0001 -#define NETIF_CHECKSUM_GEN_UDP 0x0002 -#define NETIF_CHECKSUM_GEN_TCP 0x0004 -#define NETIF_CHECKSUM_GEN_ICMP 0x0008 -#define NETIF_CHECKSUM_GEN_ICMP6 0x0010 -#define NETIF_CHECKSUM_CHECK_IP 0x0100 -#define NETIF_CHECKSUM_CHECK_UDP 0x0200 -#define NETIF_CHECKSUM_CHECK_TCP 0x0400 -#define NETIF_CHECKSUM_CHECK_ICMP 0x0800 -#define NETIF_CHECKSUM_CHECK_ICMP6 0x1000 -#define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF -#define NETIF_CHECKSUM_DISABLE_ALL 0x0000 -#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ - -struct netif; - -/** MAC Filter Actions, these are passed to a netif's igmp_mac_filter or - * mld_mac_filter callback function. */ -enum netif_mac_filter_action { - /** Delete a filter entry */ - NETIF_DEL_MAC_FILTER = 0, - /** Add a filter entry */ - NETIF_ADD_MAC_FILTER = 1 -}; - -/** Function prototype for netif init functions. Set up flags and output/linkoutput - * callback functions in this function. - * - * @param netif The netif to initialize - */ -typedef err_t (*netif_init_fn)(struct netif *netif); -/** Function prototype for netif->input functions. This function is saved as 'input' - * callback function in the netif struct. Call it when a packet has been received. - * - * @param p The received packet, copied into a pbuf - * @param inp The netif which received the packet - */ -typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); - -#if LWIP_IPV4 -/** Function prototype for netif->output functions. Called by lwIP when a packet - * shall be sent. For ethernet netif, set this to 'etharp_output' and set - * 'linkoutput'. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (p->payload points to IP header) - * @param ipaddr The IP address to which the packet shall be sent - */ -typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, - const ip4_addr_t *ipaddr); -#endif /* LWIP_IPV4*/ - -#if LWIP_IPV6 -/** Function prototype for netif->output_ip6 functions. Called by lwIP when a packet - * shall be sent. For ethernet netif, set this to 'ethip6_output' and set - * 'linkoutput'. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (p->payload points to IP header) - * @param ipaddr The IPv6 address to which the packet shall be sent - */ -typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p, - const ip6_addr_t *ipaddr); -#endif /* LWIP_IPV6 */ - -/** Function prototype for netif->linkoutput functions. Only used for ethernet - * netifs. This function is called by ARP when a packet shall be sent. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (raw ethernet packet) - */ -typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); -/** Function prototype for netif status- or link-callback functions. */ -typedef void (*netif_status_callback_fn)(struct netif *netif); -#if LWIP_IPV4 && LWIP_IGMP -/** Function prototype for netif igmp_mac_filter functions */ -typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, - const ip4_addr_t *group, enum netif_mac_filter_action action); -#endif /* LWIP_IPV4 && LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD -/** Function prototype for netif mld_mac_filter functions */ -typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif, - const ip6_addr_t *group, enum netif_mac_filter_action action); -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - -#if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || (LWIP_NUM_NETIF_CLIENT_DATA > 0) -u8_t netif_alloc_client_data_id(void); -/** @ingroup netif_cd - * Set client data. Obtain ID from netif_alloc_client_data_id(). - */ -#define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data) -/** @ingroup netif_cd - * Get client data. Obtain ID from netif_alloc_client_data_id(). - */ -#define netif_get_client_data(netif, id) (netif)->client_data[(id)] -#endif /* LWIP_DHCP || LWIP_AUTOIP || (LWIP_NUM_NETIF_CLIENT_DATA > 0) */ - -/** Generic data structure used for all lwIP network interfaces. - * The following fields should be filled in by the initialization - * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ -struct netif { - /** pointer to next in linked list */ - struct netif *next; - -#if LWIP_IPV4 - /** IP address configuration in network byte order */ - ip_addr_t ip_addr; - ip_addr_t netmask; - ip_addr_t gw; -#endif /* LWIP_IPV4 */ -#if LWIP_IPV6 - /** Array of IPv6 addresses for this netif. */ - ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES]; - /** The state of each IPv6 address (Tentative, Preferred, etc). - * @see ip6_addr.h */ - u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES]; -#endif /* LWIP_IPV6 */ - /** This function is called by the network device driver - * to pass a packet up the TCP/IP stack. */ - netif_input_fn input; -#if LWIP_IPV4 - /** This function is called by the IP module when it wants - * to send a packet on the interface. This function typically - * first resolves the hardware address, then sends the packet. - * For ethernet physical layer, this is usually etharp_output() */ - netif_output_fn output; -#endif /* LWIP_IPV4 */ - /** This function is called by ethernet_output() when it wants - * to send a packet on the interface. This function outputs - * the pbuf as-is on the link medium. */ - netif_linkoutput_fn linkoutput; -#if LWIP_IPV6 - /** This function is called by the IPv6 module when it wants - * to send a packet on the interface. This function typically - * first resolves the hardware address, then sends the packet. - * For ethernet physical layer, this is usually ethip6_output() */ - netif_output_ip6_fn output_ip6; -#endif /* LWIP_IPV6 */ -#if LWIP_NETIF_STATUS_CALLBACK - /** This function is called when the netif state is set to up or down - */ - netif_status_callback_fn status_callback; -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_LINK_CALLBACK - /** This function is called when the netif link is set to up or down - */ - netif_status_callback_fn link_callback; -#endif /* LWIP_NETIF_LINK_CALLBACK */ -#if LWIP_NETIF_REMOVE_CALLBACK - /** This function is called when the netif has been removed */ - netif_status_callback_fn remove_callback; -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - /** This field can be set by the device driver and could point - * to state information for the device. */ - void *state; -#ifdef netif_get_client_data - void* client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA]; -#endif -#if LWIP_IPV6_AUTOCONFIG - /** is this netif enabled for IPv6 autoconfiguration */ - u8_t ip6_autoconfig_enabled; -#endif /* LWIP_IPV6_AUTOCONFIG */ -#if LWIP_IPV6_SEND_ROUTER_SOLICIT - /** Number of Router Solicitation messages that remain to be sent. */ - u8_t rs_count; -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ -#if LWIP_NETIF_HOSTNAME - /* the hostname for this netif, NULL is a valid value */ - const char* hostname; -#endif /* LWIP_NETIF_HOSTNAME */ -#if LWIP_CHECKSUM_CTRL_PER_NETIF - u16_t chksum_flags; -#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF*/ - /** maximum transfer unit (in bytes) */ - u16_t mtu; - /** number of bytes used in hwaddr */ - u8_t hwaddr_len; - /** link level hardware address of this interface */ - u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; - /** flags (@see @ref netif_flags) */ - u8_t flags; - /** descriptive abbreviation */ - char name[2]; - /** number of this interface */ - u8_t num; -#if MIB2_STATS - /** link type (from "snmp_ifType" enum from snmp_mib2.h) */ - u8_t link_type; - /** (estimate) link speed */ - u32_t link_speed; - /** timestamp at last change made (up/down) */ - u32_t ts; - /** counters */ - struct stats_mib2_netif_ctrs mib2_counters; -#endif /* MIB2_STATS */ -#if LWIP_IPV4 && LWIP_IGMP - /** This function could be called to add or delete an entry in the multicast - filter table of the ethernet MAC.*/ - netif_igmp_mac_filter_fn igmp_mac_filter; -#endif /* LWIP_IPV4 && LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD - /** This function could be called to add or delete an entry in the IPv6 multicast - filter table of the ethernet MAC. */ - netif_mld_mac_filter_fn mld_mac_filter; -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ -#if LWIP_NETIF_HWADDRHINT - u8_t *addr_hint; -#endif /* LWIP_NETIF_HWADDRHINT */ -#if ENABLE_LOOPBACK - /* List of packets to be queued for ourselves. */ - struct pbuf *loop_first; - struct pbuf *loop_last; -#if LWIP_LOOPBACK_MAX_PBUFS - u16_t loop_cnt_current; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ -#endif /* ENABLE_LOOPBACK */ -}; - -#if LWIP_CHECKSUM_CTRL_PER_NETIF -#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \ - (netif)->chksum_flags = chksumflags; } while(0) -#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0)) -#else /* LWIP_CHECKSUM_CTRL_PER_NETIF */ -#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) -#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) -#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */ - -/** The list of network interfaces. */ -extern struct netif *netif_list; -/** The default network interface. */ -extern struct netif *netif_default; - -void netif_init(void); - -struct netif *netif_add(struct netif *netif, -#if LWIP_IPV4 - const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw, -#endif /* LWIP_IPV4 */ - void *state, netif_init_fn init, netif_input_fn input); -#if LWIP_IPV4 -void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, - const ip4_addr_t *gw); -#endif /* LWIP_IPV4 */ -void netif_remove(struct netif * netif); - -/* Returns a network interface given its name. The name is of the form - "et0", where the first two letters are the "name" field in the - netif structure, and the digit is in the num field in the same - structure. */ -struct netif *netif_find(const char *name); - -void netif_set_default(struct netif *netif); - -#if LWIP_IPV4 -void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr); -void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask); -void netif_set_gw(struct netif *netif, const ip4_addr_t *gw); -/** @ingroup netif_ip4 */ -#define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr))) -/** @ingroup netif_ip4 */ -#define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask))) -/** @ingroup netif_ip4 */ -#define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw))) -/** @ingroup netif_ip4 */ -#define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr)) -/** @ingroup netif_ip4 */ -#define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask)) -/** @ingroup netif_ip4 */ -#define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw)) -#endif /* LWIP_IPV4 */ - -void netif_set_up(struct netif *netif); -void netif_set_down(struct netif *netif); -/** @ingroup netif - * Ask if an interface is up - */ -#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) - -#if LWIP_NETIF_STATUS_CALLBACK -void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_REMOVE_CALLBACK -void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - -void netif_set_link_up(struct netif *netif); -void netif_set_link_down(struct netif *netif); -/** Ask if a link is up */ -#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) - -#if LWIP_NETIF_LINK_CALLBACK -void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#if LWIP_NETIF_HOSTNAME -/** @ingroup netif */ -#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) -/** @ingroup netif */ -#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) -#endif /* LWIP_NETIF_HOSTNAME */ - -#if LWIP_IGMP -/** @ingroup netif */ -#define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) -#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) -#endif /* LWIP_IGMP */ - -#if LWIP_IPV6 && LWIP_IPV6_MLD -/** @ingroup netif */ -#define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0) -#define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL) -#define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0) -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - -#if ENABLE_LOOPBACK -err_t netif_loop_output(struct netif *netif, struct pbuf *p); -void netif_poll(struct netif *netif); -#if !LWIP_NETIF_LOOPBACK_MULTITHREADING -void netif_poll_all(void); -#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ - -err_t netif_input(struct pbuf *p, struct netif *inp); - -#if LWIP_IPV6 -/** @ingroup netif_ip6 */ -#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i]))) -/** @ingroup netif_ip6 */ -#define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i]))) -void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6); -void netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3); -#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i]) -void netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state); -s8_t netif_get_ip6_addr_match(struct netif *netif, const ip6_addr_t *ip6addr); -void netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit); -err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx); -#define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0) -#endif /* LWIP_IPV6 */ - -#if LWIP_NETIF_HWADDRHINT -#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) -#else /* LWIP_NETIF_HWADDRHINT */ -#define NETIF_SET_HWADDRHINT(netif, hint) -#endif /* LWIP_NETIF_HWADDRHINT */ - -#ifdef __cplusplus -} -#endif - -/*MrOlsen 2017-12-17 LWIP */ -void ethernetif_input(struct netif *); - -#endif /* LWIP_HDR_NETIF_H */ diff --git a/include/net/netifapi.h b/include/net/netifapi.h deleted file mode 100644 index 82cb80e..0000000 --- a/include/net/netifapi.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file - * netif API (to be used from non-TCPIP threads) - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ -#ifndef LWIP_HDR_NETIFAPI_H -#define LWIP_HDR_NETIFAPI_H - -#include "net/opt.h" - -#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ - -#include "net/sys.h" -#include "net/netif.h" -#include "net/dhcp.h" -#include "net/autoip.h" -#include "net/priv/tcpip_priv.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_MPU_COMPATIBLE -#define NETIFAPI_IPADDR_DEF(type, m) type m -#else /* LWIP_MPU_COMPATIBLE */ -#define NETIFAPI_IPADDR_DEF(type, m) const type * m -#endif /* LWIP_MPU_COMPATIBLE */ - -typedef void (*netifapi_void_fn)(struct netif *netif); -typedef err_t (*netifapi_errt_fn)(struct netif *netif); - -struct netifapi_msg { - struct tcpip_api_call_data call; - struct netif *netif; - union { - struct { -#if LWIP_IPV4 - NETIFAPI_IPADDR_DEF(ip4_addr_t, ipaddr); - NETIFAPI_IPADDR_DEF(ip4_addr_t, netmask); - NETIFAPI_IPADDR_DEF(ip4_addr_t, gw); -#endif /* LWIP_IPV4 */ - void *state; - netif_init_fn init; - netif_input_fn input; - } add; - struct { - netifapi_void_fn voidfunc; - netifapi_errt_fn errtfunc; - } common; - } msg; -}; - - -/* API for application */ -err_t netifapi_netif_add(struct netif *netif, -#if LWIP_IPV4 - const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw, -#endif /* LWIP_IPV4 */ - void *state, netif_init_fn init, netif_input_fn input); - -#if LWIP_IPV4 -err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, - const ip4_addr_t *netmask, const ip4_addr_t *gw); -#endif /* LWIP_IPV4*/ - -err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc, - netifapi_errt_fn errtfunc); - -/** @ingroup netifapi_netif */ -#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) -/** @ingroup netifapi_netif */ -#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) -/** @ingroup netifapi_netif */ -#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) -/** @ingroup netifapi_netif */ -#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) -/** @ingroup netifapi_netif */ -#define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL) -/** @ingroup netifapi_netif */ -#define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL) - -/** - * @defgroup netifapi_dhcp4 DHCPv4 - * @ingroup netifapi - * To be called from non-TCPIP threads - */ -/** @ingroup netifapi_dhcp4 */ -#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) -/** @ingroup netifapi_dhcp4 */ -#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) -/** @ingroup netifapi_dhcp4 */ -#define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL) -/** @ingroup netifapi_dhcp4 */ -#define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew) -/** @ingroup netifapi_dhcp4 */ -#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release) - -/** - * @defgroup netifapi_autoip AUTOIP - * @ingroup netifapi - * To be called from non-TCPIP threads - */ -/** @ingroup netifapi_autoip */ -#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) -/** @ingroup netifapi_autoip */ -#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETIF_API */ - -#endif /* LWIP_HDR_NETIFAPI_H */ diff --git a/include/net/opt.h b/include/net/opt.h deleted file mode 100644 index 4dbf656..0000000 --- a/include/net/opt.h +++ /dev/null @@ -1,2837 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -/* - * NOTE: || defined __DOXYGEN__ is a workaround for doxygen bug - - * without this, doxygen does not see the actual #define - */ - -#if !defined LWIP_HDR_OPT_H -#define LWIP_HDR_OPT_H - -#include - -/* - * Include user defined options first. Anything not defined in these files - * will be set to standard values. Override anything you don't like! - */ -#include -#include - -/** - * @defgroup lwip_opts Options (lwipopts.h) - * @ingroup lwip - * - * @defgroup lwip_opts_debug Debugging - * @ingroup lwip_opts - * - * @defgroup lwip_opts_infrastructure Infrastructure - * @ingroup lwip_opts - * - * @defgroup lwip_opts_callback Callback-style APIs - * @ingroup lwip_opts - * - * @defgroup lwip_opts_threadsafe_apis Thread-safe APIs - * @ingroup lwip_opts - */ - -/** - * NO_SYS==1: Use lwIP without OS-awareness (no thread, semaphores, mutexes or - * mboxes). This means threaded APIs cannot be used (socket, netconn, - * i.e. everything in the 'api' folder), only the callback-style raw API is - * available (and you have to watch out for yourself that you don't access - * lwIP functions/structures from more than one context at a time!) - */ -#if !defined NO_SYS -#define NO_SYS 0 -#endif - -/** - * LWIP_TIMERS==0: Drop support for sys_timeout and lwip-internal cyclic timers. - * (the array of lwip-internal cyclic timers is still provided) - * (check NO_SYS_NO_TIMERS for compatibility to old versions) - */ -#if !defined LWIP_TIMERS -#ifdef NO_SYS_NO_TIMERS -#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) -#else -#define LWIP_TIMERS 1 -#endif -#endif - -/** - * LWIP_TIMERS_CUSTOM==1: Provide your own timer implementation. - * Function prototypes in timeouts.h and the array of lwip-internal cyclic timers - * are still included, but the implementation is not. The following functions - * will be required: sys_timeouts_init(), sys_timeout(), sys_untimeout(), - * sys_timeouts_mbox_fetch() - */ -#if !defined LWIP_TIMERS_CUSTOM -#define LWIP_TIMERS_CUSTOM 0 -#endif - -/** - * MEMCPY: override this if you have a faster implementation at hand than the - * one included in your C library - */ -#if !defined MEMCPY -#define MEMCPY(dst,src,len) memcpy(dst,src,len) -#endif - -/** - * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a - * call to memcpy() if the length is known at compile time and is small. - */ -#if !defined SMEMCPY -#define SMEMCPY(dst,src,len) memcpy(dst,src,len) -#endif - -/* - ------------------------------------ - ----------- Core locking ----------- - ------------------------------------ - */ -/** - * LWIP_MPU_COMPATIBLE: enables special memory management mechanism - * which makes lwip able to work on MPU (Memory Protection Unit) system - * by not passing stack-pointers to other threads - * (this decreases performance as memory is allocated from pools instead - * of keeping it on the stack) - */ -#if !defined LWIP_MPU_COMPATIBLE -#define LWIP_MPU_COMPATIBLE 0 -#endif - -/** - * LWIP_TCPIP_CORE_LOCKING - * Creates a global mutex that is held during TCPIP thread operations. - * Can be locked by client code to perform lwIP operations without changing - * into TCPIP thread using callbacks. See LOCK_TCPIP_CORE() and - * UNLOCK_TCPIP_CORE(). - * Your system should provide mutexes supporting priority inversion to use this. - */ -#if !defined LWIP_TCPIP_CORE_LOCKING -#define LWIP_TCPIP_CORE_LOCKING 1 -#endif - -/** - * LWIP_TCPIP_CORE_LOCKING_INPUT: when LWIP_TCPIP_CORE_LOCKING is enabled, - * this lets tcpip_input() grab the mutex for input packets as well, - * instead of allocating a message and passing it to tcpip_thread. - * - * ATTENTION: this does not work when tcpip_input() is called from - * interrupt context! - */ -#if !defined LWIP_TCPIP_CORE_LOCKING_INPUT || defined __DOXYGEN__ -#define LWIP_TCPIP_CORE_LOCKING_INPUT 0 -#endif - -/** - * SYS_LIGHTWEIGHT_PROT==1: enable inter-task protection (and task-vs-interrupt - * protection) for certain critical regions during buffer allocation, deallocation - * and memory allocation and deallocation. - * ATTENTION: This is required when using lwIP from more than one context! If - * you disable this, you must be sure what you are doing! - */ -#if !defined SYS_LIGHTWEIGHT_PROT || defined __DOXYGEN__ -#define SYS_LIGHTWEIGHT_PROT 1 -#endif -/** - * @} - */ - -/* - ------------------------------------ - ---------- Memory options ---------- - ------------------------------------ - */ -/** - * @defgroup lwip_opts_mem Heap and memory pools - * @ingroup lwip_opts_infrastructure - * @{ - */ -/** - * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library - * instead of the lwip internal allocator. Can save code size if you - * already use it. - */ -#if !defined MEM_LIBC_MALLOC || defined __DOXYGEN__ -#define MEM_LIBC_MALLOC 0 -#endif - -/** - * MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. - * Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution - * speed (heap alloc can be much slower than pool alloc) and usage from interrupts - * (especially if your netif driver allocates PBUF_POOL pbufs for received frames - * from interrupt)! - * ATTENTION: Currently, this uses the heap for ALL pools (also for private pools, - * not only for internal pools defined in memp_std.h)! - */ -#if !defined MEMP_MEM_MALLOC || defined __DOXYGEN__ -#define MEMP_MEM_MALLOC 0 -#endif - -/** - * MEM_ALIGNMENT: should be set to the alignment of the CPU - * 4 byte alignment -> \#define MEM_ALIGNMENT 4 - * 2 byte alignment -> \#define MEM_ALIGNMENT 2 - */ -#if !defined MEM_ALIGNMENT || defined __DOXYGEN__ -#define MEM_ALIGNMENT 1 -#endif - -/** - * MEM_SIZE: the size of the heap memory. If the application will send - * a lot of data that needs to be copied, this should be set high. - */ -#if !defined MEM_SIZE || defined __DOXYGEN__ -#define MEM_SIZE 1600 -#endif - -/** - * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable - * amount of bytes before and after each memp element in every pool and fills - * it with a prominent default value. - * MEMP_OVERFLOW_CHECK == 0 no checking - * MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed - * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time - * memp_malloc() or memp_free() is called (useful but slow!) - */ -#if !defined MEMP_OVERFLOW_CHECK || defined __DOXYGEN__ -#define MEMP_OVERFLOW_CHECK 0 -#endif - -/** - * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make - * sure that there are no cycles in the linked lists. - */ -#if !defined MEMP_SANITY_CHECK || defined __DOXYGEN__ -#define MEMP_SANITY_CHECK 0 -#endif - -/** - * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set - * of memory pools of various sizes. When mem_malloc is called, an element of - * the smallest pool that can provide the length needed is returned. - * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled. - */ -#if !defined MEM_USE_POOLS || defined __DOXYGEN__ -#define MEM_USE_POOLS 0 -#endif - -/** - * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next - * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more - * reliable. */ -#if !defined MEM_USE_POOLS_TRY_BIGGER_POOL || defined __DOXYGEN__ -#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 -#endif - -/** - * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h - * that defines additional pools beyond the "standard" ones required - * by lwIP. If you set this to 1, you must have lwippools.h in your - * include path somewhere. - */ -#if !defined MEMP_USE_CUSTOM_POOLS || defined __DOXYGEN__ -#define MEMP_USE_CUSTOM_POOLS 0 -#endif - -/** - * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from - * interrupt context (or another context that doesn't allow waiting for a - * semaphore). - * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, - * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs - * with each loop so that mem_free can run. - * - * ATTENTION: As you can see from the above description, this leads to dis-/ - * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc - * can need longer. - * - * If you don't want that, at least for NO_SYS=0, you can still use the following - * functions to enqueue a deallocation call which then runs in the tcpip_thread - * context: - * - pbuf_free_callback(p); - * - mem_free_callback(m); - */ -#if !defined LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT || defined __DOXYGEN__ -#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 -#endif -/** - * @} - */ - -/* - ------------------------------------------------ - ---------- Internal Memory Pool Sizes ---------- - ------------------------------------------------ - */ -/** - * @defgroup lwip_opts_memp Internal memory pools - * @ingroup lwip_opts_infrastructure - * @{ - */ -/** - * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). - * If the application sends a lot of data out of ROM (or other static memory), - * this should be set high. - */ -#if !defined MEMP_NUM_PBUF || defined __DOXYGEN__ -#define MEMP_NUM_PBUF 16 -#endif - -/** - * MEMP_NUM_RAW_PCB: Number of raw connection PCBs - * (requires the LWIP_RAW option) - */ -#if !defined MEMP_NUM_RAW_PCB || defined __DOXYGEN__ -#define MEMP_NUM_RAW_PCB 4 -#endif - -/** - * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - * per active UDP "connection". - * (requires the LWIP_UDP option) - */ -#if !defined MEMP_NUM_UDP_PCB || defined __DOXYGEN__ -#define MEMP_NUM_UDP_PCB 4 -#endif - -/** - * MEMP_NUM_TCP_PCB: the number of simultaneously active TCP connections. - * (requires the LWIP_TCP option) - */ -#if !defined MEMP_NUM_TCP_PCB || defined __DOXYGEN__ -#define MEMP_NUM_TCP_PCB 5 -#endif - -/** - * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. - * (requires the LWIP_TCP option) - */ -#if !defined MEMP_NUM_TCP_PCB_LISTEN || defined __DOXYGEN__ -#define MEMP_NUM_TCP_PCB_LISTEN 8 -#endif - -/** - * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. - * (requires the LWIP_TCP option) - */ -#if !defined MEMP_NUM_TCP_SEG || defined __DOXYGEN__ -#define MEMP_NUM_TCP_SEG 16 -#endif - -/** - * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for - * reassembly (whole packets, not fragments!) - */ -#if !defined MEMP_NUM_REASSDATA || defined __DOXYGEN__ -#define MEMP_NUM_REASSDATA 5 -#endif - -/** - * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent - * (fragments, not whole packets!). - * This is only used with LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 - * with DMA-enabled MACs where the packet is not yet sent when netif->output - * returns. - */ -#if !defined MEMP_NUM_FRAG_PBUF || defined __DOXYGEN__ -#define MEMP_NUM_FRAG_PBUF 15 -#endif - -/** - * MEMP_NUM_ARP_QUEUE: the number of simultaneously queued outgoing - * packets (pbufs) that are waiting for an ARP request (to resolve - * their destination address) to finish. - * (requires the ARP_QUEUEING option) - */ -#if !defined MEMP_NUM_ARP_QUEUE || defined __DOXYGEN__ -#define MEMP_NUM_ARP_QUEUE 30 -#endif - -/** - * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces - * can be members at the same time (one per netif - allsystems group -, plus one - * per netif membership). - * (requires the LWIP_IGMP option) - */ -#if !defined MEMP_NUM_IGMP_GROUP || defined __DOXYGEN__ -#define MEMP_NUM_IGMP_GROUP 8 -#endif - -/** - * MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts. - * The default number of timeouts is calculated here for all enabled modules. - * The formula expects settings to be either '0' or '1'. - */ -#if !defined MEMP_NUM_SYS_TIMEOUT || defined __DOXYGEN__ -#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) -#endif - -/** - * MEMP_NUM_NETBUF: the number of struct netbufs. - * (only needed if you use the sequential API, like api_lib.c) - */ -#if !defined MEMP_NUM_NETBUF || defined __DOXYGEN__ -#define MEMP_NUM_NETBUF 2 -#endif - -/** - * MEMP_NUM_NETCONN: the number of struct netconns. - * (only needed if you use the sequential API, like api_lib.c) - */ -#if !defined MEMP_NUM_NETCONN || defined __DOXYGEN__ -#define MEMP_NUM_NETCONN 4 -#endif - -/** - * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used - * for callback/timeout API communication. - * (only needed if you use tcpip.c) - */ -#if !defined MEMP_NUM_TCPIP_MSG_API || defined __DOXYGEN__ -#define MEMP_NUM_TCPIP_MSG_API 8 -#endif - -/** - * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used - * for incoming packets. - * (only needed if you use tcpip.c) - */ -#if !defined MEMP_NUM_TCPIP_MSG_INPKT || defined __DOXYGEN__ -#define MEMP_NUM_TCPIP_MSG_INPKT 8 -#endif - -/** - * MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls - * (before freeing the corresponding memory using lwip_freeaddrinfo()). - */ -#if !defined MEMP_NUM_NETDB || defined __DOXYGEN__ -#define MEMP_NUM_NETDB 1 -#endif - -/** - * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list - * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1. - */ -#if !defined MEMP_NUM_LOCALHOSTLIST || defined __DOXYGEN__ -#define MEMP_NUM_LOCALHOSTLIST 1 -#endif - -/** - * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. - */ -#if !defined PBUF_POOL_SIZE || defined __DOXYGEN__ -#define PBUF_POOL_SIZE 16 -#endif - -/** MEMP_NUM_API_MSG: the number of concurrently active calls to various - * socket, netconn, and tcpip functions - */ -#if !defined MEMP_NUM_API_MSG || defined __DOXYGEN__ -#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API -#endif - -/** MEMP_NUM_DNS_API_MSG: the number of concurrently active calls to netconn_gethostbyname - */ -#if !defined MEMP_NUM_DNS_API_MSG || defined __DOXYGEN__ -#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API -#endif - -/** MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA: the number of concurrently active calls - * to getsockopt/setsockopt - */ -#if !defined MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA || defined __DOXYGEN__ -#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API -#endif - -/** MEMP_NUM_NETIFAPI_MSG: the number of concurrently active calls to the - * netifapi functions - */ -#if !defined MEMP_NUM_NETIFAPI_MSG || defined __DOXYGEN__ -#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API -#endif -/** - * @} - */ - -/* - --------------------------------- - ---------- ARP options ---------- - --------------------------------- - */ -/** - * @defgroup lwip_opts_arp ARP - * @ingroup lwip_opts_ipv4 - * @{ - */ -/** - * LWIP_ARP==1: Enable ARP functionality. - */ -#if !defined LWIP_ARP || defined __DOXYGEN__ -#define LWIP_ARP 1 -#endif - -/** - * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached. - */ -#if !defined ARP_TABLE_SIZE || defined __DOXYGEN__ -#define ARP_TABLE_SIZE 10 -#endif - -/** the time an ARP entry stays valid after its last update, - * for ARP_TMR_INTERVAL = 1000, this is - * (60 * 5) seconds = 5 minutes. - */ -#if !defined ARP_MAXAGE || defined __DOXYGEN__ -#define ARP_MAXAGE 300 -#endif - -/** - * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address - * resolution. By default, only the most recent packet is queued per IP address. - * This is sufficient for most protocols and mainly reduces TCP connection - * startup time. Set this to 1 if you know your application sends more than one - * packet in a row to an IP address that is not in the ARP cache. - */ -#if !defined ARP_QUEUEING || defined __DOXYGEN__ -#define ARP_QUEUEING 0 -#endif - -/** The maximum number of packets which may be queued for each - * unresolved address by other network layers. Defaults to 3, 0 means disabled. - * Old packets are dropped, new packets are queued. - */ -#if !defined ARP_QUEUE_LEN || defined __DOXYGEN__ -#define ARP_QUEUE_LEN 3 -#endif - -/** - * ETHARP_SUPPORT_VLAN==1: support receiving and sending ethernet packets with - * VLAN header. See the description of LWIP_HOOK_VLAN_CHECK and - * LWIP_HOOK_VLAN_SET hooks to check/set VLAN headers. - * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check. - * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted. - * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted. - * Alternatively, define a function/define ETHARP_VLAN_CHECK_FN(eth_hdr, vlan) - * that returns 1 to accept a packet or 0 to drop a packet. - */ -#if !defined ETHARP_SUPPORT_VLAN || defined __DOXYGEN__ -#define ETHARP_SUPPORT_VLAN 0 -#endif - -/** LWIP_ETHERNET==1: enable ethernet support even though ARP might be disabled - */ -#if !defined LWIP_ETHERNET || defined __DOXYGEN__ -#define LWIP_ETHERNET LWIP_ARP -#endif - -/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure - * alignment of payload after that header. Since the header is 14 bytes long, - * without this padding e.g. addresses in the IP header will not be aligned - * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms. - */ -#if !defined ETH_PAD_SIZE || defined __DOXYGEN__ -#define ETH_PAD_SIZE 0 -#endif - -/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table - * entries (using etharp_add_static_entry/etharp_remove_static_entry). - */ -#if !defined ETHARP_SUPPORT_STATIC_ENTRIES || defined __DOXYGEN__ -#define ETHARP_SUPPORT_STATIC_ENTRIES 0 -#endif - -/** ETHARP_TABLE_MATCH_NETIF==1: Match netif for ARP table entries. - * If disabled, duplicate IP address on multiple netifs are not supported - * (but this should only occur for AutoIP). - */ -#if !defined ETHARP_TABLE_MATCH_NETIF || defined __DOXYGEN__ -#define ETHARP_TABLE_MATCH_NETIF 0 -#endif -/** - * @} - */ - -/* - -------------------------------- - ---------- IP options ---------- - -------------------------------- - */ -/** - * @defgroup lwip_opts_ipv4 IPv4 - * @ingroup lwip_opts - * @{ - */ -/** - * LWIP_IPV4==1: Enable IPv4 - */ -#if !defined LWIP_IPV4 || defined __DOXYGEN__ -#define LWIP_IPV4 1 -#endif - -/** - * IP_FORWARD==1: Enables the ability to forward IP packets across network - * interfaces. If you are going to run lwIP on a device with only one network - * interface, define this to 0. - */ -#if !defined IP_FORWARD || defined __DOXYGEN__ -#define IP_FORWARD 0 -#endif - -/** - * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that - * this option does not affect outgoing packet sizes, which can be controlled - * via IP_FRAG. - */ -#if !defined IP_REASSEMBLY || defined __DOXYGEN__ -#define IP_REASSEMBLY 1 -#endif - -/** - * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note - * that this option does not affect incoming packet sizes, which can be - * controlled via IP_REASSEMBLY. - */ -#if !defined IP_FRAG || defined __DOXYGEN__ -#define IP_FRAG 1 -#endif - -#if !LWIP_IPV4 -/* disable IPv4 extensions when IPv4 is disabled */ -#undef IP_FORWARD -#define IP_FORWARD 0 -#undef IP_REASSEMBLY -#define IP_REASSEMBLY 0 -#undef IP_FRAG -#define IP_FRAG 0 -#endif /* !LWIP_IPV4 */ - -/** - * IP_OPTIONS_ALLOWED: Defines the behavior for IP options. - * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. - * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). - */ -#if !defined IP_OPTIONS_ALLOWED || defined __DOXYGEN__ -#define IP_OPTIONS_ALLOWED 1 -#endif - -/** - * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) - * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived - * in this time, the whole packet is discarded. - */ -#if !defined IP_REASS_MAXAGE || defined __DOXYGEN__ -#define IP_REASS_MAXAGE 3 -#endif - -/** - * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. - * Since the received pbufs are enqueued, be sure to configure - * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive - * packets even if the maximum amount of fragments is enqueued for reassembly! - */ -#if !defined IP_REASS_MAX_PBUFS || defined __DOXYGEN__ -#define IP_REASS_MAX_PBUFS 10 -#endif - -/** - * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers. - */ -#if !defined IP_DEFAULT_TTL || defined __DOXYGEN__ -#define IP_DEFAULT_TTL 255 -#endif - -/** - * IP_SOF_BROADCAST=1: Use the SOF_BROADCAST field to enable broadcast - * filter per pcb on udp and raw send operations. To enable broadcast filter - * on recv operations, you also have to set IP_SOF_BROADCAST_RECV=1. - */ -#if !defined IP_SOF_BROADCAST || defined __DOXYGEN__ -#define IP_SOF_BROADCAST 0 -#endif - -/** - * IP_SOF_BROADCAST_RECV (requires IP_SOF_BROADCAST=1) enable the broadcast - * filter on recv operations. - */ -#if !defined IP_SOF_BROADCAST_RECV || defined __DOXYGEN__ -#define IP_SOF_BROADCAST_RECV 0 -#endif - -/** - * IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1: allow ip_forward() to send packets back - * out on the netif where it was received. This should only be used for - * wireless networks. - * ATTENTION: When this is 1, make sure your netif driver correctly marks incoming - * link-layer-broadcast/multicast packets as such using the corresponding pbuf flags! - */ -#if !defined IP_FORWARD_ALLOW_TX_ON_RX_NETIF || defined __DOXYGEN__ -#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0 -#endif - -/** - * LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first - * local TCP/UDP pcb (default==0). This can prevent creating predictable port - * numbers after booting a device. - */ -#if !defined LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS || defined __DOXYGEN__ -#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0 -#endif -/** - * @} - */ - -/* - ---------------------------------- - ---------- ICMP options ---------- - ---------------------------------- - */ -/** - * @defgroup lwip_opts_icmp ICMP - * @ingroup lwip_opts_ipv4 - * @{ - */ -/** - * LWIP_ICMP==1: Enable ICMP module inside the IP stack. - * Be careful, disable that make your product non-compliant to RFC1122 - */ -#if !defined LWIP_ICMP || defined __DOXYGEN__ -#define LWIP_ICMP 1 -#endif - -/** - * ICMP_TTL: Default value for Time-To-Live used by ICMP packets. - */ -#if !defined ICMP_TTL || defined __DOXYGEN__ -#define ICMP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) - */ -#if !defined LWIP_BROADCAST_PING || defined __DOXYGEN__ -#define LWIP_BROADCAST_PING 0 -#endif - -/** - * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only) - */ -#if !defined LWIP_MULTICAST_PING || defined __DOXYGEN__ -#define LWIP_MULTICAST_PING 0 -#endif -/** - * @} - */ - -/* - --------------------------------- - ---------- RAW options ---------- - --------------------------------- - */ -/** - * @defgroup lwip_opts_raw RAW - * @ingroup lwip_opts_callback - * @{ - */ -/** - * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. - */ -#if !defined LWIP_RAW || defined __DOXYGEN__ -#define LWIP_RAW 0 -#endif - -/** - * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. - */ -#if !defined RAW_TTL || defined __DOXYGEN__ -#define RAW_TTL (IP_DEFAULT_TTL) -#endif -/** - * @} - */ - -/* - ---------------------------------- - ---------- DHCP options ---------- - ---------------------------------- - */ -/** - * @defgroup lwip_opts_dhcp DHCP - * @ingroup lwip_opts_ipv4 - * @{ - */ -/** - * LWIP_DHCP==1: Enable DHCP module. - */ -#if !defined LWIP_DHCP || defined __DOXYGEN__ -#define LWIP_DHCP 0 -#endif -#if !LWIP_IPV4 -/* disable DHCP when IPv4 is disabled */ -#undef LWIP_DHCP -#define LWIP_DHCP 0 -#endif /* !LWIP_IPV4 */ - -/** - * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address. - */ -#if !defined DHCP_DOES_ARP_CHECK || defined __DOXYGEN__ -#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP)) -#endif - -/** - * LWIP_DHCP_CHECK_LINK_UP==1: dhcp_start() only really starts if the netif has - * NETIF_FLAG_LINK_UP set in its flags. As this is only an optimization and - * netif drivers might not set this flag, the default is off. If enabled, - * netif_set_link_up() must be called to continue dhcp starting. - */ -#if !defined LWIP_DHCP_CHECK_LINK_UP -#define LWIP_DHCP_CHECK_LINK_UP 0 -#endif - -/** - * LWIP_DHCP_BOOTP_FILE==1: Store offered_si_addr and boot_file_name. - */ -#if !defined LWIP_DHCP_BOOTP_FILE || defined __DOXYGEN__ -#define LWIP_DHCP_BOOTP_FILE 0 -#endif - -/** - * LWIP_DHCP_GETS_NTP==1: Request NTP servers with discover/select. For each - * response packet, an callback is called, which has to be provided by the port: - * void dhcp_set_ntp_servers(u8_t num_ntp_servers, ip_addr_t* ntp_server_addrs); - */ -#if !defined LWIP_DHCP_GET_NTP_SRV || defined __DOXYGEN__ -#define LWIP_DHCP_GET_NTP_SRV 0 -#endif - -/** - * The maximum of NTP servers requested - */ -#if !defined LWIP_DHCP_MAX_NTP_SERVERS || defined __DOXYGEN__ -#define LWIP_DHCP_MAX_NTP_SERVERS 1 -#endif - -/** - * LWIP_DHCP_MAX_DNS_SERVERS > 0: Request DNS servers with discover/select. - * DHCP servers received in the response are passed to DNS via @ref dns_setserver() - * (up to the maximum limit defined here). - */ -#if !defined LWIP_DHCP_MAX_DNS_SERVERS || defined __DOXYGEN__ -#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS -#endif -/** - * @} - */ - -/* - ------------------------------------ - ---------- AUTOIP options ---------- - ------------------------------------ - */ -/** - * @defgroup lwip_opts_autoip AUTOIP - * @ingroup lwip_opts_ipv4 - * @{ - */ -/** - * LWIP_AUTOIP==1: Enable AUTOIP module. - */ -#if !defined LWIP_AUTOIP || defined __DOXYGEN__ -#define LWIP_AUTOIP 0 -#endif -#if !LWIP_IPV4 -/* disable AUTOIP when IPv4 is disabled */ -#undef LWIP_AUTOIP -#define LWIP_AUTOIP 0 -#endif /* !LWIP_IPV4 */ - -/** - * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on - * the same interface at the same time. - */ -#if !defined LWIP_DHCP_AUTOIP_COOP || defined __DOXYGEN__ -#define LWIP_DHCP_AUTOIP_COOP 0 -#endif - -/** - * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes - * that should be sent before falling back on AUTOIP (the DHCP client keeps - * running in this case). This can be set as low as 1 to get an AutoIP address - * very quickly, but you should be prepared to handle a changing IP address - * when DHCP overrides AutoIP. - */ -#if !defined LWIP_DHCP_AUTOIP_COOP_TRIES || defined __DOXYGEN__ -#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 -#endif -/** - * @} - */ - -/* - ---------------------------------- - ----- SNMP MIB2 support ----- - ---------------------------------- - */ -/** - * @defgroup lwip_opts_mib2 SNMP MIB2 callbacks - * @ingroup lwip_opts_infrastructure - * @{ - */ -/** - * LWIP_MIB2_CALLBACKS==1: Turn on SNMP MIB2 callbacks. - * Turn this on to get callbacks needed to implement MIB2. - * Usually MIB2_STATS should be enabled, too. - */ -#if !defined LWIP_MIB2_CALLBACKS || defined __DOXYGEN__ -#define LWIP_MIB2_CALLBACKS 0 -#endif -/** - * @} - */ - -/* - ---------------------------------- - ----- Multicast/IGMP options ----- - ---------------------------------- - */ -/** - * @defgroup lwip_opts_igmp IGMP - * @ingroup lwip_opts_ipv4 - * @{ - */ -/** - * LWIP_IGMP==1: Turn on IGMP module. - */ -#if !defined LWIP_IGMP || defined __DOXYGEN__ -#define LWIP_IGMP 0 -#endif -#if !LWIP_IPV4 -#undef LWIP_IGMP -#define LWIP_IGMP 0 -#endif - -/** - * LWIP_MULTICAST_TX_OPTIONS==1: Enable multicast TX support like the socket options - * IP_MULTICAST_TTL/IP_MULTICAST_IF/IP_MULTICAST_LOOP - */ -#if !defined LWIP_MULTICAST_TX_OPTIONS || defined __DOXYGEN__ -#define LWIP_MULTICAST_TX_OPTIONS (LWIP_IGMP && LWIP_UDP) -#endif -/** - * @} - */ - -/* - ---------------------------------- - ---------- DNS options ----------- - ---------------------------------- - */ -/** - * @defgroup lwip_opts_dns DNS - * @ingroup lwip_opts_callback - * @{ - */ -/** - * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS - * transport. - */ -#if !defined LWIP_DNS || defined __DOXYGEN__ -#define LWIP_DNS 0 -#endif - -/** DNS maximum number of entries to maintain locally. */ -#if !defined DNS_TABLE_SIZE || defined __DOXYGEN__ -#define DNS_TABLE_SIZE 4 -#endif - -/** DNS maximum host name length supported in the name table. */ -#if !defined DNS_MAX_NAME_LENGTH || defined __DOXYGEN__ -#define DNS_MAX_NAME_LENGTH 256 -#endif - -/** The maximum of DNS servers - * The first server can be initialized automatically by defining - * DNS_SERVER_ADDRESS(ipaddr), where 'ipaddr' is an 'ip_addr_t*' - */ -#if !defined DNS_MAX_SERVERS || defined __DOXYGEN__ -#define DNS_MAX_SERVERS 2 -#endif - -/** DNS do a name checking between the query and the response. */ -#if !defined DNS_DOES_NAME_CHECK || defined __DOXYGEN__ -#define DNS_DOES_NAME_CHECK 1 -#endif - -/** LWIP_DNS_SECURE: controls the security level of the DNS implementation - * Use all DNS security features by default. - * This is overridable but should only be needed by very small targets - * or when using against non standard DNS servers. */ -#if !defined LWIP_DNS_SECURE || defined __DOXYGEN__ -#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -#endif - -/* A list of DNS security features follows */ -#define LWIP_DNS_SECURE_RAND_XID 1 -#define LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING 2 -#define LWIP_DNS_SECURE_RAND_SRC_PORT 4 - -/** DNS_LOCAL_HOSTLIST: Implements a local host-to-address list. If enabled, you have to define an initializer: - * \#define DNS_LOCAL_HOSTLIST_INIT {DNS_LOCAL_HOSTLIST_ELEM("host_ip4", IPADDR4_INIT_BYTES(1,2,3,4)), \ - * DNS_LOCAL_HOSTLIST_ELEM("host_ip6", IPADDR6_INIT_HOST(123, 234, 345, 456)} - * - * Instead, you can also use an external function: - * \#define DNS_LOOKUP_LOCAL_EXTERN(x) extern err_t my_lookup_function(const char *name, ip_addr_t *addr, u8_t dns_addrtype) - * that looks up the IP address and returns ERR_OK if found (LWIP_DNS_ADDRTYPE_xxx is passed in dns_addrtype). - */ -#if !defined DNS_LOCAL_HOSTLIST || defined __DOXYGEN__ -#define DNS_LOCAL_HOSTLIST 0 -#endif /* DNS_LOCAL_HOSTLIST */ - -/** If this is turned on, the local host-list can be dynamically changed - * at runtime. */ -#if !defined DNS_LOCAL_HOSTLIST_IS_DYNAMIC || defined __DOXYGEN__ -#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0 -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -/** Set this to 1 to enable querying ".local" names via mDNS - * using a One-Shot Multicast DNS Query */ -#if !defined LWIP_DNS_SUPPORT_MDNS_QUERIES || defined __DOXYGEN__ -#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0 -#endif -/** - * @} - */ - -/* - --------------------------------- - ---------- UDP options ---------- - --------------------------------- - */ -/** - * @defgroup lwip_opts_udp UDP - * @ingroup lwip_opts_callback - * @{ - */ -/** - * LWIP_UDP==1: Turn on UDP. - */ -#if !defined LWIP_UDP || defined __DOXYGEN__ -#define LWIP_UDP 1 -#endif - -/** - * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP) - */ -#if !defined LWIP_UDPLITE || defined __DOXYGEN__ -#define LWIP_UDPLITE 0 -#endif - -/** - * UDP_TTL: Default Time-To-Live value. - */ -#if !defined UDP_TTL || defined __DOXYGEN__ -#define UDP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf. - */ -#if !defined LWIP_NETBUF_RECVINFO || defined __DOXYGEN__ -#define LWIP_NETBUF_RECVINFO 0 -#endif -/** - * @} - */ - -/* - --------------------------------- - ---------- TCP options ---------- - --------------------------------- - */ -/** - * @defgroup lwip_opts_tcp TCP - * @ingroup lwip_opts_callback - * @{ - */ -/** - * LWIP_TCP==1: Turn on TCP. - */ -#if !defined LWIP_TCP || defined __DOXYGEN__ -#define LWIP_TCP 1 -#endif - -/** - * TCP_TTL: Default Time-To-Live value. - */ -#if !defined TCP_TTL || defined __DOXYGEN__ -#define TCP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * TCP_WND: The size of a TCP window. This must be at least - * (2 * TCP_MSS) for things to work well. - * ATTENTION: when using TCP_RCV_SCALE, TCP_WND is the total size - * with scaling applied. Maximum window value in the TCP header - * will be TCP_WND >> TCP_RCV_SCALE - */ -#if !defined TCP_WND || defined __DOXYGEN__ -#define TCP_WND (4 * TCP_MSS) -#endif - -/** - * TCP_MAXRTX: Maximum number of retransmissions of data segments. - */ -#if !defined TCP_MAXRTX || defined __DOXYGEN__ -#define TCP_MAXRTX 12 -#endif - -/** - * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments. - */ -#if !defined TCP_SYNMAXRTX || defined __DOXYGEN__ -#define TCP_SYNMAXRTX 6 -#endif - -/** - * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order. - * Define to 0 if your device is low on memory. - */ -#if !defined TCP_QUEUE_OOSEQ || defined __DOXYGEN__ -#define TCP_QUEUE_OOSEQ (LWIP_TCP) -#endif - -/** - * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, - * you might want to increase this.) - * For the receive side, this MSS is advertised to the remote side - * when opening a connection. For the transmit size, this MSS sets - * an upper limit on the MSS advertised by the remote host. - */ -#if !defined TCP_MSS || defined __DOXYGEN__ -#define TCP_MSS 536 -#endif - -/** - * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really - * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which - * reflects the available reassembly buffer size at the remote host) and the - * largest size permitted by the IP layer" (RFC 1122) - * Setting this to 1 enables code that checks TCP_MSS against the MTU of the - * netif used for a connection and limits the MSS if it would be too big otherwise. - */ -#if !defined TCP_CALCULATE_EFF_SEND_MSS || defined __DOXYGEN__ -#define TCP_CALCULATE_EFF_SEND_MSS 1 -#endif - -/** - * TCP_SND_BUF: TCP sender buffer space (bytes). - * To achieve good performance, this should be at least 2 * TCP_MSS. - */ -#if !defined TCP_SND_BUF || defined __DOXYGEN__ -#define TCP_SND_BUF (2 * TCP_MSS) -#endif - -/** - * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least - * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. - */ -#if !defined TCP_SND_QUEUELEN || defined __DOXYGEN__ -#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) -#endif - -/** - * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than - * TCP_SND_BUF. It is the amount of space which must be available in the - * TCP snd_buf for select to return writable (combined with TCP_SNDQUEUELOWAT). - */ -#if !defined TCP_SNDLOWAT || defined __DOXYGEN__ -#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -#endif - -/** - * TCP_SNDQUEUELOWAT: TCP writable bufs (pbuf count). This must be less - * than TCP_SND_QUEUELEN. If the number of pbufs queued on a pcb drops below - * this number, select returns writable (combined with TCP_SNDLOWAT). - */ -#if !defined TCP_SNDQUEUELOWAT || defined __DOXYGEN__ -#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5) -#endif - -/** - * TCP_OOSEQ_MAX_BYTES: The maximum number of bytes queued on ooseq per pcb. - * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==1. - */ -#if !defined TCP_OOSEQ_MAX_BYTES || defined __DOXYGEN__ -#define TCP_OOSEQ_MAX_BYTES 0 -#endif - -/** - * TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs queued on ooseq per pcb. - * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==1. - */ -#if !defined TCP_OOSEQ_MAX_PBUFS || defined __DOXYGEN__ -#define TCP_OOSEQ_MAX_PBUFS 0 -#endif - -/** - * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb. - */ -#if !defined TCP_LISTEN_BACKLOG || defined __DOXYGEN__ -#define TCP_LISTEN_BACKLOG 0 -#endif - -/** - * The maximum allowed backlog for TCP listen netconns. - * This backlog is used unless another is explicitly specified. - * 0xff is the maximum (u8_t). - */ -#if !defined TCP_DEFAULT_LISTEN_BACKLOG || defined __DOXYGEN__ -#define TCP_DEFAULT_LISTEN_BACKLOG 0xff -#endif - -/** - * TCP_OVERSIZE: The maximum number of bytes that tcp_write may - * allocate ahead of time in an attempt to create shorter pbuf chains - * for transmission. The meaningful range is 0 to TCP_MSS. Some - * suggested values are: - * - * 0: Disable oversized allocation. Each tcp_write() allocates a new - pbuf (old behaviour). - * 1: Allocate size-aligned pbufs with minimal excess. Use this if your - * scatter-gather DMA requires aligned fragments. - * 128: Limit the pbuf/memory overhead to 20%. - * TCP_MSS: Try to create unfragmented TCP packets. - * TCP_MSS/4: Try to create 4 fragments or less per TCP packet. - */ -#if !defined TCP_OVERSIZE || defined __DOXYGEN__ -#define TCP_OVERSIZE TCP_MSS -#endif - -/** - * LWIP_TCP_TIMESTAMPS==1: support the TCP timestamp option. - * The timestamp option is currently only used to help remote hosts, it is not - * really used locally. Therefore, it is only enabled when a TS option is - * received in the initial SYN packet from a remote host. - */ -#if !defined LWIP_TCP_TIMESTAMPS || defined __DOXYGEN__ -#define LWIP_TCP_TIMESTAMPS 0 -#endif - -/** - * TCP_WND_UPDATE_THRESHOLD: difference in window to trigger an - * explicit window update - */ -#if !defined TCP_WND_UPDATE_THRESHOLD || defined __DOXYGEN__ -#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4)) -#endif - -/** - * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1. - * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all - * events (accept, sent, etc) that happen in the system. - * LWIP_CALLBACK_API==1: The PCB callback function is called directly - * for the event. This is the default. - */ -#if !defined(LWIP_EVENT_API) && !defined(LWIP_CALLBACK_API) || defined __DOXYGEN__ -#define LWIP_EVENT_API 0 -#define LWIP_CALLBACK_API 1 -#else -#ifndef LWIP_EVENT_API -#define LWIP_EVENT_API 0 -#endif -#ifndef LWIP_CALLBACK_API -#define LWIP_CALLBACK_API 0 -#endif -#endif - -/** - * LWIP_WND_SCALE and TCP_RCV_SCALE: - * Set LWIP_WND_SCALE to 1 to enable window scaling. - * Set TCP_RCV_SCALE to the desired scaling factor (shift count in the - * range of [0..14]). - * When LWIP_WND_SCALE is enabled but TCP_RCV_SCALE is 0, we can use a large - * send window while having a small receive window only. - */ -#if !defined LWIP_WND_SCALE || defined __DOXYGEN__ -#define LWIP_WND_SCALE 0 -#define TCP_RCV_SCALE 0 -#endif -/** - * @} - */ - -/* - ---------------------------------- - ---------- Pbuf options ---------- - ---------------------------------- - */ -/** - * @defgroup lwip_opts_pbuf PBUF - * @ingroup lwip_opts - * @{ - */ -/** - * PBUF_LINK_HLEN: the number of bytes that should be allocated for a - * link level header. The default is 14, the standard value for - * Ethernet. - */ -#if !defined PBUF_LINK_HLEN || defined __DOXYGEN__ -#if defined LWIP_HOOK_VLAN_SET && !defined __DOXYGEN__ -#define PBUF_LINK_HLEN (18 + ETH_PAD_SIZE) -#else /* LWIP_HOOK_VLAN_SET */ -#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) -#endif /* LWIP_HOOK_VLAN_SET */ -#endif - -/** - * PBUF_LINK_ENCAPSULATION_HLEN: the number of bytes that should be allocated - * for an additional encapsulation header before ethernet headers (e.g. 802.11) - */ -#if !defined PBUF_LINK_ENCAPSULATION_HLEN || defined __DOXYGEN__ -#define PBUF_LINK_ENCAPSULATION_HLEN 0u -#endif - -/** - * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is - * designed to accommodate single full size TCP frame in one pbuf, including - * TCP_MSS, IP header, and link header. - */ -#if !defined PBUF_POOL_BUFSIZE || defined __DOXYGEN__ -#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) -#endif -/** - * @} - */ - -/* - ------------------------------------------------ - ---------- Network Interfaces options ---------- - ------------------------------------------------ - */ -/** - * @defgroup lwip_opts_netif NETIF - * @ingroup lwip_opts - * @{ - */ -/** - * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname - * field. - */ -#if !defined LWIP_NETIF_HOSTNAME || defined __DOXYGEN__ -#define LWIP_NETIF_HOSTNAME 0 -#endif - -/** - * LWIP_NETIF_API==1: Support netif api (in netifapi.c) - */ -#if !defined LWIP_NETIF_API || defined __DOXYGEN__ -#define LWIP_NETIF_API 0 -#endif - -/** - * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface - * changes its up/down status (i.e., due to DHCP IP acquisition) - */ -#if !defined LWIP_NETIF_STATUS_CALLBACK || defined __DOXYGEN__ -#define LWIP_NETIF_STATUS_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface - * whenever the link changes (i.e., link down) - */ -#if !defined LWIP_NETIF_LINK_CALLBACK || defined __DOXYGEN__ -#define LWIP_NETIF_LINK_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_REMOVE_CALLBACK==1: Support a callback function that is called - * when a netif has been removed - */ -#if !defined LWIP_NETIF_REMOVE_CALLBACK || defined __DOXYGEN__ -#define LWIP_NETIF_REMOVE_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table - * indices) in struct netif. TCP and UDP can make use of this to prevent - * scanning the ARP table for every sent packet. While this is faster for big - * ARP tables or many concurrent connections, it might be counterproductive - * if you have a tiny ARP table or if there never are concurrent connections. - */ -#if !defined LWIP_NETIF_HWADDRHINT || defined __DOXYGEN__ -#define LWIP_NETIF_HWADDRHINT 0 -#endif - -/** - * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data - * to be sent into one single pbuf. This is for compatibility with DMA-enabled - * MACs that do not support scatter-gather. - * Beware that this might involve CPU-memcpy before transmitting that would not - * be needed without this flag! Use this only if you need to! - * - * @todo: TCP and IP-frag do not work with this, yet: - */ -#if !defined LWIP_NETIF_TX_SINGLE_PBUF || defined __DOXYGEN__ -#define LWIP_NETIF_TX_SINGLE_PBUF 0 -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - -/** - * LWIP_NUM_NETIF_CLIENT_DATA: Number of clients that may store - * data in client_data member array of struct netif. - */ -#if !defined LWIP_NUM_NETIF_CLIENT_DATA || defined __DOXYGEN__ -#define LWIP_NUM_NETIF_CLIENT_DATA 0 -#endif -/** - * @} - */ - -/* - ------------------------------------ - ---------- LOOPIF options ---------- - ------------------------------------ - */ -/** - * @defgroup lwip_opts_loop Loopback interface - * @ingroup lwip_opts_netif - * @{ - */ -/** - * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1). - * This is only needed when no real netifs are available. If at least one other - * netif is available, loopback traffic uses this netif. - */ -#if !defined LWIP_HAVE_LOOPIF || defined __DOXYGEN__ -#define LWIP_HAVE_LOOPIF LWIP_NETIF_LOOPBACK -#endif - -/** - * LWIP_LOOPIF_MULTICAST==1: Support multicast/IGMP on loop interface (127.0.0.1). - */ -#if !defined LWIP_LOOPIF_MULTICAST || defined __DOXYGEN__ -#define LWIP_LOOPIF_MULTICAST 0 -#endif - -/** - * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP - * address equal to the netif IP address, looping them back up the stack. - */ -#if !defined LWIP_NETIF_LOOPBACK || defined __DOXYGEN__ -#define LWIP_NETIF_LOOPBACK 0 -#endif - -/** - * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback - * sending for each netif (0 = disabled) - */ -#if !defined LWIP_LOOPBACK_MAX_PBUFS || defined __DOXYGEN__ -#define LWIP_LOOPBACK_MAX_PBUFS 0 -#endif - -/** - * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in - * the system, as netifs must change how they behave depending on this setting - * for the LWIP_NETIF_LOOPBACK option to work. - * Setting this is needed to avoid reentering non-reentrant functions like - * tcp_input(). - * LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a - * multithreaded environment like tcpip.c. In this case, netif->input() - * is called directly. - * LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. - * The packets are put on a list and netif_poll() must be called in - * the main application loop. - */ -#if !defined LWIP_NETIF_LOOPBACK_MULTITHREADING || defined __DOXYGEN__ -#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) -#endif -/** - * @} - */ - -/* - ------------------------------------ - ---------- Thread options ---------- - ------------------------------------ - */ -/** - * @defgroup lwip_opts_thread Threading - * @ingroup lwip_opts_infrastructure - * @{ - */ -/** - * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread. - */ -#if !defined TCPIP_THREAD_NAME || defined __DOXYGEN__ -#define TCPIP_THREAD_NAME "tcpip_thread" -#endif - -/** - * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#if !defined TCPIP_THREAD_STACKSIZE || defined __DOXYGEN__ -#define TCPIP_THREAD_STACKSIZE 0 -#endif - -/** - * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#if !defined TCPIP_THREAD_PRIO || defined __DOXYGEN__ -#define TCPIP_THREAD_PRIO 1 -#endif - -/** - * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when tcpip_init is called. - */ -#if !defined TCPIP_MBOX_SIZE || defined __DOXYGEN__ -#define TCPIP_MBOX_SIZE 0 -#endif - -/** - * Define this to something that triggers a watchdog. This is called from - * tcpip_thread after processing a message. - */ -#if !defined LWIP_TCPIP_THREAD_ALIVE || defined __DOXYGEN__ -#define LWIP_TCPIP_THREAD_ALIVE() -#endif - -/** - * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread. - */ -#if !defined SLIPIF_THREAD_NAME || defined __DOXYGEN__ -#define SLIPIF_THREAD_NAME "slipif_loop" -#endif - -/** - * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#if !defined SLIPIF_THREAD_STACKSIZE || defined __DOXYGEN__ -#define SLIPIF_THREAD_STACKSIZE 0 -#endif - -/** - * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#if !defined SLIPIF_THREAD_PRIO || defined __DOXYGEN__ -#define SLIPIF_THREAD_PRIO 1 -#endif - -/** - * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread. - */ -#if !defined DEFAULT_THREAD_NAME || defined __DOXYGEN__ -#define DEFAULT_THREAD_NAME "lwIP" -#endif - -/** - * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#if !defined DEFAULT_THREAD_STACKSIZE || defined __DOXYGEN__ -#define DEFAULT_THREAD_STACKSIZE 0 -#endif - -/** - * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#if !defined DEFAULT_THREAD_PRIO || defined __DOXYGEN__ -#define DEFAULT_THREAD_PRIO 1 -#endif - -/** - * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#if !defined DEFAULT_RAW_RECVMBOX_SIZE || defined __DOXYGEN__ -#define DEFAULT_RAW_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#if !defined DEFAULT_UDP_RECVMBOX_SIZE || defined __DOXYGEN__ -#define DEFAULT_UDP_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#if !defined DEFAULT_TCP_RECVMBOX_SIZE || defined __DOXYGEN__ -#define DEFAULT_TCP_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections. - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when the acceptmbox is created. - */ -#if !defined DEFAULT_ACCEPTMBOX_SIZE || defined __DOXYGEN__ -#define DEFAULT_ACCEPTMBOX_SIZE 0 -#endif -/** - * @} - */ - -/* - ---------------------------------------------- - ---------- Sequential layer options ---------- - ---------------------------------------------- - */ -/** - * @defgroup lwip_opts_netconn Netconn - * @ingroup lwip_opts_threadsafe_apis - * @{ - */ -/** - * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) - */ -#if !defined LWIP_NETCONN || defined __DOXYGEN__ -#define LWIP_NETCONN 1 -#endif - -/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout to create - * timers running in tcpip_thread from another thread. - */ -#if !defined LWIP_TCPIP_TIMEOUT || defined __DOXYGEN__ -#define LWIP_TCPIP_TIMEOUT 0 -#endif - -/** LWIP_NETCONN_SEM_PER_THREAD==1: Use one (thread-local) semaphore per - * thread calling socket/netconn functions instead of allocating one - * semaphore per netconn (and per select etc.) - * ATTENTION: a thread-local semaphore for API calls is needed: - * - LWIP_NETCONN_THREAD_SEM_GET() returning a sys_sem_t* - * - LWIP_NETCONN_THREAD_SEM_ALLOC() creating the semaphore - * - LWIP_NETCONN_THREAD_SEM_FREE() freeing the semaphore - * The latter 2 can be invoked up by calling netconn_thread_init()/netconn_thread_cleanup(). - * Ports may call these for threads created with sys_thread_new(). - */ -#if !defined LWIP_NETCONN_SEM_PER_THREAD || defined __DOXYGEN__ -#define LWIP_NETCONN_SEM_PER_THREAD 0 -#endif - -/** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread, - * writing from a 2nd thread and closing from a 3rd thread at the same time. - * ATTENTION: This is currently really alpha! Some requirements: - * - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from - * multiple threads at once - * - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox - * and prevent a task pending on this during/after deletion - */ -#if !defined LWIP_NETCONN_FULLDUPLEX || defined __DOXYGEN__ -#define LWIP_NETCONN_FULLDUPLEX 0 -#endif -/** - * @} - */ - -/* - ------------------------------------ - ---------- Socket options ---------- - ------------------------------------ - */ -/** - * @defgroup lwip_opts_socket Sockets - * @ingroup lwip_opts_threadsafe_apis - * @{ - */ -/** - * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) - */ -#if !defined LWIP_SOCKET || defined __DOXYGEN__ -#define LWIP_SOCKET 1 -#endif - -/* LWIP_SOCKET_SET_ERRNO==1: Set errno when socket functions cannot complete - * successfully, as required by POSIX. Default is POSIX-compliant. - */ -#if !defined LWIP_SOCKET_SET_ERRNO || defined __DOXYGEN__ -#define LWIP_SOCKET_SET_ERRNO 1 -#endif - -/** - * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names through defines. - * LWIP_COMPAT_SOCKETS==2: Same as ==1 but correctly named functions are created. - * While this helps code completion, it might conflict with existing libraries. - * (only used if you use sockets.c) - */ -#if !defined LWIP_COMPAT_SOCKETS || defined __DOXYGEN__ -#define LWIP_COMPAT_SOCKETS 1 -#endif - -/** - * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names. - * Disable this option if you use a POSIX operating system that uses the same - * names (read, write & close). (only used if you use sockets.c) - */ -#if !defined LWIP_POSIX_SOCKETS_IO_NAMES || defined __DOXYGEN__ -#define LWIP_POSIX_SOCKETS_IO_NAMES 1 -#endif - -/** - * LWIP_SOCKET_OFFSET==n: Increases the file descriptor number created by LwIP with n. - * This can be useful when there are multiple APIs which create file descriptors. - * When they all start with a different offset and you won't make them overlap you can - * re implement read/write/close/ioctl/fnctl to send the requested action to the right - * library (sharing select will need more work though). - */ -#if !defined LWIP_SOCKET_OFFSET || defined __DOXYGEN__ -#define LWIP_SOCKET_OFFSET 0 -#endif - -/** - * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT - * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set - * in seconds. (does not require sockets.c, and will affect tcp.c) - */ -#if !defined LWIP_TCP_KEEPALIVE || defined __DOXYGEN__ -#define LWIP_TCP_KEEPALIVE 0 -#endif - -/** - * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and - * SO_SNDTIMEO processing. - */ -#if !defined LWIP_SO_SNDTIMEO || defined __DOXYGEN__ -#define LWIP_SO_SNDTIMEO 0 -#endif - -/** - * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and - * SO_RCVTIMEO processing. - */ -#if !defined LWIP_SO_RCVTIMEO || defined __DOXYGEN__ -#define LWIP_SO_RCVTIMEO 0 -#endif - -/** - * LWIP_SO_SNDRCVTIMEO_NONSTANDARD==1: SO_RCVTIMEO/SO_SNDTIMEO take an int - * (milliseconds, much like winsock does) instead of a struct timeval (default). - */ -#if !defined LWIP_SO_SNDRCVTIMEO_NONSTANDARD || defined __DOXYGEN__ -#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0 -#endif - -/** - * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing. - */ -#if !defined LWIP_SO_RCVBUF || defined __DOXYGEN__ -#define LWIP_SO_RCVBUF 0 -#endif - -/** - * LWIP_SO_LINGER==1: Enable SO_LINGER processing. - */ -#if !defined LWIP_SO_LINGER || defined __DOXYGEN__ -#define LWIP_SO_LINGER 0 -#endif - -/** - * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize. - */ -#if !defined RECV_BUFSIZE_DEFAULT || defined __DOXYGEN__ -#define RECV_BUFSIZE_DEFAULT INT_MAX -#endif - -/** - * By default, TCP socket/netconn close waits 20 seconds max to send the FIN - */ -#if !defined LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT || defined __DOXYGEN__ -#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000 -#endif - -/** - * SO_REUSE==1: Enable SO_REUSEADDR option. - */ -#if !defined SO_REUSE || defined __DOXYGEN__ -#define SO_REUSE 0 -#endif - -/** - * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets - * to all local matches if SO_REUSEADDR is turned on. - * WARNING: Adds a memcpy for every packet if passing to more than one pcb! - */ -#if !defined SO_REUSE_RXTOALL || defined __DOXYGEN__ -#define SO_REUSE_RXTOALL 0 -#endif - -/** - * LWIP_FIONREAD_LINUXMODE==0 (default): ioctl/FIONREAD returns the amount of - * pending data in the network buffer. This is the way windows does it. It's - * the default for lwIP since it is smaller. - * LWIP_FIONREAD_LINUXMODE==1: ioctl/FIONREAD returns the size of the next - * pending datagram in bytes. This is the way linux does it. This code is only - * here for compatibility. - */ -#if !defined LWIP_FIONREAD_LINUXMODE || defined __DOXYGEN__ -#define LWIP_FIONREAD_LINUXMODE 0 -#endif -/** - * @} - */ - -/* - ---------------------------------------- - ---------- Statistics options ---------- - ---------------------------------------- - */ -/** - * @defgroup lwip_opts_stats Statistics - * @ingroup lwip_opts_debug - * @{ - */ -/** - * LWIP_STATS==1: Enable statistics collection in lwip_stats. - */ -#if !defined LWIP_STATS || defined __DOXYGEN__ -#define LWIP_STATS 1 -#endif - -#if LWIP_STATS - -/** - * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions. - */ -#if !defined LWIP_STATS_DISPLAY || defined __DOXYGEN__ -#define LWIP_STATS_DISPLAY 0 -#endif - -/** - * LINK_STATS==1: Enable link stats. - */ -#if !defined LINK_STATS || defined __DOXYGEN__ -#define LINK_STATS 1 -#endif - -/** - * ETHARP_STATS==1: Enable etharp stats. - */ -#if !defined ETHARP_STATS || defined __DOXYGEN__ -#define ETHARP_STATS (LWIP_ARP) -#endif - -/** - * IP_STATS==1: Enable IP stats. - */ -#if !defined IP_STATS || defined __DOXYGEN__ -#define IP_STATS 1 -#endif - -/** - * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is - * on if using either frag or reass. - */ -#if !defined IPFRAG_STATS || defined __DOXYGEN__ -#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG) -#endif - -/** - * ICMP_STATS==1: Enable ICMP stats. - */ -#if !defined ICMP_STATS || defined __DOXYGEN__ -#define ICMP_STATS 1 -#endif - -/** - * IGMP_STATS==1: Enable IGMP stats. - */ -#if !defined IGMP_STATS || defined __DOXYGEN__ -#define IGMP_STATS (LWIP_IGMP) -#endif - -/** - * UDP_STATS==1: Enable UDP stats. Default is on if - * UDP enabled, otherwise off. - */ -#if !defined UDP_STATS || defined __DOXYGEN__ -#define UDP_STATS (LWIP_UDP) -#endif - -/** - * TCP_STATS==1: Enable TCP stats. Default is on if TCP - * enabled, otherwise off. - */ -#if !defined TCP_STATS || defined __DOXYGEN__ -#define TCP_STATS (LWIP_TCP) -#endif - -/** - * MEM_STATS==1: Enable mem.c stats. - */ -#if !defined MEM_STATS || defined __DOXYGEN__ -#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0)) -#endif - -/** - * MEMP_STATS==1: Enable memp.c pool stats. - */ -#if !defined MEMP_STATS || defined __DOXYGEN__ -#define MEMP_STATS (MEMP_MEM_MALLOC == 0) -#endif - -/** - * SYS_STATS==1: Enable system stats (sem and mbox counts, etc). - */ -#if !defined SYS_STATS || defined __DOXYGEN__ -#define SYS_STATS (NO_SYS == 0) -#endif - -/** - * IP6_STATS==1: Enable IPv6 stats. - */ -#if !defined IP6_STATS || defined __DOXYGEN__ -#define IP6_STATS (LWIP_IPV6) -#endif - -/** - * ICMP6_STATS==1: Enable ICMP for IPv6 stats. - */ -#if !defined ICMP6_STATS || defined __DOXYGEN__ -#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6) -#endif - -/** - * IP6_FRAG_STATS==1: Enable IPv6 fragmentation stats. - */ -#if !defined IP6_FRAG_STATS || defined __DOXYGEN__ -#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS)) -#endif - -/** - * MLD6_STATS==1: Enable MLD for IPv6 stats. - */ -#if !defined MLD6_STATS || defined __DOXYGEN__ -#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD) -#endif - -/** - * ND6_STATS==1: Enable Neighbor discovery for IPv6 stats. - */ -#if !defined ND6_STATS || defined __DOXYGEN__ -#define ND6_STATS (LWIP_IPV6) -#endif - -/** - * MIB2_STATS==1: Stats for SNMP MIB2. - */ -#if !defined MIB2_STATS || defined __DOXYGEN__ -#define MIB2_STATS 0 -#endif - -#else - -#define LINK_STATS 0 -#define ETHARP_STATS 0 -#define IP_STATS 0 -#define IPFRAG_STATS 0 -#define ICMP_STATS 0 -#define IGMP_STATS 0 -#define UDP_STATS 0 -#define TCP_STATS 0 -#define MEM_STATS 0 -#define MEMP_STATS 0 -#define SYS_STATS 0 -#define LWIP_STATS_DISPLAY 0 -#define IP6_STATS 0 -#define ICMP6_STATS 0 -#define IP6_FRAG_STATS 0 -#define MLD6_STATS 0 -#define ND6_STATS 0 -#define MIB2_STATS 0 - -#endif /* LWIP_STATS */ -/** - * @} - */ - -/* - -------------------------------------- - ---------- Checksum options ---------- - -------------------------------------- - */ -/** - * @defgroup lwip_opts_checksum Checksum - * @ingroup lwip_opts_infrastructure - * @{ - */ -/** - * LWIP_CHECKSUM_CTRL_PER_NETIF==1: Checksum generation/check can be enabled/disabled - * per netif. - * ATTENTION: if enabled, the CHECKSUM_GEN_* and CHECKSUM_CHECK_* defines must be enabled! - */ -#if !defined LWIP_CHECKSUM_CTRL_PER_NETIF || defined __DOXYGEN__ -#define LWIP_CHECKSUM_CTRL_PER_NETIF 0 -#endif - -/** - * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets. - */ -#if !defined CHECKSUM_GEN_IP || defined __DOXYGEN__ -#define CHECKSUM_GEN_IP 1 -#endif - -/** - * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets. - */ -#if !defined CHECKSUM_GEN_UDP || defined __DOXYGEN__ -#define CHECKSUM_GEN_UDP 1 -#endif - -/** - * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets. - */ -#if !defined CHECKSUM_GEN_TCP || defined __DOXYGEN__ -#define CHECKSUM_GEN_TCP 1 -#endif - -/** - * CHECKSUM_GEN_ICMP==1: Generate checksums in software for outgoing ICMP packets. - */ -#if !defined CHECKSUM_GEN_ICMP || defined __DOXYGEN__ -#define CHECKSUM_GEN_ICMP 1 -#endif - -/** - * CHECKSUM_GEN_ICMP6==1: Generate checksums in software for outgoing ICMP6 packets. - */ -#if !defined CHECKSUM_GEN_ICMP6 || defined __DOXYGEN__ -#define CHECKSUM_GEN_ICMP6 1 -#endif - -/** - * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. - */ -#if !defined CHECKSUM_CHECK_IP || defined __DOXYGEN__ -#define CHECKSUM_CHECK_IP 1 -#endif - -/** - * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets. - */ -#if !defined CHECKSUM_CHECK_UDP || defined __DOXYGEN__ -#define CHECKSUM_CHECK_UDP 1 -#endif - -/** - * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets. - */ -#if !defined CHECKSUM_CHECK_TCP || defined __DOXYGEN__ -#define CHECKSUM_CHECK_TCP 1 -#endif - -/** - * CHECKSUM_CHECK_ICMP==1: Check checksums in software for incoming ICMP packets. - */ -#if !defined CHECKSUM_CHECK_ICMP || defined __DOXYGEN__ -#define CHECKSUM_CHECK_ICMP 1 -#endif - -/** - * CHECKSUM_CHECK_ICMP6==1: Check checksums in software for incoming ICMPv6 packets - */ -#if !defined CHECKSUM_CHECK_ICMP6 || defined __DOXYGEN__ -#define CHECKSUM_CHECK_ICMP6 1 -#endif - -/** - * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from - * application buffers to pbufs. - */ -#if !defined LWIP_CHECKSUM_ON_COPY || defined __DOXYGEN__ -#define LWIP_CHECKSUM_ON_COPY 0 -#endif -/** - * @} - */ - -/* - --------------------------------------- - ---------- IPv6 options --------------- - --------------------------------------- - */ -/** - * @defgroup lwip_opts_ipv6 IPv6 - * @ingroup lwip_opts - * @{ - */ -/** - * LWIP_IPV6==1: Enable IPv6 - */ -#if !defined LWIP_IPV6 || defined __DOXYGEN__ -#define LWIP_IPV6 0 -#endif - -/** - * LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif. - */ -#if !defined LWIP_IPV6_NUM_ADDRESSES || defined __DOXYGEN__ -#define LWIP_IPV6_NUM_ADDRESSES 3 -#endif - -/** - * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs - */ -#if !defined LWIP_IPV6_FORWARD || defined __DOXYGEN__ -#define LWIP_IPV6_FORWARD 0 -#endif - -/** - * LWIP_IPV6_FRAG==1: Fragment outgoing IPv6 packets that are too big. - */ -#if !defined LWIP_IPV6_FRAG || defined __DOXYGEN__ -#define LWIP_IPV6_FRAG 0 -#endif - -/** - * LWIP_IPV6_REASS==1: reassemble incoming IPv6 packets that fragmented - */ -#if !defined LWIP_IPV6_REASS || defined __DOXYGEN__ -#define LWIP_IPV6_REASS (LWIP_IPV6) -#endif - -/** - * LWIP_IPV6_SEND_ROUTER_SOLICIT==1: Send router solicitation messages during - * network startup. - */ -#if !defined LWIP_IPV6_SEND_ROUTER_SOLICIT || defined __DOXYGEN__ -#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1 -#endif - -/** - * LWIP_IPV6_AUTOCONFIG==1: Enable stateless address autoconfiguration as per RFC 4862. - */ -#if !defined LWIP_IPV6_AUTOCONFIG || defined __DOXYGEN__ -#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6) -#endif - -/** - * LWIP_IPV6_DUP_DETECT_ATTEMPTS=[0..7]: Number of duplicate address detection attempts. - */ -#if !defined LWIP_IPV6_DUP_DETECT_ATTEMPTS || defined __DOXYGEN__ -#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1 -#endif -/** - * @} - */ - -/** - * @defgroup lwip_opts_icmp6 ICMP6 - * @ingroup lwip_opts_ipv6 - * @{ - */ -/** - * LWIP_ICMP6==1: Enable ICMPv6 (mandatory per RFC) - */ -#if !defined LWIP_ICMP6 || defined __DOXYGEN__ -#define LWIP_ICMP6 (LWIP_IPV6) -#endif - -/** - * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. - */ -#if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 -#endif - -/** - * LWIP_ICMP6_HL: default hop limit for ICMPv6 messages - */ -#if !defined LWIP_ICMP6_HL || defined __DOXYGEN__ -#define LWIP_ICMP6_HL 255 -#endif -/** - * @} - */ - -/** - * @defgroup lwip_opts_mld6 Multicast listener discovery - * @ingroup lwip_opts_ipv6 - * @{ - */ -/** - * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol. - * If LWIP_IPV6 is enabled but this setting is disabled, the MAC layer must - * indiscriminately pass all inbound IPv6 multicast traffic to lwIP. - */ -#if !defined LWIP_IPV6_MLD || defined __DOXYGEN__ -#define LWIP_IPV6_MLD (LWIP_IPV6) -#endif - -/** - * MEMP_NUM_MLD6_GROUP: Max number of IPv6 multicast groups that can be joined. - * There must be enough groups so that each netif can join the solicited-node - * multicast group for each of its local addresses, plus one for MDNS if - * applicable, plus any number of groups to be joined on UDP sockets. - */ -#if !defined MEMP_NUM_MLD6_GROUP || defined __DOXYGEN__ -#define MEMP_NUM_MLD6_GROUP 4 -#endif -/** - * @} - */ - -/** - * @defgroup lwip_opts_nd6 Neighbor discovery - * @ingroup lwip_opts_ipv6 - * @{ - */ -/** - * LWIP_ND6_QUEUEING==1: queue outgoing IPv6 packets while MAC address - * is being resolved. - */ -#if !defined LWIP_ND6_QUEUEING || defined __DOXYGEN__ -#define LWIP_ND6_QUEUEING (LWIP_IPV6) -#endif - -/** - * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution. - */ -#if !defined MEMP_NUM_ND6_QUEUE || defined __DOXYGEN__ -#define MEMP_NUM_ND6_QUEUE 20 -#endif - -/** - * LWIP_ND6_NUM_NEIGHBORS: Number of entries in IPv6 neighbor cache - */ -#if !defined LWIP_ND6_NUM_NEIGHBORS || defined __DOXYGEN__ -#define LWIP_ND6_NUM_NEIGHBORS 10 -#endif - -/** - * LWIP_ND6_NUM_DESTINATIONS: number of entries in IPv6 destination cache - */ -#if !defined LWIP_ND6_NUM_DESTINATIONS || defined __DOXYGEN__ -#define LWIP_ND6_NUM_DESTINATIONS 10 -#endif - -/** - * LWIP_ND6_NUM_PREFIXES: number of entries in IPv6 on-link prefixes cache - */ -#if !defined LWIP_ND6_NUM_PREFIXES || defined __DOXYGEN__ -#define LWIP_ND6_NUM_PREFIXES 5 -#endif - -/** - * LWIP_ND6_NUM_ROUTERS: number of entries in IPv6 default router cache - */ -#if !defined LWIP_ND6_NUM_ROUTERS || defined __DOXYGEN__ -#define LWIP_ND6_NUM_ROUTERS 3 -#endif - -/** - * LWIP_ND6_MAX_MULTICAST_SOLICIT: max number of multicast solicit messages to send - * (neighbor solicit and router solicit) - */ -#if !defined LWIP_ND6_MAX_MULTICAST_SOLICIT || defined __DOXYGEN__ -#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3 -#endif - -/** - * LWIP_ND6_MAX_UNICAST_SOLICIT: max number of unicast neighbor solicitation messages - * to send during neighbor reachability detection. - */ -#if !defined LWIP_ND6_MAX_UNICAST_SOLICIT || defined __DOXYGEN__ -#define LWIP_ND6_MAX_UNICAST_SOLICIT 3 -#endif - -/** - * Unused: See ND RFC (time in milliseconds). - */ -#if !defined LWIP_ND6_MAX_ANYCAST_DELAY_TIME || defined __DOXYGEN__ -#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000 -#endif - -/** - * Unused: See ND RFC - */ -#if !defined LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT || defined __DOXYGEN__ -#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3 -#endif - -/** - * LWIP_ND6_REACHABLE_TIME: default neighbor reachable time (in milliseconds). - * May be updated by router advertisement messages. - */ -#if !defined LWIP_ND6_REACHABLE_TIME || defined __DOXYGEN__ -#define LWIP_ND6_REACHABLE_TIME 30000 -#endif - -/** - * LWIP_ND6_RETRANS_TIMER: default retransmission timer for solicitation messages - */ -#if !defined LWIP_ND6_RETRANS_TIMER || defined __DOXYGEN__ -#define LWIP_ND6_RETRANS_TIMER 1000 -#endif - -/** - * LWIP_ND6_DELAY_FIRST_PROBE_TIME: Delay before first unicast neighbor solicitation - * message is sent, during neighbor reachability detection. - */ -#if !defined LWIP_ND6_DELAY_FIRST_PROBE_TIME || defined __DOXYGEN__ -#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000 -#endif - -/** - * LWIP_ND6_ALLOW_RA_UPDATES==1: Allow Router Advertisement messages to update - * Reachable time and retransmission timers, and netif MTU. - */ -#if !defined LWIP_ND6_ALLOW_RA_UPDATES || defined __DOXYGEN__ -#define LWIP_ND6_ALLOW_RA_UPDATES 1 -#endif - -/** - * LWIP_ND6_TCP_REACHABILITY_HINTS==1: Allow TCP to provide Neighbor Discovery - * with reachability hints for connected destinations. This helps avoid sending - * unicast neighbor solicitation messages. - */ -#if !defined LWIP_ND6_TCP_REACHABILITY_HINTS || defined __DOXYGEN__ -#define LWIP_ND6_TCP_REACHABILITY_HINTS 1 -#endif - -/** - * LWIP_ND6_RDNSS_MAX_DNS_SERVERS > 0: Use IPv6 Router Advertisement Recursive - * DNS Server Option (as per RFC 6106) to copy a defined maximum number of DNS - * servers to the DNS module. - */ -#if !defined LWIP_ND6_RDNSS_MAX_DNS_SERVERS || defined __DOXYGEN__ -#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 -#endif -/** - * @} - */ - -/** - * LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful address autoconfiguration. - */ -#if !defined LWIP_IPV6_DHCP6 || defined __DOXYGEN__ -#define LWIP_IPV6_DHCP6 0 -#endif - -/* - --------------------------------------- - ---------- Hook options --------------- - --------------------------------------- - */ - -/** - * @defgroup lwip_opts_hooks Hooks - * @ingroup lwip_opts_infrastructure - * Hooks are undefined by default, define them to a function if you need them. - * @{ - */ - -/** - * LWIP_HOOK_FILENAME: Custom filename to #include in files that provide hooks. - * Declare your hook function prototypes in there, you may also #include all headers - * providing data types that are need in this file. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_FILENAME "path/to/my/lwip_hooks.h" -#endif - -/** - * LWIP_HOOK_TCP_ISN: - * Hook for generation of the Initial Sequence Number (ISN) for a new TCP - * connection. The default lwIP ISN generation algorithm is very basic and may - * allow for TCP spoofing attacks. This hook provides the means to implement - * the standardized ISN generation algorithm from RFC 6528 (see contrib/adons/tcp_isn), - * or any other desired algorithm as a replacement. - * Called from tcp_connect() and tcp_listen_input() when an ISN is needed for - * a new TCP connection, if TCP support (@ref LWIP_TCP) is enabled.\n - * Signature: u32_t my_hook_tcp_isn(const ip_addr_t* local_ip, u16_t local_port, const ip_addr_t* remote_ip, u16_t remote_port); - * - it may be necessary to use "struct ip_addr" (ip4_addr, ip6_addr) instead of "ip_addr_t" in function declarations\n - * Arguments: - * - local_ip: pointer to the local IP address of the connection - * - local_port: local port number of the connection (host-byte order) - * - remote_ip: pointer to the remote IP address of the connection - * - remote_port: remote port number of the connection (host-byte order)\n - * Return value: - * - the 32-bit Initial Sequence Number to use for the new TCP connection. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port) -#endif - -/** - * LWIP_HOOK_IP4_INPUT(pbuf, input_netif): - * - called from ip_input() (IPv4) - * - pbuf: received struct pbuf passed to ip_input() - * - input_netif: struct netif on which the packet has been received - * Return values: - * - 0: Hook has not consumed the packet, packet is processed as normal - * - != 0: Hook has consumed the packet. - * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook - * (i.e. free it when done). - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif) -#endif - -/** - * LWIP_HOOK_IP4_ROUTE(dest): - * - called from ip_route() (IPv4) - * - dest: destination IPv4 address - * Returns the destination netif or NULL if no destination netif is found. In - * that case, ip_route() continues as normal. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_IP4_ROUTE() -#endif - -/** - * LWIP_HOOK_IP4_ROUTE_SRC(dest, src): - * - source-based routing for IPv4 (see LWIP_HOOK_IP4_ROUTE(), src may be NULL) - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src) -#endif - -/** - * LWIP_HOOK_ETHARP_GET_GW(netif, dest): - * - called from etharp_output() (IPv4) - * - netif: the netif used for sending - * - dest: the destination IPv4 address - * Returns the IPv4 address of the gateway to handle the specified destination - * IPv4 address. If NULL is returned, the netif's default gateway is used. - * The returned address MUST be directly reachable on the specified netif! - * This function is meant to implement advanced IPv4 routing together with - * LWIP_HOOK_IP4_ROUTE(). The actual routing/gateway table implementation is - * not part of lwIP but can e.g. be hidden in the netif's state argument. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_ETHARP_GET_GW(netif, dest) -#endif - -/** - * LWIP_HOOK_IP6_INPUT(pbuf, input_netif): - * - called from ip6_input() (IPv6) - * - pbuf: received struct pbuf passed to ip6_input() - * - input_netif: struct netif on which the packet has been received - * Return values: - * - 0: Hook has not consumed the packet, packet is processed as normal - * - != 0: Hook has consumed the packet. - * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook - * (i.e. free it when done). - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif) -#endif - -/** - * LWIP_HOOK_IP6_ROUTE(src, dest): - * - called from ip6_route() (IPv6) - * - src: sourc IPv6 address - * - dest: destination IPv6 address - * Returns the destination netif or NULL if no destination netif is found. In - * that case, ip6_route() continues as normal. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_IP6_ROUTE(src, dest) -#endif - -/** - * LWIP_HOOK_ND6_GET_GW(netif, dest): - * - called from nd6_get_next_hop_entry() (IPv6) - * - netif: the netif used for sending - * - dest: the destination IPv6 address - * Returns the IPv6 address of the next hop to handle the specified destination - * IPv6 address. If NULL is returned, a NDP-discovered router is used instead. - * The returned address MUST be directly reachable on the specified netif! - * This function is meant to implement advanced IPv6 routing together with - * LWIP_HOOK_IP6_ROUTE(). The actual routing/gateway table implementation is - * not part of lwIP but can e.g. be hidden in the netif's state argument. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_ND6_GET_GW(netif, dest) -#endif - -/** - * LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr): - * - called from ethernet_input() if VLAN support is enabled - * - netif: struct netif on which the packet has been received - * - eth_hdr: struct eth_hdr of the packet - * - vlan_hdr: struct eth_vlan_hdr of the packet - * Return values: - * - 0: Packet must be dropped. - * - != 0: Packet must be accepted. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr) -#endif - -/** - * LWIP_HOOK_VLAN_SET: - * Hook can be used to set prio_vid field of vlan_hdr. If you need to store data - * on per-netif basis to implement this callback, see @ref netif_cd. - * Called from ethernet_output() if VLAN support (@ref ETHARP_SUPPORT_VLAN) is enabled.\n - * Signature: s32_t my_hook_vlan_set(struct netif* netif, struct pbuf* pbuf, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type);\n - * Arguments: - * - netif: struct netif that the packet will be sent through - * - p: struct pbuf packet to be sent - * - src: source eth address - * - dst: destination eth address - * - eth_type: ethernet type to packet to be sent\n - * - * - * Return values: - * - <0: Packet shall not contain VLAN header. - * - 0 <= return value <= 0xFFFF: Packet shall contain VLAN header. Return value is prio_vid in host byte order. - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type) -#endif - -/** - * LWIP_HOOK_MEMP_AVAILABLE(memp_t_type): - * - called from memp_free() when a memp pool was empty and an item is now available - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type) -#endif - -/** - * LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif): - * Called from ethernet_input() when an unknown eth type is encountered. - * Return ERR_OK if packet is accepted, any error code otherwise. - * Payload points to ethernet header! - */ -#ifdef __DOXYGEN__ -#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) -#endif -/** - * @} - */ - -/* - --------------------------------------- - ---------- Debugging options ---------- - --------------------------------------- - */ -/** - * @defgroup lwip_opts_debugmsg Debug messages - * @ingroup lwip_opts_debug - * @{ - */ -/** - * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is - * compared against this value. If it is smaller, then debugging - * messages are written. - * @see debugging_levels - */ -#if !defined LWIP_DBG_MIN_LEVEL || defined __DOXYGEN__ -#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL -#endif - -/** - * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable - * debug messages of certain types. - * @see debugging_levels - */ -#if !defined LWIP_DBG_TYPES_ON || defined __DOXYGEN__ -#define LWIP_DBG_TYPES_ON LWIP_DBG_ON -#endif - -/** - * ETHARP_DEBUG: Enable debugging in etharp.c. - */ -#if !defined ETHARP_DEBUG || defined __DOXYGEN__ -#define ETHARP_DEBUG LWIP_DBG_OFF -#endif - -/** - * NETIF_DEBUG: Enable debugging in netif.c. - */ -#if !defined NETIF_DEBUG || defined __DOXYGEN__ -#define NETIF_DEBUG LWIP_DBG_OFF -#endif - -/** - * PBUF_DEBUG: Enable debugging in pbuf.c. - */ -#if !defined PBUF_DEBUG || defined __DOXYGEN__ -#define PBUF_DEBUG LWIP_DBG_OFF -#endif - -/** - * API_LIB_DEBUG: Enable debugging in api_lib.c. - */ -#if !defined API_LIB_DEBUG || defined __DOXYGEN__ -#define API_LIB_DEBUG LWIP_DBG_OFF -#endif - -/** - * API_MSG_DEBUG: Enable debugging in api_msg.c. - */ -#if !defined API_MSG_DEBUG || defined __DOXYGEN__ -#define API_MSG_DEBUG LWIP_DBG_OFF -#endif - -/** - * SOCKETS_DEBUG: Enable debugging in sockets.c. - */ -#if !defined SOCKETS_DEBUG || defined __DOXYGEN__ -#define SOCKETS_DEBUG LWIP_DBG_OFF -#endif - -/** - * ICMP_DEBUG: Enable debugging in icmp.c. - */ -#if !defined ICMP_DEBUG || defined __DOXYGEN__ -#define ICMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * IGMP_DEBUG: Enable debugging in igmp.c. - */ -#if !defined IGMP_DEBUG || defined __DOXYGEN__ -#define IGMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * INET_DEBUG: Enable debugging in inet.c. - */ -#if !defined INET_DEBUG || defined __DOXYGEN__ -#define INET_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP_DEBUG: Enable debugging for IP. - */ -#if !defined IP_DEBUG || defined __DOXYGEN__ -#define IP_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass. - */ -#if !defined IP_REASS_DEBUG || defined __DOXYGEN__ -#define IP_REASS_DEBUG LWIP_DBG_OFF -#endif - -/** - * RAW_DEBUG: Enable debugging in raw.c. - */ -#if !defined RAW_DEBUG || defined __DOXYGEN__ -#define RAW_DEBUG LWIP_DBG_OFF -#endif - -/** - * MEM_DEBUG: Enable debugging in mem.c. - */ -#if !defined MEM_DEBUG || defined __DOXYGEN__ -#define MEM_DEBUG LWIP_DBG_OFF -#endif - -/** - * MEMP_DEBUG: Enable debugging in memp.c. - */ -#if !defined MEMP_DEBUG || defined __DOXYGEN__ -#define MEMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SYS_DEBUG: Enable debugging in sys.c. - */ -#if !defined SYS_DEBUG || defined __DOXYGEN__ -#define SYS_DEBUG LWIP_DBG_OFF -#endif - -/** - * TIMERS_DEBUG: Enable debugging in timers.c. - */ -#if !defined TIMERS_DEBUG || defined __DOXYGEN__ -#define TIMERS_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_DEBUG: Enable debugging for TCP. - */ -#if !defined TCP_DEBUG || defined __DOXYGEN__ -#define TCP_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug. - */ -#if !defined TCP_INPUT_DEBUG || defined __DOXYGEN__ -#define TCP_INPUT_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit. - */ -#if !defined TCP_FR_DEBUG || defined __DOXYGEN__ -#define TCP_FR_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_RTO_DEBUG: Enable debugging in TCP for retransmit - * timeout. - */ -#if !defined TCP_RTO_DEBUG || defined __DOXYGEN__ -#define TCP_RTO_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_CWND_DEBUG: Enable debugging for TCP congestion window. - */ -#if !defined TCP_CWND_DEBUG || defined __DOXYGEN__ -#define TCP_CWND_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating. - */ -#if !defined TCP_WND_DEBUG || defined __DOXYGEN__ -#define TCP_WND_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions. - */ -#if !defined TCP_OUTPUT_DEBUG || defined __DOXYGEN__ -#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_RST_DEBUG: Enable debugging for TCP with the RST message. - */ -#if !defined TCP_RST_DEBUG || defined __DOXYGEN__ -#define TCP_RST_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths. - */ -#if !defined TCP_QLEN_DEBUG || defined __DOXYGEN__ -#define TCP_QLEN_DEBUG LWIP_DBG_OFF -#endif - -/** - * UDP_DEBUG: Enable debugging in UDP. - */ -#if !defined UDP_DEBUG || defined __DOXYGEN__ -#define UDP_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCPIP_DEBUG: Enable debugging in tcpip.c. - */ -#if !defined TCPIP_DEBUG || defined __DOXYGEN__ -#define TCPIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SLIP_DEBUG: Enable debugging in slipif.c. - */ -#if !defined SLIP_DEBUG || defined __DOXYGEN__ -#define SLIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * DHCP_DEBUG: Enable debugging in dhcp.c. - */ -#if !defined DHCP_DEBUG || defined __DOXYGEN__ -#define DHCP_DEBUG LWIP_DBG_OFF -#endif - -/** - * AUTOIP_DEBUG: Enable debugging in autoip.c. - */ -#if !defined AUTOIP_DEBUG || defined __DOXYGEN__ -#define AUTOIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * DNS_DEBUG: Enable debugging for DNS. - */ -#if !defined DNS_DEBUG || defined __DOXYGEN__ -#define DNS_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP6_DEBUG: Enable debugging for IPv6. - */ -#if !defined IP6_DEBUG || defined __DOXYGEN__ -#define IP6_DEBUG LWIP_DBG_OFF -#endif -/** - * @} - */ - -/* - -------------------------------------------------- - ---------- Performance tracking options ---------- - -------------------------------------------------- - */ -/** - * @defgroup lwip_opts_perf Performance - * @ingroup lwip_opts_debug - * @{ - */ -/** - * LWIP_PERF: Enable performance testing for lwIP - * (if enabled, arch/perf.h is included) - */ -#if !defined LWIP_PERF || defined __DOXYGEN__ -#define LWIP_PERF 0 -#endif -/** - * @} - */ - -#endif /* LWIP_HDR_OPT_H */ diff --git a/include/net/pbuf.h b/include/net/pbuf.h deleted file mode 100644 index 850c0c5..0000000 --- a/include/net/pbuf.h +++ /dev/null @@ -1,263 +0,0 @@ -/** - * @file - * pbuf API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef LWIP_HDR_PBUF_H -#define LWIP_HDR_PBUF_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** LWIP_SUPPORT_CUSTOM_PBUF==1: Custom pbufs behave much like their pbuf type - * but they are allocated by external code (initialised by calling - * pbuf_alloced_custom()) and when pbuf_free gives up their last reference, they - * are freed by calling pbuf_custom->custom_free_function(). - * Currently, the pbuf_custom code is only needed for one specific configuration - * of IP_FRAG, unless required by external driver/application code. */ -#ifndef LWIP_SUPPORT_CUSTOM_PBUF -#define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)) -#endif - -/* @todo: We need a mechanism to prevent wasting memory in every pbuf - (TCP vs. UDP, IPv4 vs. IPv6: UDP/IPv4 packets may waste up to 28 bytes) */ - -#define PBUF_TRANSPORT_HLEN 20 -#if LWIP_IPV6 -#define PBUF_IP_HLEN 40 -#else -#define PBUF_IP_HLEN 20 -#endif - -/** - * @ingroup pbuf - * Enumeration of pbuf layers - */ -typedef enum { - /** Includes spare room for transport layer header, e.g. UDP header. - * Use this if you intend to pass the pbuf to functions like udp_send(). - */ - PBUF_TRANSPORT, - /** Includes spare room for IP header. - * Use this if you intend to pass the pbuf to functions like raw_send(). - */ - PBUF_IP, - /** Includes spare room for link layer header (ethernet header). - * Use this if you intend to pass the pbuf to functions like ethernet_output(). - * @see PBUF_LINK_HLEN - */ - PBUF_LINK, - /** Includes spare room for additional encapsulation header before ethernet - * headers (e.g. 802.11). - * Use this if you intend to pass the pbuf to functions like netif->linkoutput(). - * @see PBUF_LINK_ENCAPSULATION_HLEN - */ - PBUF_RAW_TX, - /** Use this for input packets in a netif driver when calling netif->input() - * in the most common case - ethernet-layer netif driver. */ - PBUF_RAW -} pbuf_layer; - -/** - * @ingroup pbuf - * Enumeration of pbuf types - */ -typedef enum { - /** pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload - are allocated in one piece of contiguous memory (so the first payload byte - can be calculated from struct pbuf). - pbuf_alloc() allocates PBUF_RAM pbufs as unchained pbufs (although that might - change in future versions). - This should be used for all OUTGOING packets (TX).*/ - PBUF_RAM, - /** pbuf data is stored in ROM, i.e. struct pbuf and its payload are located in - totally different memory areas. Since it points to ROM, payload does not - have to be copied when queued for transmission. */ - PBUF_ROM, - /** pbuf comes from the pbuf pool. Much like PBUF_ROM but payload might change - so it has to be duplicated when queued before transmitting, depending on - who has a 'ref' to it. */ - PBUF_REF, - /** pbuf payload refers to RAM. This one comes from a pool and should be used - for RX. Payload can be chained (scatter-gather RX) but like PBUF_RAM, struct - pbuf and its payload are allocated in one piece of contiguous memory (so - the first payload byte can be calculated from struct pbuf). - Don't use this for TX, if the pool becomes empty e.g. because of TCP queuing, - you are unable to receive TCP acks! */ - PBUF_POOL -} pbuf_type; - - -/** indicates this packet's data should be immediately passed to the application */ -#define PBUF_FLAG_PUSH 0x01U -/** indicates this is a custom pbuf: pbuf_free calls pbuf_custom->custom_free_function() - when the last reference is released (plus custom PBUF_RAM cannot be trimmed) */ -#define PBUF_FLAG_IS_CUSTOM 0x02U -/** indicates this pbuf is UDP multicast to be looped back */ -#define PBUF_FLAG_MCASTLOOP 0x04U -/** indicates this pbuf was received as link-level broadcast */ -#define PBUF_FLAG_LLBCAST 0x08U -/** indicates this pbuf was received as link-level multicast */ -#define PBUF_FLAG_LLMCAST 0x10U -/** indicates this pbuf includes a TCP FIN flag */ -#define PBUF_FLAG_TCP_FIN 0x20U - -/** Main packet buffer struct */ -struct pbuf { - /** next pbuf in singly linked pbuf chain */ - struct pbuf *next; - - /** pointer to the actual data in the buffer */ - void *payload; - - /** - * total length of this buffer and all next buffers in chain - * belonging to the same packet. - * - * For non-queue packet chains this is the invariant: - * p->tot_len == p->len + (p->next? p->next->tot_len: 0) - */ - u16_t tot_len; - - /** length of this buffer */ - u16_t len; - - /** pbuf_type as u8_t instead of enum to save space */ - u8_t /*pbuf_type*/ type; - - /** misc flags */ - u8_t flags; - - /** - * the reference count always equals the number of pointers - * that refer to this pbuf. This can be pointers from an application, - * the stack itself, or pbuf->next pointers from a chain. - */ - u16_t ref; -}; - - -/** Helper struct for const-correctness only. - * The only meaning of this one is to provide a const payload pointer - * for PBUF_ROM type. - */ -struct pbuf_rom { - /** next pbuf in singly linked pbuf chain */ - struct pbuf *next; - - /** pointer to the actual data in the buffer */ - const void *payload; -}; - -#if LWIP_SUPPORT_CUSTOM_PBUF -/** Prototype for a function to free a custom pbuf */ -typedef void (*pbuf_free_custom_fn)(struct pbuf *p); - -/** A custom pbuf: like a pbuf, but following a function pointer to free it. */ -struct pbuf_custom { - /** The actual pbuf */ - struct pbuf pbuf; - /** This function is called when pbuf_free deallocates this pbuf(_custom) */ - pbuf_free_custom_fn custom_free_function; -}; -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - -/** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */ -#ifndef PBUF_POOL_FREE_OOSEQ -#define PBUF_POOL_FREE_OOSEQ 1 -#endif /* PBUF_POOL_FREE_OOSEQ */ -#if LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ -extern volatile u8_t pbuf_free_ooseq_pending; -void pbuf_free_ooseq(void); -/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() - at regular intervals from main level to check if ooseq pbufs need to be - freed! */ -#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \ - /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \ - ooseq queued pbufs now */ \ - pbuf_free_ooseq(); }}while(0) -#else /* LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ */ - /* Otherwise declare an empty PBUF_CHECK_FREE_OOSEQ */ - #define PBUF_CHECK_FREE_OOSEQ() -#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ*/ - -/* Initializes the pbuf module. This call is empty for now, but may not be in future. */ -#define pbuf_init() - -struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); -#if LWIP_SUPPORT_CUSTOM_PBUF -struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, - struct pbuf_custom *p, void *payload_mem, - u16_t payload_mem_len); -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ -void pbuf_realloc(struct pbuf *p, u16_t size); -u8_t pbuf_header(struct pbuf *p, s16_t header_size); -u8_t pbuf_header_force(struct pbuf *p, s16_t header_size); -void pbuf_ref(struct pbuf *p); -u8_t pbuf_free(struct pbuf *p); -u16_t pbuf_clen(const struct pbuf *p); -void pbuf_cat(struct pbuf *head, struct pbuf *tail); -void pbuf_chain(struct pbuf *head, struct pbuf *tail); -struct pbuf *pbuf_dechain(struct pbuf *p); -err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); -u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); -err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); -err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset); -struct pbuf *pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset); -struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); -#if LWIP_CHECKSUM_ON_COPY -err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, - u16_t len, u16_t *chksum); -#endif /* LWIP_CHECKSUM_ON_COPY */ -#if LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE -void pbuf_split_64k(struct pbuf *p, struct pbuf **rest); -#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */ - -u8_t pbuf_get_at(const struct pbuf* p, u16_t offset); -int pbuf_try_get_at(const struct pbuf* p, u16_t offset); -void pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data); -u16_t pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n); -u16_t pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset); -u16_t pbuf_strstr(const struct pbuf* p, const char* substr); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PBUF_H */ diff --git a/include/net/priv/api_msg.h b/include/net/priv/api_msg.h deleted file mode 100644 index 631379d..0000000 --- a/include/net/priv/api_msg.h +++ /dev/null @@ -1,216 +0,0 @@ -/** - * @file - * netconn API lwIP internal implementations (do not use in application code) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_API_MSG_H -#define LWIP_HDR_API_MSG_H - -#include "net/opt.h" - -#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ -/* Note: Netconn API is always available when sockets are enabled - - * sockets are implemented on top of them */ - -#include "net/arch.h" -#include "net/ip_addr.h" -#include "net/err.h" -#include "net/sys.h" -#include "net/igmp.h" -#include "net/api.h" -#include "net/priv/tcpip_priv.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_MPU_COMPATIBLE -#if LWIP_NETCONN_SEM_PER_THREAD -#define API_MSG_M_DEF_SEM(m) *m -#else -#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m) -#endif -#else /* LWIP_MPU_COMPATIBLE */ -#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m) -#endif /* LWIP_MPU_COMPATIBLE */ - -/* For the netconn API, these values are use as a bitmask! */ -#define NETCONN_SHUT_RD 1 -#define NETCONN_SHUT_WR 2 -#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) - -/* IP addresses and port numbers are expected to be in - * the same byte order as in the corresponding pcb. - */ -/** This struct includes everything that is necessary to execute a function - for a netconn in another thread context (mainly used to process netconns - in the tcpip_thread context to be thread safe). */ -struct api_msg { - /** The netconn which to process - always needed: it includes the semaphore - which is used to block the application thread until the function finished. */ - struct netconn *conn; - /** The return value of the function executed in tcpip_thread. */ - err_t err; - /** Depending on the executed function, one of these union members is used */ - union { - /** used for lwip_netconn_do_send */ - struct netbuf *b; - /** used for lwip_netconn_do_newconn */ - struct { - u8_t proto; - } n; - /** used for lwip_netconn_do_bind and lwip_netconn_do_connect */ - struct { - API_MSG_M_DEF_C(ip_addr_t, ipaddr); - u16_t port; - } bc; - /** used for lwip_netconn_do_getaddr */ - struct { - ip_addr_t API_MSG_M_DEF(ipaddr); - u16_t API_MSG_M_DEF(port); - u8_t local; - } ad; - /** used for lwip_netconn_do_write */ - struct { - const void *dataptr; - size_t len; - u8_t apiflags; -#if LWIP_SO_SNDTIMEO - u32_t time_started; -#endif /* LWIP_SO_SNDTIMEO */ - } w; - /** used for lwip_netconn_do_recv */ - struct { - u32_t len; - } r; -#if LWIP_TCP - /** used for lwip_netconn_do_close (/shutdown) */ - struct { - u8_t shut; -#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER - u32_t time_started; -#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */ - u8_t polls_left; -#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */ - } sd; -#endif /* LWIP_TCP */ -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) - /** used for lwip_netconn_do_join_leave_group */ - struct { - API_MSG_M_DEF_C(ip_addr_t, multiaddr); - API_MSG_M_DEF_C(ip_addr_t, netif_addr); - enum netconn_igmp join_or_leave; - } jl; -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ -#if TCP_LISTEN_BACKLOG - struct { - u8_t backlog; - } lb; -#endif /* TCP_LISTEN_BACKLOG */ - } msg; -#if LWIP_NETCONN_SEM_PER_THREAD - sys_sem_t* op_completed_sem; -#endif /* LWIP_NETCONN_SEM_PER_THREAD */ -}; - -#if LWIP_NETCONN_SEM_PER_THREAD -#define LWIP_API_MSG_SEM(msg) ((msg)->op_completed_sem) -#else /* LWIP_NETCONN_SEM_PER_THREAD */ -#define LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed) -#endif /* LWIP_NETCONN_SEM_PER_THREAD */ - - -#if LWIP_DNS -/** As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn, - it has its own struct (to avoid struct api_msg getting bigger than necessary). - lwip_netconn_do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg - (see netconn_gethostbyname). */ -struct dns_api_msg { - /** Hostname to query or dotted IP address string */ -#if LWIP_MPU_COMPATIBLE - char name[DNS_MAX_NAME_LENGTH]; -#else /* LWIP_MPU_COMPATIBLE */ - const char *name; -#endif /* LWIP_MPU_COMPATIBLE */ - /** The resolved address is stored here */ - ip_addr_t API_MSG_M_DEF(addr); -#if LWIP_IPV4 && LWIP_IPV6 - /** Type of resolve call */ - u8_t dns_addrtype; -#endif /* LWIP_IPV4 && LWIP_IPV6 */ - /** This semaphore is posted when the name is resolved, the application thread - should wait on it. */ - sys_sem_t API_MSG_M_DEF_SEM(sem); - /** Errors are given back here */ - err_t API_MSG_M_DEF(err); -}; -#endif /* LWIP_DNS */ - -#if LWIP_TCP -extern u8_t netconn_aborted; -#endif /* LWIP_TCP */ - -void lwip_netconn_do_newconn (void *m); -void lwip_netconn_do_delconn (void *m); -void lwip_netconn_do_bind (void *m); -void lwip_netconn_do_connect (void *m); -void lwip_netconn_do_disconnect (void *m); -void lwip_netconn_do_listen (void *m); -void lwip_netconn_do_send (void *m); -void lwip_netconn_do_recv (void *m); -#if TCP_LISTEN_BACKLOG -void lwip_netconn_do_accepted (void *m); -#endif /* TCP_LISTEN_BACKLOG */ -void lwip_netconn_do_write (void *m); -void lwip_netconn_do_getaddr (void *m); -void lwip_netconn_do_close (void *m); -void lwip_netconn_do_shutdown (void *m); -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -void lwip_netconn_do_join_leave_group(void *m); -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ - -#if LWIP_DNS -void lwip_netconn_do_gethostbyname(void *arg); -#endif /* LWIP_DNS */ - -struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); -void netconn_free(struct netconn *conn); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN || LWIP_SOCKET */ - -#endif /* LWIP_HDR_API_MSG_H */ diff --git a/include/net/priv/memp_priv.h b/include/net/priv/memp_priv.h deleted file mode 100644 index 9a1aa71..0000000 --- a/include/net/priv/memp_priv.h +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @file - * memory pools lwIP internal implementations (do not use in application code) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef LWIP_HDR_MEMP_PRIV_H -#define LWIP_HDR_MEMP_PRIV_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#if MEMP_OVERFLOW_CHECK -/* if MEMP_OVERFLOW_CHECK is turned on, we reserve some bytes at the beginning - * and at the end of each element, initialize them as 0xcd and check - * them later. */ -/* If MEMP_OVERFLOW_CHECK is >= 2, on every call to memp_malloc or memp_free, - * every single element in each pool is checked! - * This is VERY SLOW but also very helpful. */ -/* MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in - * lwipopts.h to change the amount reserved for checking. */ -#ifndef MEMP_SANITY_REGION_BEFORE -#define MEMP_SANITY_REGION_BEFORE 16 -#endif /* MEMP_SANITY_REGION_BEFORE*/ -#if MEMP_SANITY_REGION_BEFORE > 0 -#define MEMP_SANITY_REGION_BEFORE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_BEFORE) -#else -#define MEMP_SANITY_REGION_BEFORE_ALIGNED 0 -#endif /* MEMP_SANITY_REGION_BEFORE*/ -#ifndef MEMP_SANITY_REGION_AFTER -#define MEMP_SANITY_REGION_AFTER 16 -#endif /* MEMP_SANITY_REGION_AFTER*/ -#if MEMP_SANITY_REGION_AFTER > 0 -#define MEMP_SANITY_REGION_AFTER_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_AFTER) -#else -#define MEMP_SANITY_REGION_AFTER_ALIGNED 0 -#endif /* MEMP_SANITY_REGION_AFTER*/ - -/* MEMP_SIZE: save space for struct memp and for sanity check */ -#define MEMP_SIZE (LWIP_MEM_ALIGN_SIZE(sizeof(struct memp)) + MEMP_SANITY_REGION_BEFORE_ALIGNED) -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x) + MEMP_SANITY_REGION_AFTER_ALIGNED) - -#else /* MEMP_OVERFLOW_CHECK */ - -/* No sanity checks - * We don't need to preserve the struct memp while not allocated, so we - * can save a little space and set MEMP_SIZE to 0. - */ -#define MEMP_SIZE 0 -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) - -#endif /* MEMP_OVERFLOW_CHECK */ - -#if !MEMP_MEM_MALLOC || MEMP_OVERFLOW_CHECK -struct memp { - struct memp *next; -#if MEMP_OVERFLOW_CHECK - const char *file; - int line; -#endif /* MEMP_OVERFLOW_CHECK */ -}; -#endif /* !MEMP_MEM_MALLOC || MEMP_OVERFLOW_CHECK */ - -#if MEM_USE_POOLS && MEMP_USE_CUSTOM_POOLS -/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ -typedef enum { - /* Get the first (via: - MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ - MEMP_POOL_HELPER_FIRST = ((u8_t) -#define LWIP_MEMPOOL(name,num,size,desc) -#define LWIP_MALLOC_MEMPOOL_START 1 -#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 -#define LWIP_MALLOC_MEMPOOL_END -#include - ) , - /* Get the last (via: - MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ - MEMP_POOL_HELPER_LAST = ((u8_t) -#define LWIP_MEMPOOL(name,num,size,desc) -#define LWIP_MALLOC_MEMPOOL_START -#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * -#define LWIP_MALLOC_MEMPOOL_END 1 -#include - ) -} memp_pool_helper_t; - -/* The actual start and stop values are here (cast them over) - We use this helper type and these defines so we can avoid using const memp_t values */ -#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) -#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) -#endif /* MEM_USE_POOLS && MEMP_USE_CUSTOM_POOLS */ - -/** Memory pool descriptor */ -struct memp_desc { -#if defined(LWIP_DEBUG) || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY - /** Textual description */ - const char *desc; -#endif /* LWIP_DEBUG || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY */ -#if MEMP_STATS - /** Statistics */ - struct stats_mem *stats; -#endif - - /** Element size */ - u16_t size; - -#if !MEMP_MEM_MALLOC - /** Number of elements */ - u16_t num; - - /** Base address */ - u8_t *base; - - /** First free element of each pool. Elements form a linked list. */ - struct memp **tab; -#endif /* MEMP_MEM_MALLOC */ -}; - -#if defined(LWIP_DEBUG) || MEMP_OVERFLOW_CHECK || LWIP_STATS_DISPLAY -#define DECLARE_LWIP_MEMPOOL_DESC(desc) (desc), -#else -#define DECLARE_LWIP_MEMPOOL_DESC(desc) -#endif - -#if MEMP_STATS -#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name) static struct stats_mem name; -#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name) &name, -#else -#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name) -#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name) -#endif - -void memp_init_pool(const struct memp_desc *desc); - -#if MEMP_OVERFLOW_CHECK -void *memp_malloc_pool_fn(const struct memp_desc* desc, const char* file, const int line); -#define memp_malloc_pool(d) memp_malloc_pool_fn((d), __FILE__, __LINE__) -#else -void *memp_malloc_pool(const struct memp_desc *desc); -#endif -void memp_free_pool(const struct memp_desc* desc, void *mem); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_MEMP_PRIV_H */ diff --git a/include/net/priv/memp_std.h b/include/net/priv/memp_std.h deleted file mode 100644 index ce9fd50..0000000 --- a/include/net/priv/memp_std.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @file - * lwIP internal memory pools (do not use in application code) - * This file is deliberately included multiple times: once with empty - * definition of LWIP_MEMPOOL() to handle all includes and multiple times - * to build up various lists of mem pools. - */ - -/* - * SETUP: Make sure we define everything we will need. - * - * We have create three types of pools: - * 1) MEMPOOL - standard pools - * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c - * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct - * - * If the include'r doesn't require any special treatment of each of the types - * above, then will declare #2 & #3 to be just standard mempools. - */ -#ifndef LWIP_MALLOC_MEMPOOL -/* This treats "malloc pools" just like any other pool. - The pools are a little bigger to provide 'size' as the amount of user data. */ -#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size) -#define LWIP_MALLOC_MEMPOOL_START -#define LWIP_MALLOC_MEMPOOL_END -#endif /* LWIP_MALLOC_MEMPOOL */ - -#ifndef LWIP_PBUF_MEMPOOL -/* This treats "pbuf pools" just like any other pool. - * Allocates buffers for a pbuf struct AND a payload size */ -#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc) -#endif /* LWIP_PBUF_MEMPOOL */ - - -/* - * A list of internal pools used by LWIP. - * - * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description) - * creates a pool name MEMP_pool_name. description is used in stats.c - */ -#if LWIP_RAW -LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB") -#endif /* LWIP_RAW */ - -#if LWIP_UDP -LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB") -#endif /* LWIP_UDP */ - -#if LWIP_TCP -LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") -LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN") -LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG") -#endif /* LWIP_TCP */ - -#if LWIP_IPV4 && IP_REASSEMBLY -LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA") -#endif /* LWIP_IPV4 && IP_REASSEMBLY */ -#if (IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG) -LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF") -#endif /* IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF || (LWIP_IPV6 && LWIP_IPV6_FRAG) */ - -#if LWIP_NETCONN || LWIP_SOCKET -LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF") -LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN") -#endif /* LWIP_NETCONN || LWIP_SOCKET */ - -#if NO_SYS==0 -LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API") -#if LWIP_MPU_COMPATIBLE -LWIP_MEMPOOL(API_MSG, MEMP_NUM_API_MSG, sizeof(struct api_msg), "API_MSG") -#if LWIP_DNS -LWIP_MEMPOOL(DNS_API_MSG, MEMP_NUM_DNS_API_MSG, sizeof(struct dns_api_msg), "DNS_API_MSG") -#endif -#if LWIP_SOCKET && !LWIP_TCPIP_CORE_LOCKING -LWIP_MEMPOOL(SOCKET_SETGETSOCKOPT_DATA, MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA, sizeof(struct lwip_setgetsockopt_data), "SOCKET_SETGETSOCKOPT_DATA") -#endif -#if LWIP_NETIF_API -LWIP_MEMPOOL(NETIFAPI_MSG, MEMP_NUM_NETIFAPI_MSG, sizeof(struct netifapi_msg), "NETIFAPI_MSG") -#endif -#endif /* LWIP_MPU_COMPATIBLE */ -#if !LWIP_TCPIP_CORE_LOCKING_INPUT -LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT") -#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ -#endif /* NO_SYS==0 */ - -#if LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING -LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE") -#endif /* LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING */ - -#if LWIP_IGMP -LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP") -#endif /* LWIP_IGMP */ - -#if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM -LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT") -#endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */ - -#if LWIP_DNS && LWIP_SOCKET -LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB") -#endif /* LWIP_DNS && LWIP_SOCKET */ -#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC -LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST") -#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -#if LWIP_IPV6 && LWIP_ND6_QUEUEING -LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE") -#endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */ - -#if LWIP_IPV6 && LWIP_IPV6_REASS -LWIP_MEMPOOL(IP6_REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip6_reassdata), "IP6_REASSDATA") -#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ - -#if LWIP_IPV6 && LWIP_IPV6_MLD -LWIP_MEMPOOL(MLD6_GROUP, MEMP_NUM_MLD6_GROUP, sizeof(struct mld_group), "MLD6_GROUP") -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - - -/* - * A list of pools of pbuf's used by LWIP. - * - * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description) - * creates a pool name MEMP_pool_name. description is used in stats.c - * This allocates enough space for the pbuf struct and a payload. - * (Example: pbuf_payload_size=0 allocates only size for the struct) - */ -LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM") -LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL") - - -/* - * Allow for user-defined pools; this must be explicitly set in lwipopts.h - * since the default is to NOT look for lwippools.h - */ -#if MEMP_USE_CUSTOM_POOLS -#include "lwippools.h" -#endif /* MEMP_USE_CUSTOM_POOLS */ - -/* - * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later - * (#undef is ignored for something that is not defined) - */ -#undef LWIP_MEMPOOL -#undef LWIP_MALLOC_MEMPOOL -#undef LWIP_MALLOC_MEMPOOL_START -#undef LWIP_MALLOC_MEMPOOL_END -#undef LWIP_PBUF_MEMPOOL diff --git a/include/net/priv/nd6_priv.h b/include/net/priv/nd6_priv.h deleted file mode 100644 index a057a4d..0000000 --- a/include/net/priv/nd6_priv.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @file - * - * Neighbor discovery and stateless address autoconfiguration for IPv6. - * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 - * (Address autoconfiguration). - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_ND6_PRIV_H -#define LWIP_HDR_ND6_PRIV_H - -#include "net/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/ip6_addr.h" -#include "net/netif.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_ND6_QUEUEING -/** struct for queueing outgoing packets for unknown address - * defined here to be accessed by memp.h - */ -struct nd6_q_entry { - struct nd6_q_entry *next; - struct pbuf *p; -}; -#endif /* LWIP_ND6_QUEUEING */ - -/** Struct for tables. */ -struct nd6_neighbor_cache_entry { - ip6_addr_t next_hop_address; - struct netif *netif; - u8_t lladdr[NETIF_MAX_HWADDR_LEN]; - /*u32_t pmtu;*/ -#if LWIP_ND6_QUEUEING - /** Pointer to queue of pending outgoing packets on this entry. */ - struct nd6_q_entry *q; -#else /* LWIP_ND6_QUEUEING */ - /** Pointer to a single pending outgoing packet on this entry. */ - struct pbuf *q; -#endif /* LWIP_ND6_QUEUEING */ - u8_t state; - u8_t isrouter; - union { - u32_t reachable_time; /* in ms since value may originate from network packet */ - u32_t delay_time; /* ticks (ND6_TMR_INTERVAL) */ - u32_t probes_sent; - u32_t stale_time; /* ticks (ND6_TMR_INTERVAL) */ - } counter; -}; - -struct nd6_destination_cache_entry { - ip6_addr_t destination_addr; - ip6_addr_t next_hop_addr; - u16_t pmtu; - u32_t age; -}; - -struct nd6_prefix_list_entry { - ip6_addr_t prefix; - struct netif *netif; - u32_t invalidation_timer; /* in ms since value may originate from network packet */ -#if LWIP_IPV6_AUTOCONFIG - u8_t flags; -#define ND6_PREFIX_AUTOCONFIG_AUTONOMOUS 0x01 -#define ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED 0x02 -#define ND6_PREFIX_AUTOCONFIG_ADDRESS_DUPLICATE 0x04 -#endif /* LWIP_IPV6_AUTOCONFIG */ -}; - -struct nd6_router_list_entry { - struct nd6_neighbor_cache_entry *neighbor_entry; - u32_t invalidation_timer; /* in ms since value may originate from network packet */ - u8_t flags; -}; - -enum nd6_neighbor_cache_entry_state { - ND6_NO_ENTRY = 0, - ND6_INCOMPLETE, - ND6_REACHABLE, - ND6_STALE, - ND6_DELAY, - ND6_PROBE -}; - -/* Router tables. */ -/* @todo make these static? and entries accessible through API? */ -extern struct nd6_neighbor_cache_entry neighbor_cache[]; -extern struct nd6_destination_cache_entry destination_cache[]; -extern struct nd6_prefix_list_entry prefix_list[]; -extern struct nd6_router_list_entry default_router_list[]; - -/* Default values, can be updated by a RA message. */ -extern u32_t reachable_time; -extern u32_t retrans_timer; - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* LWIP_HDR_ND6_PRIV_H */ diff --git a/include/net/priv/tcp_priv.h b/include/net/priv/tcp_priv.h deleted file mode 100644 index 3c8cf67..0000000 --- a/include/net/priv/tcp_priv.h +++ /dev/null @@ -1,507 +0,0 @@ -/** - * @file - * TCP internal implementations (do not use in application code) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_TCP_PRIV_H -#define LWIP_HDR_TCP_PRIV_H - -#include "net/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "net/tcp.h" -#include "net/mem.h" -#include "net/pbuf.h" -#include "net/ip.h" -#include "net/icmp.h" -#include "net/err.h" -#include "net/ip6.h" -#include "net/ip6_addr.h" -#include "net/prot/tcp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Functions for interfacing with TCP: */ - -/* Lower layer interface to TCP: */ -void tcp_init (void); /* Initialize this module. */ -void tcp_tmr (void); /* Must be called every - TCP_TMR_INTERVAL - ms. (Typically 250 ms). */ -/* It is also possible to call these two functions at the right - intervals (instead of calling tcp_tmr()). */ -void tcp_slowtmr (void); -void tcp_fasttmr (void); - -/* Call this from a netif driver (watch out for threading issues!) that has - returned a memory error on transmit and now has free buffers to send more. - This iterates all active pcbs that had an error and tries to call - tcp_output, so use this with care as it might slow down the system. */ -void tcp_txnow (void); - -/* Only used by IP to pass a TCP segment to TCP: */ -void tcp_input (struct pbuf *p, struct netif *inp); -/* Used within the TCP code only: */ -struct tcp_pcb * tcp_alloc (u8_t prio); -void tcp_abandon (struct tcp_pcb *pcb, int reset); -err_t tcp_send_empty_ack(struct tcp_pcb *pcb); -void tcp_rexmit (struct tcp_pcb *pcb); -void tcp_rexmit_rto (struct tcp_pcb *pcb); -void tcp_rexmit_fast (struct tcp_pcb *pcb); -u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); -err_t tcp_process_refused_data(struct tcp_pcb *pcb); - -/** - * This is the Nagle algorithm: try to combine user data to send as few TCP - * segments as possible. Only send if - * - no previously transmitted data on the connection remains unacknowledged or - * - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or - * - the only unsent segment is at least pcb->mss bytes long (or there is more - * than one unsent segment - with lwIP, this can happen although unsent->len < mss) - * - or if we are in fast-retransmit (TF_INFR) - */ -#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ - ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \ - (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ - ((tpcb)->unsent->len >= (tpcb)->mss))) || \ - ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \ - ) ? 1 : 0) -#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) - - -#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) -#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) -#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) -#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) -/* is b<=a<=c? */ -#if 0 /* see bug #10548 */ -#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) -#endif -#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) - -#ifndef TCP_TMR_INTERVAL -#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ -#endif /* TCP_TMR_INTERVAL */ - -#ifndef TCP_FAST_INTERVAL -#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ -#endif /* TCP_FAST_INTERVAL */ - -#ifndef TCP_SLOW_INTERVAL -#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ -#endif /* TCP_SLOW_INTERVAL */ - -#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ -#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ - -#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ - -#ifndef TCP_MSL -#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */ -#endif - -/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ -#ifndef TCP_KEEPIDLE_DEFAULT -#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ -#endif - -#ifndef TCP_KEEPINTVL_DEFAULT -#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ -#endif - -#ifndef TCP_KEEPCNT_DEFAULT -#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ -#endif - -#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */ - -#define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U)) - -/** Flags used on input processing, not on pcb->flags -*/ -#define TF_RESET (u8_t)0x08U /* Connection was reset. */ -#define TF_CLOSED (u8_t)0x10U /* Connection was successfully closed. */ -#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ - - -#if LWIP_EVENT_API - -#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) ret = lwip_tcp_event(arg, (pcb),\ - LWIP_EVENT_ACCEPT, NULL, 0, err) -#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_SENT, NULL, space, ERR_OK) -#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_RECV, (p), 0, (err)) -#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_RECV, NULL, 0, ERR_OK) -#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_CONNECTED, NULL, 0, (err)) -#define TCP_EVENT_POLL(pcb,ret) do { if ((pcb)->state != SYN_RCVD) { \ - ret = lwip_tcp_event((pcb)->callback_arg, (pcb), LWIP_EVENT_POLL, NULL, 0, ERR_OK); \ - } else { \ - ret = ERR_ARG; } } while(0) -#define TCP_EVENT_ERR(last_state,errf,arg,err) do { if (last_state != SYN_RCVD) { \ - lwip_tcp_event((arg), NULL, LWIP_EVENT_ERR, NULL, 0, (err)); } } while(0) - -#else /* LWIP_EVENT_API */ - -#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \ - do { \ - if((lpcb)->accept != NULL) \ - (ret) = (lpcb)->accept((arg),(pcb),(err)); \ - else (ret) = ERR_ARG; \ - } while (0) - -#define TCP_EVENT_SENT(pcb,space,ret) \ - do { \ - if((pcb)->sent != NULL) \ - (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_RECV(pcb,p,err,ret) \ - do { \ - if((pcb)->recv != NULL) { \ - (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\ - } else { \ - (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \ - } \ - } while (0) - -#define TCP_EVENT_CLOSED(pcb,ret) \ - do { \ - if(((pcb)->recv != NULL)) { \ - (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\ - } else { \ - (ret) = ERR_OK; \ - } \ - } while (0) - -#define TCP_EVENT_CONNECTED(pcb,err,ret) \ - do { \ - if((pcb)->connected != NULL) \ - (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_POLL(pcb,ret) \ - do { \ - if((pcb)->poll != NULL) \ - (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_ERR(last_state,errf,arg,err) \ - do { \ - LWIP_UNUSED_ARG(last_state); \ - if((errf) != NULL) \ - (errf)((arg),(err)); \ - } while (0) - -#endif /* LWIP_EVENT_API */ - -/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */ -#if TCP_OVERSIZE && defined(LWIP_DEBUG) -#define TCP_OVERSIZE_DBGCHECK 1 -#else -#define TCP_OVERSIZE_DBGCHECK 0 -#endif - -/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ -#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) - -/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */ -struct tcp_seg { - struct tcp_seg *next; /* used when putting segments on a queue */ - struct pbuf *p; /* buffer containing data + TCP header */ - u16_t len; /* the TCP length of this segment */ -#if TCP_OVERSIZE_DBGCHECK - u16_t oversize_left; /* Extra bytes available at the end of the last - pbuf in unsent (used for asserting vs. - tcp_pcb.unsent_oversize only) */ -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - u16_t chksum; - u8_t chksum_swapped; -#endif /* TCP_CHECKSUM_ON_COPY */ - u8_t flags; -#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */ -#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */ -#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is - checksummed into 'chksum' */ -#define TF_SEG_OPTS_WND_SCALE (u8_t)0x08U /* Include WND SCALE option */ - struct tcp_hdr *tcphdr; /* the TCP header */ -}; - -#define LWIP_TCP_OPT_EOL 0 -#define LWIP_TCP_OPT_NOP 1 -#define LWIP_TCP_OPT_MSS 2 -#define LWIP_TCP_OPT_WS 3 -#define LWIP_TCP_OPT_TS 8 - -#define LWIP_TCP_OPT_LEN_MSS 4 -#if LWIP_TCP_TIMESTAMPS -#define LWIP_TCP_OPT_LEN_TS 10 -#define LWIP_TCP_OPT_LEN_TS_OUT 12 /* aligned for output (includes NOP padding) */ -#else -#define LWIP_TCP_OPT_LEN_TS_OUT 0 -#endif -#if LWIP_WND_SCALE -#define LWIP_TCP_OPT_LEN_WS 3 -#define LWIP_TCP_OPT_LEN_WS_OUT 4 /* aligned for output (includes NOP padding) */ -#else -#define LWIP_TCP_OPT_LEN_WS_OUT 0 -#endif - -#define LWIP_TCP_OPT_LENGTH(flags) \ - (flags & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \ - (flags & TF_SEG_OPTS_TS ? LWIP_TCP_OPT_LEN_TS_OUT : 0) + \ - (flags & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0) - -/** This returns a TCP header option for MSS in an u32_t */ -#define TCP_BUILD_MSS_OPTION(mss) lwip_htonl(0x02040000 | ((mss) & 0xFFFF)) - -#if LWIP_WND_SCALE -#define TCPWNDSIZE_F U32_F -#define TCPWND_MAX 0xFFFFFFFFU -#define TCPWND_CHECK16(x) LWIP_ASSERT("window size > 0xFFFF", (x) <= 0xFFFF) -#define TCPWND_MIN16(x) ((u16_t)LWIP_MIN((x), 0xFFFF)) -#else /* LWIP_WND_SCALE */ -#define TCPWNDSIZE_F U16_F -#define TCPWND_MAX 0xFFFFU -#define TCPWND_CHECK16(x) -#define TCPWND_MIN16(x) x -#endif /* LWIP_WND_SCALE */ - -/* Global variables: */ -extern struct tcp_pcb *tcp_input_pcb; -extern u32_t tcp_ticks; -extern u8_t tcp_active_pcbs_changed; - -/* The TCP PCB lists. */ -union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ - struct tcp_pcb_listen *listen_pcbs; - struct tcp_pcb *pcbs; -}; -extern struct tcp_pcb *tcp_bound_pcbs; -extern union tcp_listen_pcbs_t tcp_listen_pcbs; -extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a - state in which they accept or send - data. */ -extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ - -#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 -#define NUM_TCP_PCB_LISTS 4 -extern struct tcp_pcb ** const tcp_pcb_lists[NUM_TCP_PCB_LISTS]; - -/* Axioms about the above lists: - 1) Every TCP PCB that is not CLOSED is in one of the lists. - 2) A PCB is only in one of the lists. - 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. - 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. -*/ -/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB - with a PCB list or removes a PCB from a list, respectively. */ -#ifndef TCP_DEBUG_PCB_LISTS -#define TCP_DEBUG_PCB_LISTS 0 -#endif -#if TCP_DEBUG_PCB_LISTS -#define TCP_REG(pcbs, npcb) do {\ - struct tcp_pcb *tcp_tmp_pcb; \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \ - for (tcp_tmp_pcb = *(pcbs); \ - tcp_tmp_pcb != NULL; \ - tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \ - } \ - LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \ - (npcb)->next = *(pcbs); \ - LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \ - *(pcbs) = (npcb); \ - LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ - tcp_timer_needed(); \ - } while(0) -#define TCP_RMV(pcbs, npcb) do { \ - struct tcp_pcb *tcp_tmp_pcb; \ - LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \ - if(*(pcbs) == (npcb)) { \ - *(pcbs) = (*pcbs)->next; \ - } else for (tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - if(tcp_tmp_pcb->next == (npcb)) { \ - tcp_tmp_pcb->next = (npcb)->next; \ - break; \ - } \ - } \ - (npcb)->next = NULL; \ - LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \ - } while(0) - -#else /* LWIP_DEBUG */ - -#define TCP_REG(pcbs, npcb) \ - do { \ - (npcb)->next = *pcbs; \ - *(pcbs) = (npcb); \ - tcp_timer_needed(); \ - } while (0) - -#define TCP_RMV(pcbs, npcb) \ - do { \ - if(*(pcbs) == (npcb)) { \ - (*(pcbs)) = (*pcbs)->next; \ - } \ - else { \ - struct tcp_pcb *tcp_tmp_pcb; \ - for (tcp_tmp_pcb = *pcbs; \ - tcp_tmp_pcb != NULL; \ - tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - if(tcp_tmp_pcb->next == (npcb)) { \ - tcp_tmp_pcb->next = (npcb)->next; \ - break; \ - } \ - } \ - } \ - (npcb)->next = NULL; \ - } while(0) - -#endif /* LWIP_DEBUG */ - -#define TCP_REG_ACTIVE(npcb) \ - do { \ - TCP_REG(&tcp_active_pcbs, npcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - -#define TCP_RMV_ACTIVE(npcb) \ - do { \ - TCP_RMV(&tcp_active_pcbs, npcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - -#define TCP_PCB_REMOVE_ACTIVE(pcb) \ - do { \ - tcp_pcb_remove(&tcp_active_pcbs, pcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - - -/* Internal functions: */ -struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); -void tcp_pcb_purge(struct tcp_pcb *pcb); -void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); - -void tcp_segs_free(struct tcp_seg *seg); -void tcp_seg_free(struct tcp_seg *seg); -struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); - -#define tcp_ack(pcb) \ - do { \ - if((pcb)->flags & TF_ACK_DELAY) { \ - (pcb)->flags &= ~TF_ACK_DELAY; \ - (pcb)->flags |= TF_ACK_NOW; \ - } \ - else { \ - (pcb)->flags |= TF_ACK_DELAY; \ - } \ - } while (0) - -#define tcp_ack_now(pcb) \ - do { \ - (pcb)->flags |= TF_ACK_NOW; \ - } while (0) - -err_t tcp_send_fin(struct tcp_pcb *pcb); -err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags); - -void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); - -void tcp_rst(u32_t seqno, u32_t ackno, - const ip_addr_t *local_ip, const ip_addr_t *remote_ip, - u16_t local_port, u16_t remote_port); - -u32_t tcp_next_iss(struct tcp_pcb *pcb); - -err_t tcp_keepalive(struct tcp_pcb *pcb); -err_t tcp_zero_window_probe(struct tcp_pcb *pcb); -void tcp_trigger_input_pcb_close(void); - -#if TCP_CALCULATE_EFF_SEND_MSS -u16_t tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest -#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING - , const ip_addr_t *src -#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ - ); -#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING -#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest, src) -#else /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ -#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest) -#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - -#if LWIP_CALLBACK_API -err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); -#endif /* LWIP_CALLBACK_API */ - -#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG -void tcp_debug_print(struct tcp_hdr *tcphdr); -void tcp_debug_print_flags(u8_t flags); -void tcp_debug_print_state(enum tcp_state s); -void tcp_debug_print_pcbs(void); -s16_t tcp_pcbs_sane(void); -#else -# define tcp_debug_print(tcphdr) -# define tcp_debug_print_flags(flags) -# define tcp_debug_print_state(s) -# define tcp_debug_print_pcbs() -# define tcp_pcbs_sane() 1 -#endif /* TCP_DEBUG */ - -/** External function (implemented in timers.c), called when TCP detects - * that a timer is needed (i.e. active- or time-wait-pcb found). */ -void tcp_timer_needed(void); - -void tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TCP */ - -#endif /* LWIP_HDR_TCP_PRIV_H */ diff --git a/include/net/priv/tcpip_priv.h b/include/net/priv/tcpip_priv.h deleted file mode 100644 index c714d1e..0000000 --- a/include/net/priv/tcpip_priv.h +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @file - * TCPIP API internal implementations (do not use in application code) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_TCPIP_PRIV_H -#define LWIP_HDR_TCPIP_PRIV_H - -#include "net/opt.h" - -#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ - -#include "net/tcpip.h" -#include "net/sys.h" -#include "net/timeouts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct pbuf; -struct netif; - -#if LWIP_MPU_COMPATIBLE -#define API_VAR_REF(name) (*(name)) -#define API_VAR_DECLARE(type, name) type * name -#define API_VAR_ALLOC(type, pool, name, errorval) do { \ - name = (type *)memp_malloc(pool); \ - if (name == NULL) { \ - return errorval; \ - } \ - } while(0) -#define API_VAR_ALLOC_POOL(type, pool, name, errorval) do { \ - name = (type *)LWIP_MEMPOOL_ALLOC(pool); \ - if (name == NULL) { \ - return errorval; \ - } \ - } while(0) -#define API_VAR_FREE(pool, name) memp_free(pool, name) -#define API_VAR_FREE_POOL(pool, name) LWIP_MEMPOOL_FREE(pool, name) -#define API_EXPR_REF(expr) (&(expr)) -#if LWIP_NETCONN_SEM_PER_THREAD -#define API_EXPR_REF_SEM(expr) (expr) -#else -#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr) -#endif -#define API_EXPR_DEREF(expr) expr -#define API_MSG_M_DEF(m) m -#define API_MSG_M_DEF_C(t, m) t m -#else /* LWIP_MPU_COMPATIBLE */ -#define API_VAR_REF(name) name -#define API_VAR_DECLARE(type, name) type name -#define API_VAR_ALLOC(type, pool, name, errorval) -#define API_VAR_ALLOC_POOL(type, pool, name, errorval) -#define API_VAR_FREE(pool, name) -#define API_VAR_FREE_POOL(pool, name) -#define API_EXPR_REF(expr) expr -#define API_EXPR_REF_SEM(expr) API_EXPR_REF(expr) -#define API_EXPR_DEREF(expr) (*(expr)) -#define API_MSG_M_DEF(m) *m -#define API_MSG_M_DEF_C(t, m) const t * m -#endif /* LWIP_MPU_COMPATIBLE */ - -err_t tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem); - -struct tcpip_api_call_data -{ -#if !LWIP_TCPIP_CORE_LOCKING - err_t err; -#if !LWIP_NETCONN_SEM_PER_THREAD - sys_sem_t sem; -#endif /* LWIP_NETCONN_SEM_PER_THREAD */ -#else /* !LWIP_TCPIP_CORE_LOCKING */ - u8_t dummy; /* avoid empty struct :-( */ -#endif /* !LWIP_TCPIP_CORE_LOCKING */ -}; -typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call_data* call); -err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call); - -enum tcpip_msg_type { - TCPIP_MSG_API, - TCPIP_MSG_API_CALL, - TCPIP_MSG_INPKT, -#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS - TCPIP_MSG_TIMEOUT, - TCPIP_MSG_UNTIMEOUT, -#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ - TCPIP_MSG_CALLBACK, - TCPIP_MSG_CALLBACK_STATIC -}; - -struct tcpip_msg { - enum tcpip_msg_type type; - union { - struct { - tcpip_callback_fn function; - void* msg; - } api_msg; - struct { - tcpip_api_call_fn function; - struct tcpip_api_call_data *arg; - sys_sem_t *sem; - } api_call; - struct { - struct pbuf *p; - struct netif *netif; - netif_input_fn input_fn; - } inp; - struct { - tcpip_callback_fn function; - void *ctx; - } cb; -#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS - struct { - u32_t msecs; - sys_timeout_handler h; - void *arg; - } tmo; -#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ - } msg; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !NO_SYS */ - -#endif /* LWIP_HDR_TCPIP_PRIV_H */ diff --git a/include/net/prot/autoip.h b/include/net/prot/autoip.h deleted file mode 100644 index fd3af8a..0000000 --- a/include/net/prot/autoip.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file - * AutoIP protocol definitions - */ - -/* - * - * Copyright (c) 2007 Dominik Spies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Dominik Spies - * - * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform - * with RFC 3927. - * - */ - -#ifndef LWIP_HDR_PROT_AUTOIP_H -#define LWIP_HDR_PROT_AUTOIP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* 169.254.0.0 */ -#define AUTOIP_NET 0xA9FE0000 -/* 169.254.1.0 */ -#define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) -/* 169.254.254.255 */ -#define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) - -/* RFC 3927 Constants */ -#define PROBE_WAIT 1 /* second (initial random delay) */ -#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ -#define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ -#define PROBE_NUM 3 /* (number of probe packets) */ -#define ANNOUNCE_NUM 2 /* (number of announcement packets) */ -#define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ -#define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ -#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ -#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ -#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ - -/* AutoIP client states */ -typedef enum { - AUTOIP_STATE_OFF = 0, - AUTOIP_STATE_PROBING = 1, - AUTOIP_STATE_ANNOUNCING = 2, - AUTOIP_STATE_BOUND = 3 -} autoip_state_enum_t; - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_AUTOIP_H */ diff --git a/include/net/prot/dhcp.h b/include/net/prot/dhcp.h deleted file mode 100644 index 39d7726..0000000 --- a/include/net/prot/dhcp.h +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @file - * DHCP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Leon Woestenberg - * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Leon Woestenberg - * - */ -#ifndef LWIP_HDR_PROT_DHCP_H -#define LWIP_HDR_PROT_DHCP_H - -#include "net/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define DHCP_CLIENT_PORT 68 -#define DHCP_SERVER_PORT 67 - - - /* DHCP message item offsets and length */ -#define DHCP_CHADDR_LEN 16U -#define DHCP_SNAME_OFS 44U -#define DHCP_SNAME_LEN 64U -#define DHCP_FILE_OFS 108U -#define DHCP_FILE_LEN 128U -#define DHCP_MSG_LEN 236U -#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4U) /* 4 byte: cookie */ - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** minimum set of fields of any DHCP message */ -struct dhcp_msg -{ - PACK_STRUCT_FLD_8(u8_t op); - PACK_STRUCT_FLD_8(u8_t htype); - PACK_STRUCT_FLD_8(u8_t hlen); - PACK_STRUCT_FLD_8(u8_t hops); - PACK_STRUCT_FIELD(u32_t xid); - PACK_STRUCT_FIELD(u16_t secs); - PACK_STRUCT_FIELD(u16_t flags); - PACK_STRUCT_FLD_S(ip4_addr_p_t ciaddr); - PACK_STRUCT_FLD_S(ip4_addr_p_t yiaddr); - PACK_STRUCT_FLD_S(ip4_addr_p_t siaddr); - PACK_STRUCT_FLD_S(ip4_addr_p_t giaddr); - PACK_STRUCT_FLD_8(u8_t chaddr[DHCP_CHADDR_LEN]); - PACK_STRUCT_FLD_8(u8_t sname[DHCP_SNAME_LEN]); - PACK_STRUCT_FLD_8(u8_t file[DHCP_FILE_LEN]); - PACK_STRUCT_FIELD(u32_t cookie); -#define DHCP_MIN_OPTIONS_LEN 68U -/** make sure user does not configure this too small */ -#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) -# undef DHCP_OPTIONS_LEN -#endif -/** allow this to be configured in lwipopts.h, but not too small */ -#if (!defined(DHCP_OPTIONS_LEN)) -/** set this to be sufficient for your options in outgoing DHCP msgs */ -# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN -#endif - PACK_STRUCT_FLD_8(u8_t options[DHCP_OPTIONS_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - - -/* DHCP client states */ -typedef enum { - DHCP_STATE_OFF = 0, - DHCP_STATE_REQUESTING = 1, - DHCP_STATE_INIT = 2, - DHCP_STATE_REBOOTING = 3, - DHCP_STATE_REBINDING = 4, - DHCP_STATE_RENEWING = 5, - DHCP_STATE_SELECTING = 6, - DHCP_STATE_INFORMING = 7, - DHCP_STATE_CHECKING = 8, - DHCP_STATE_PERMANENT = 9, /* not yet implemented */ - DHCP_STATE_BOUND = 10, - DHCP_STATE_RELEASING = 11, /* not yet implemented */ - DHCP_STATE_BACKING_OFF = 12 -} dhcp_state_enum_t; - -/* DHCP op codes */ -#define DHCP_BOOTREQUEST 1 -#define DHCP_BOOTREPLY 2 - -/* DHCP message types */ -#define DHCP_DISCOVER 1 -#define DHCP_OFFER 2 -#define DHCP_REQUEST 3 -#define DHCP_DECLINE 4 -#define DHCP_ACK 5 -#define DHCP_NAK 6 -#define DHCP_RELEASE 7 -#define DHCP_INFORM 8 - -/** DHCP hardware type, currently only ethernet is supported */ -#define DHCP_HTYPE_ETH 1 - -#define DHCP_MAGIC_COOKIE 0x63825363UL - -/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */ - -/* BootP options */ -#define DHCP_OPTION_PAD 0 -#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ -#define DHCP_OPTION_ROUTER 3 -#define DHCP_OPTION_DNS_SERVER 6 -#define DHCP_OPTION_HOSTNAME 12 -#define DHCP_OPTION_IP_TTL 23 -#define DHCP_OPTION_MTU 26 -#define DHCP_OPTION_BROADCAST 28 -#define DHCP_OPTION_TCP_TTL 37 -#define DHCP_OPTION_NTP 42 -#define DHCP_OPTION_END 255 - -/* DHCP options */ -#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ -#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ -#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ - -#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ -#define DHCP_OPTION_MESSAGE_TYPE_LEN 1 - -#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ -#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ - -#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ -#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 - -#define DHCP_OPTION_T1 58 /* T1 renewal time */ -#define DHCP_OPTION_T2 59 /* T2 rebinding time */ -#define DHCP_OPTION_US 60 -#define DHCP_OPTION_CLIENT_ID 61 -#define DHCP_OPTION_TFTP_SERVERNAME 66 -#define DHCP_OPTION_BOOTFILE 67 - -/* possible combinations of overloading the file and sname fields with options */ -#define DHCP_OVERLOAD_NONE 0 -#define DHCP_OVERLOAD_FILE 1 -#define DHCP_OVERLOAD_SNAME 2 -#define DHCP_OVERLOAD_SNAME_FILE 3 - - -#ifdef __cplusplus -} -#endif - -#endif /*LWIP_HDR_PROT_DHCP_H*/ diff --git a/include/net/prot/dns.h b/include/net/prot/dns.h deleted file mode 100644 index e109743..0000000 --- a/include/net/prot/dns.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file - * DNS - host name to IP address resolver. - */ - -/* - * Port to lwIP from uIP - * by Jim Pettinato April 2007 - * - * security fixes and more by Simon Goldschmidt - * - * uIP version Copyright (c) 2002-2003, Adam Dunkels. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LWIP_HDR_PROT_DNS_H -#define LWIP_HDR_PROT_DNS_H - -#include "net/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** DNS server port address */ -#ifndef DNS_SERVER_PORT -#define DNS_SERVER_PORT 53 -#endif - -/* DNS field TYPE used for "Resource Records" */ -#define DNS_RRTYPE_A 1 /* a host address */ -#define DNS_RRTYPE_NS 2 /* an authoritative name server */ -#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ -#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ -#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ -#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ -#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ -#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ -#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ -#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ -#define DNS_RRTYPE_WKS 11 /* a well known service description */ -#define DNS_RRTYPE_PTR 12 /* a domain name pointer */ -#define DNS_RRTYPE_HINFO 13 /* host information */ -#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ -#define DNS_RRTYPE_MX 15 /* mail exchange */ -#define DNS_RRTYPE_TXT 16 /* text strings */ -#define DNS_RRTYPE_AAAA 28 /* IPv6 address */ -#define DNS_RRTYPE_SRV 33 /* service location */ -#define DNS_RRTYPE_ANY 255 /* any type */ - -/* DNS field CLASS used for "Resource Records" */ -#define DNS_RRCLASS_IN 1 /* the Internet */ -#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ -#define DNS_RRCLASS_CH 3 /* the CHAOS class */ -#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ -#define DNS_RRCLASS_ANY 255 /* any class */ -#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ - -/* DNS protocol flags */ -#define DNS_FLAG1_RESPONSE 0x80 -#define DNS_FLAG1_OPCODE_STATUS 0x10 -#define DNS_FLAG1_OPCODE_INVERSE 0x08 -#define DNS_FLAG1_OPCODE_STANDARD 0x00 -#define DNS_FLAG1_AUTHORATIVE 0x04 -#define DNS_FLAG1_TRUNC 0x02 -#define DNS_FLAG1_RD 0x01 -#define DNS_FLAG2_RA 0x80 -#define DNS_FLAG2_ERR_MASK 0x0f -#define DNS_FLAG2_ERR_NONE 0x00 -#define DNS_FLAG2_ERR_NAME 0x03 - -#define DNS_HDR_GET_OPCODE(hdr) ((((hdr)->flags1) >> 3) & 0xF) - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** DNS message header */ -struct dns_hdr { - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FLD_8(u8_t flags1); - PACK_STRUCT_FLD_8(u8_t flags2); - PACK_STRUCT_FIELD(u16_t numquestions); - PACK_STRUCT_FIELD(u16_t numanswers); - PACK_STRUCT_FIELD(u16_t numauthrr); - PACK_STRUCT_FIELD(u16_t numextrarr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif -#define SIZEOF_DNS_HDR 12 - - -/* Multicast DNS definitions */ - -/** UDP port for multicast DNS queries */ -#ifndef DNS_MQUERY_PORT -#define DNS_MQUERY_PORT 5353 -#endif - -/* IPv4 group for multicast DNS queries: 224.0.0.251 */ -#ifndef DNS_MQUERY_IPV4_GROUP_INIT -#define DNS_MQUERY_IPV4_GROUP_INIT IPADDR4_INIT_BYTES(224,0,0,251) -#endif - -/* IPv6 group for multicast DNS queries: FF02::FB */ -#ifndef DNS_MQUERY_IPV6_GROUP_INIT -#define DNS_MQUERY_IPV6_GROUP_INIT IPADDR6_INIT_HOST(0xFF020000,0,0,0xFB) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_DNS_H */ diff --git a/include/net/prot/etharp.h b/include/net/prot/etharp.h deleted file mode 100644 index 6f5c5eb..0000000 --- a/include/net/prot/etharp.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file - * ARP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_ETHARP_H -#define LWIP_HDR_PROT_ETHARP_H - -#include "net/arch.h" -#include "net/prot/ethernet.h" -#include "net/ip4_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ETHARP_HWADDR_LEN -#define ETHARP_HWADDR_LEN ETH_HWADDR_LEN -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** the ARP message, see RFC 826 ("Packet format") */ -struct etharp_hdr { - PACK_STRUCT_FIELD(u16_t hwtype); - PACK_STRUCT_FIELD(u16_t proto); - PACK_STRUCT_FLD_8(u8_t hwlen); - PACK_STRUCT_FLD_8(u8_t protolen); - PACK_STRUCT_FIELD(u16_t opcode); - PACK_STRUCT_FLD_S(struct eth_addr shwaddr); - PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr); - PACK_STRUCT_FLD_S(struct eth_addr dhwaddr); - PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_ETHARP_HDR 28 - -/* ARP hwtype values */ -enum etharp_hwtype { - HWTYPE_ETHERNET = 1 - /* others not used */ -}; - -/* ARP message types (opcodes) */ -enum etharp_opcode { - ARP_REQUEST = 1, - ARP_REPLY = 2 -}; - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_ETHARP_H */ diff --git a/include/net/prot/ethernet.h b/include/net/prot/ethernet.h deleted file mode 100644 index d4e8b1c..0000000 --- a/include/net/prot/ethernet.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @file - * Ethernet protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_ETHERNET_H -#define LWIP_HDR_PROT_ETHERNET_H - -#include "net/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ETH_HWADDR_LEN -#ifdef ETHARP_HWADDR_LEN -#define ETH_HWADDR_LEN ETHARP_HWADDR_LEN /* compatibility mode */ -#else -#define ETH_HWADDR_LEN 6 -#endif -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct eth_addr { - PACK_STRUCT_FLD_8(u8_t addr[ETH_HWADDR_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** Ethernet header */ -struct eth_hdr { -#if ETH_PAD_SIZE - PACK_STRUCT_FLD_8(u8_t padding[ETH_PAD_SIZE]); -#endif - PACK_STRUCT_FLD_S(struct eth_addr dest); - PACK_STRUCT_FLD_S(struct eth_addr src); - PACK_STRUCT_FIELD(u16_t type); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE) - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** VLAN header inserted between ethernet header and payload - * if 'type' in ethernet header is ETHTYPE_VLAN. - * See IEEE802.Q */ -struct eth_vlan_hdr { - PACK_STRUCT_FIELD(u16_t prio_vid); - PACK_STRUCT_FIELD(u16_t tpid); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_VLAN_HDR 4 -#define VLAN_ID(vlan_hdr) (lwip_htons((vlan_hdr)->prio_vid) & 0xFFF) - -/** - * @ingroup ethernet - * A list of often ethtypes (although lwIP does not use all of them): */ -enum eth_type { - /** Internet protocol v4 */ - ETHTYPE_IP = 0x0800U, - /** Address resolution protocol */ - ETHTYPE_ARP = 0x0806U, - /** Wake on lan */ - ETHTYPE_WOL = 0x0842U, - /** RARP */ - ETHTYPE_RARP = 0x8035U, - /** Virtual local area network */ - ETHTYPE_VLAN = 0x8100U, - /** Internet protocol v6 */ - ETHTYPE_IPV6 = 0x86DDU, - /** PPP Over Ethernet Discovery Stage */ - ETHTYPE_PPPOEDISC = 0x8863U, - /** PPP Over Ethernet Session Stage */ - ETHTYPE_PPPOE = 0x8864U, - /** Jumbo Frames */ - ETHTYPE_JUMBO = 0x8870U, - /** Process field network */ - ETHTYPE_PROFINET = 0x8892U, - /** Ethernet for control automation technology */ - ETHTYPE_ETHERCAT = 0x88A4U, - /** Link layer discovery protocol */ - ETHTYPE_LLDP = 0x88CCU, - /** Serial real-time communication system */ - ETHTYPE_SERCOS = 0x88CDU, - /** Media redundancy protocol */ - ETHTYPE_MRP = 0x88E3U, - /** Precision time protocol */ - ETHTYPE_PTP = 0x88F7U, - /** Q-in-Q, 802.1ad */ - ETHTYPE_QINQ = 0x9100U -}; - -/** The 24-bit IANA IPv4-multicast OUI is 01-00-5e: */ -#define LL_IP4_MULTICAST_ADDR_0 0x01 -#define LL_IP4_MULTICAST_ADDR_1 0x00 -#define LL_IP4_MULTICAST_ADDR_2 0x5e - -/** IPv6 multicast uses this prefix */ -#define LL_IP6_MULTICAST_ADDR_0 0x33 -#define LL_IP6_MULTICAST_ADDR_1 0x33 - -/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables - * or known to be 32-bit aligned within the protocol header. */ -#ifndef ETHADDR32_COPY -#define ETHADDR32_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN) -#endif - -/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local - * variables and known to be 16-bit aligned within the protocol header. */ -#ifndef ETHADDR16_COPY -#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN) -#endif - -#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_ETHERNET_H */ diff --git a/include/net/prot/icmp.h b/include/net/prot/icmp.h deleted file mode 100644 index 8a6fbd5..0000000 --- a/include/net/prot/icmp.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file - * ICMP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_ICMP_H -#define LWIP_HDR_PROT_ICMP_H - -#include "net/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ICMP_ER 0 /* echo reply */ -#define ICMP_DUR 3 /* destination unreachable */ -#define ICMP_SQ 4 /* source quench */ -#define ICMP_RD 5 /* redirect */ -#define ICMP_ECHO 8 /* echo */ -#define ICMP_TE 11 /* time exceeded */ -#define ICMP_PP 12 /* parameter problem */ -#define ICMP_TS 13 /* timestamp */ -#define ICMP_TSR 14 /* timestamp reply */ -#define ICMP_IRQ 15 /* information request */ -#define ICMP_IR 16 /* information reply */ -#define ICMP_AM 17 /* address mask request */ -#define ICMP_AMR 18 /* address mask reply */ - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -/** This is the standard ICMP header only that the u32_t data - * is split to two u16_t like ICMP echo needs it. - * This header is also used for other ICMP types that do not - * use the data part. - */ -PACK_STRUCT_BEGIN -struct icmp_echo_hdr { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FIELD(u16_t seqno); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Compatibility defines, old versions used to combine type and code to an u16_t */ -#define ICMPH_TYPE(hdr) ((hdr)->type) -#define ICMPH_CODE(hdr) ((hdr)->code) -#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) -#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_ICMP_H */ diff --git a/include/net/prot/icmp6.h b/include/net/prot/icmp6.h deleted file mode 100644 index 3cd7327..0000000 --- a/include/net/prot/icmp6.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @file - * ICMP6 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_ICMP6_H -#define LWIP_HDR_PROT_ICMP6_H - -#include "net/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** ICMP type */ -enum icmp6_type { - /** Destination unreachable */ - ICMP6_TYPE_DUR = 1, - /** Packet too big */ - ICMP6_TYPE_PTB = 2, - /** Time exceeded */ - ICMP6_TYPE_TE = 3, - /** Parameter problem */ - ICMP6_TYPE_PP = 4, - /** Private experimentation */ - ICMP6_TYPE_PE1 = 100, - /** Private experimentation */ - ICMP6_TYPE_PE2 = 101, - /** Reserved for expansion of error messages */ - ICMP6_TYPE_RSV_ERR = 127, - - /** Echo request */ - ICMP6_TYPE_EREQ = 128, - /** Echo reply */ - ICMP6_TYPE_EREP = 129, - /** Multicast listener query */ - ICMP6_TYPE_MLQ = 130, - /** Multicast listener report */ - ICMP6_TYPE_MLR = 131, - /** Multicast listener done */ - ICMP6_TYPE_MLD = 132, - /** Router solicitation */ - ICMP6_TYPE_RS = 133, - /** Router advertisement */ - ICMP6_TYPE_RA = 134, - /** Neighbor solicitation */ - ICMP6_TYPE_NS = 135, - /** Neighbor advertisement */ - ICMP6_TYPE_NA = 136, - /** Redirect */ - ICMP6_TYPE_RD = 137, - /** Multicast router advertisement */ - ICMP6_TYPE_MRA = 151, - /** Multicast router solicitation */ - ICMP6_TYPE_MRS = 152, - /** Multicast router termination */ - ICMP6_TYPE_MRT = 153, - /** Private experimentation */ - ICMP6_TYPE_PE3 = 200, - /** Private experimentation */ - ICMP6_TYPE_PE4 = 201, - /** Reserved for expansion of informational messages */ - ICMP6_TYPE_RSV_INF = 255 -}; - -/** ICMP destination unreachable codes */ -enum icmp6_dur_code { - /** No route to destination */ - ICMP6_DUR_NO_ROUTE = 0, - /** Communication with destination administratively prohibited */ - ICMP6_DUR_PROHIBITED = 1, - /** Beyond scope of source address */ - ICMP6_DUR_SCOPE = 2, - /** Address unreachable */ - ICMP6_DUR_ADDRESS = 3, - /** Port unreachable */ - ICMP6_DUR_PORT = 4, - /** Source address failed ingress/egress policy */ - ICMP6_DUR_POLICY = 5, - /** Reject route to destination */ - ICMP6_DUR_REJECT_ROUTE = 6 -}; - -/** ICMP time exceeded codes */ -enum icmp6_te_code { - /** Hop limit exceeded in transit */ - ICMP6_TE_HL = 0, - /** Fragment reassembly time exceeded */ - ICMP6_TE_FRAG = 1 -}; - -/** ICMP parameter code */ -enum icmp6_pp_code { - /** Erroneous header field encountered */ - ICMP6_PP_FIELD = 0, - /** Unrecognized next header type encountered */ - ICMP6_PP_HEADER = 1, - /** Unrecognized IPv6 option encountered */ - ICMP6_PP_OPTION = 2 -}; - -/** This is the standard ICMP6 header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct icmp6_hdr { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t data); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** This is the ICMP6 header adapted for echo req/resp. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct icmp6_echo_hdr { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FIELD(u16_t seqno); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_ICMP6_H */ diff --git a/include/net/prot/igmp.h b/include/net/prot/igmp.h deleted file mode 100644 index 9f60bee..0000000 --- a/include/net/prot/igmp.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file - * IGMP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_IGMP_H -#define LWIP_HDR_PROT_IGMP_H - -#include "net/arch.h" -#include "net/ip4_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * IGMP constants - */ -#define IGMP_TTL 1 -#define IGMP_MINLEN 8 -#define ROUTER_ALERT 0x9404U -#define ROUTER_ALERTLEN 4 - -/* - * IGMP message types, including version number. - */ -#define IGMP_MEMB_QUERY 0x11 /* Membership query */ -#define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */ -#define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */ -#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ - -/* Group membership states */ -#define IGMP_GROUP_NON_MEMBER 0 -#define IGMP_GROUP_DELAYING_MEMBER 1 -#define IGMP_GROUP_IDLE_MEMBER 2 - -/** - * IGMP packet format. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct igmp_msg { - PACK_STRUCT_FLD_8(u8_t igmp_msgtype); - PACK_STRUCT_FLD_8(u8_t igmp_maxresp); - PACK_STRUCT_FIELD(u16_t igmp_checksum); - PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_IGMP_H */ diff --git a/include/net/prot/ip.h b/include/net/prot/ip.h deleted file mode 100644 index eb0770c..0000000 --- a/include/net/prot/ip.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file - * IP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_IP_H -#define LWIP_HDR_PROT_IP_H - -#include "net/arch.h" - -#define IP_PROTO_ICMP 1 -#define IP_PROTO_IGMP 2 -#define IP_PROTO_UDP 17 -#define IP_PROTO_UDPLITE 136 -#define IP_PROTO_TCP 6 - -/** This operates on a void* by loading the first byte */ -#define IP_HDR_GET_VERSION(ptr) ((*(u8_t*)(ptr)) >> 4) - -#endif /* LWIP_HDR_PROT_IP_H */ diff --git a/include/net/prot/ip4.h b/include/net/prot/ip4.h deleted file mode 100644 index 9d4a5bd..0000000 --- a/include/net/prot/ip4.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file - * IPv4 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_IP4_H -#define LWIP_HDR_PROT_IP4_H - -#include "net/arch.h" -#include "net/ip4_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** This is the packed version of ip4_addr_t, - used in network headers that are itself packed */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip4_addr_packed { - PACK_STRUCT_FIELD(u32_t addr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -typedef struct ip4_addr_packed ip4_addr_p_t; - -/* Size of the IPv4 header. Same as 'sizeof(struct ip_hdr)'. */ -#define IP_HLEN 20 - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/* The IPv4 header */ -struct ip_hdr { - /* version / header length */ - PACK_STRUCT_FLD_8(u8_t _v_hl); - /* type of service */ - PACK_STRUCT_FLD_8(u8_t _tos); - /* total length */ - PACK_STRUCT_FIELD(u16_t _len); - /* identification */ - PACK_STRUCT_FIELD(u16_t _id); - /* fragment offset field */ - PACK_STRUCT_FIELD(u16_t _offset); -#define IP_RF 0x8000U /* reserved fragment flag */ -#define IP_DF 0x4000U /* don't fragment flag */ -#define IP_MF 0x2000U /* more fragments flag */ -#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */ - /* time to live */ - PACK_STRUCT_FLD_8(u8_t _ttl); - /* protocol*/ - PACK_STRUCT_FLD_8(u8_t _proto); - /* checksum */ - PACK_STRUCT_FIELD(u16_t _chksum); - /* source and destination IP addresses */ - PACK_STRUCT_FLD_S(ip4_addr_p_t src); - PACK_STRUCT_FLD_S(ip4_addr_p_t dest); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Macros to get struct ip_hdr fields: */ -#define IPH_V(hdr) ((hdr)->_v_hl >> 4) -#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f) -#define IPH_TOS(hdr) ((hdr)->_tos) -#define IPH_LEN(hdr) ((hdr)->_len) -#define IPH_ID(hdr) ((hdr)->_id) -#define IPH_OFFSET(hdr) ((hdr)->_offset) -#define IPH_TTL(hdr) ((hdr)->_ttl) -#define IPH_PROTO(hdr) ((hdr)->_proto) -#define IPH_CHKSUM(hdr) ((hdr)->_chksum) - -/* Macros to set struct ip_hdr fields: */ -#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (u8_t)((((v) << 4) | (hl))) -#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos) -#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len) -#define IPH_ID_SET(hdr, id) (hdr)->_id = (id) -#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off) -#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl) -#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) -#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_IP4_H */ diff --git a/include/net/prot/ip6.h b/include/net/prot/ip6.h deleted file mode 100644 index 066bdb2..0000000 --- a/include/net/prot/ip6.h +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @file - * IPv6 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_IP6_H -#define LWIP_HDR_PROT_IP6_H - -#include "lwip/arch.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** This is the packed version of ip6_addr_t, - used in network headers that are itself packed */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_addr_packed { - PACK_STRUCT_FIELD(u32_t addr[4]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif -typedef struct ip6_addr_packed ip6_addr_p_t; - -#define IP6_HLEN 40 - -#define IP6_NEXTH_HOPBYHOP 0 -#define IP6_NEXTH_TCP 6 -#define IP6_NEXTH_UDP 17 -#define IP6_NEXTH_ENCAPS 41 -#define IP6_NEXTH_ROUTING 43 -#define IP6_NEXTH_FRAGMENT 44 -#define IP6_NEXTH_ICMP6 58 -#define IP6_NEXTH_NONE 59 -#define IP6_NEXTH_DESTOPTS 60 -#define IP6_NEXTH_UDPLITE 136 - -/** The IPv6 header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_hdr { - /** version / traffic class / flow label */ - PACK_STRUCT_FIELD(u32_t _v_tc_fl); - /** payload length */ - PACK_STRUCT_FIELD(u16_t _plen); - /** next header */ - PACK_STRUCT_FLD_8(u8_t _nexth); - /** hop limit */ - PACK_STRUCT_FLD_8(u8_t _hoplim); - /** source and destination IP addresses */ - PACK_STRUCT_FLD_S(ip6_addr_p_t src); - PACK_STRUCT_FLD_S(ip6_addr_p_t dest); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Hop-by-hop router alert option. */ -#define IP6_HBH_HLEN 8 -#define IP6_PAD1_OPTION 0 -#define IP6_PADN_ALERT_OPTION 1 -#define IP6_ROUTER_ALERT_OPTION 5 -#define IP6_ROUTER_ALERT_VALUE_MLD 0 -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_hbh_hdr { - /* next header */ - PACK_STRUCT_FLD_8(u8_t _nexth); - /* header length */ - PACK_STRUCT_FLD_8(u8_t _hlen); - /* router alert option type */ - PACK_STRUCT_FLD_8(u8_t _ra_opt_type); - /* router alert option data len */ - PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen); - /* router alert option data */ - PACK_STRUCT_FIELD(u16_t _ra_opt_data); - /* PadN option type */ - PACK_STRUCT_FLD_8(u8_t _padn_opt_type); - /* PadN option data len */ - PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Fragment header. */ -#define IP6_FRAG_HLEN 8 -#define IP6_FRAG_OFFSET_MASK 0xfff8 -#define IP6_FRAG_MORE_FLAG 0x0001 -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_frag_hdr { - /* next header */ - PACK_STRUCT_FLD_8(u8_t _nexth); - /* reserved */ - PACK_STRUCT_FLD_8(u8_t reserved); - /* fragment offset */ - PACK_STRUCT_FIELD(u16_t _fragment_offset); - /* fragmented packet identification */ - PACK_STRUCT_FIELD(u32_t _identification); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) -#define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) -#define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff) -#define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen)) -#define IP6H_NEXTH(hdr) ((hdr)->_nexth) -#define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) -#define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) - -#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) -#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen) -#define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) -#define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_IP6_H */ diff --git a/include/net/prot/mld6.h b/include/net/prot/mld6.h deleted file mode 100644 index 8989a57..0000000 --- a/include/net/prot/mld6.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * MLD6 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_MLD6_H -#define LWIP_HDR_PROT_MLD6_H - -#include "lwip/arch.h" -#include "lwip/prot/ip6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Multicast listener report/query/done message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct mld_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t max_resp_delay); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_MLD6_H */ diff --git a/include/net/prot/nd6.h b/include/net/prot/nd6.h deleted file mode 100644 index e6999df..0000000 --- a/include/net/prot/nd6.h +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @file - * ND6 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_ND6_H -#define LWIP_HDR_PROT_ND6_H - -#include "lwip/arch.h" -#include "lwip/ip6_addr.h" -#include "lwip/prot/ip6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Neighbor solicitation message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ns_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Neighbor advertisement message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct na_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FLD_8(u8_t flags); - PACK_STRUCT_FLD_8(u8_t reserved[3]); - PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif -#define ND6_FLAG_ROUTER (0x80) -#define ND6_FLAG_SOLICITED (0x40) -#define ND6_FLAG_OVERRIDE (0x20) - -/** Router solicitation message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct rs_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Router advertisement message header. */ -#define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80) -#define ND6_RA_FLAG_OTHER_CONFIG (0x40) -#define ND6_RA_FLAG_HOME_AGENT (0x20) -#define ND6_RA_PREFERENCE_MASK (0x18) -#define ND6_RA_PREFERENCE_HIGH (0x08) -#define ND6_RA_PREFERENCE_MEDIUM (0x00) -#define ND6_RA_PREFERENCE_LOW (0x18) -#define ND6_RA_PREFERENCE_DISABLED (0x10) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ra_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FLD_8(u8_t current_hop_limit); - PACK_STRUCT_FLD_8(u8_t flags); - PACK_STRUCT_FIELD(u16_t router_lifetime); - PACK_STRUCT_FIELD(u32_t reachable_time); - PACK_STRUCT_FIELD(u32_t retrans_timer); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Redirect message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct redirect_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); - PACK_STRUCT_FLD_S(ip6_addr_p_t destination_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Link-layer address option. */ -#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01) -#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct lladdr_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t addr[NETIF_MAX_HWADDR_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Prefix information option. */ -#define ND6_OPTION_TYPE_PREFIX_INFO (0x03) -#define ND6_PREFIX_FLAG_ON_LINK (0x80) -#define ND6_PREFIX_FLAG_AUTONOMOUS (0x40) -#define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20) -#define ND6_PREFIX_FLAG_SITE_PREFIX (0x10) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct prefix_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t prefix_length); - PACK_STRUCT_FLD_8(u8_t flags); - PACK_STRUCT_FIELD(u32_t valid_lifetime); - PACK_STRUCT_FIELD(u32_t preferred_lifetime); - PACK_STRUCT_FLD_8(u8_t reserved2[3]); - PACK_STRUCT_FLD_8(u8_t site_prefix_length); - PACK_STRUCT_FLD_S(ip6_addr_p_t prefix); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Redirected header option. */ -#define ND6_OPTION_TYPE_REDIR_HDR (0x04) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct redirected_header_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t reserved[6]); - /* Portion of redirected packet follows. */ - /* PACK_STRUCT_FLD_8(u8_t redirected[8]); */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** MTU option. */ -#define ND6_OPTION_TYPE_MTU (0x05) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct mtu_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FIELD(u32_t mtu); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Route information option. */ -#define ND6_OPTION_TYPE_ROUTE_INFO (24) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct route_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t prefix_length); - PACK_STRUCT_FLD_8(u8_t preference); - PACK_STRUCT_FIELD(u32_t route_lifetime); - PACK_STRUCT_FLD_S(ip6_addr_p_t prefix); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Recursive DNS Server Option. */ -#if LWIP_ND6_RDNSS_MAX_DNS_SERVERS -#define LWIP_RDNSS_OPTION_MAX_SERVERS LWIP_ND6_RDNSS_MAX_DNS_SERVERS -#else -#define LWIP_RDNSS_OPTION_MAX_SERVERS 1 -#endif -#define ND6_OPTION_TYPE_RDNSS (25) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct rdnss_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FIELD(u32_t lifetime); - PACK_STRUCT_FLD_S(ip6_addr_p_t rdnss_address[LWIP_RDNSS_OPTION_MAX_SERVERS]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_ND6_H */ diff --git a/include/net/prot/tcp.h b/include/net/prot/tcp.h deleted file mode 100644 index 3c4444a..0000000 --- a/include/net/prot/tcp.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file - * TCP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_TCP_H -#define LWIP_HDR_PROT_TCP_H - -#include "net/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Length of the TCP header, excluding options. */ -#define TCP_HLEN 20 - -/* Fields are (of course) in network byte order. - * Some fields are converted to host byte order in tcp_input(). - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct tcp_hdr { - PACK_STRUCT_FIELD(u16_t src); - PACK_STRUCT_FIELD(u16_t dest); - PACK_STRUCT_FIELD(u32_t seqno); - PACK_STRUCT_FIELD(u32_t ackno); - PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); - PACK_STRUCT_FIELD(u16_t wnd); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t urgp); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* TCP header flags bits */ -#define TCP_FIN 0x01U -#define TCP_SYN 0x02U -#define TCP_RST 0x04U -#define TCP_PSH 0x08U -#define TCP_ACK 0x10U -#define TCP_URG 0x20U -#define TCP_ECE 0x40U -#define TCP_CWR 0x80U -/* Valid TCP header flags */ -#define TCP_FLAGS 0x3fU - -#define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) -#define TCPH_FLAGS(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)) - -#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr)) -#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags)) -#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = (u16_t)(lwip_htons((u16_t)((len) << 12) | (flags))) - -#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags)) -#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags)) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_TCP_H */ diff --git a/include/net/prot/udp.h b/include/net/prot/udp.h deleted file mode 100644 index 2b1d8b5..0000000 --- a/include/net/prot/udp.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file - * UDP protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_UDP_H -#define LWIP_HDR_PROT_UDP_H - -#include "net/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define UDP_HLEN 8 - -/* Fields are (of course) in network byte order. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct udp_hdr { - PACK_STRUCT_FIELD(u16_t src); - PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ - PACK_STRUCT_FIELD(u16_t len); - PACK_STRUCT_FIELD(u16_t chksum); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_UDP_H */ diff --git a/include/net/raw.h b/include/net/raw.h deleted file mode 100644 index 5ced3e1..0000000 --- a/include/net/raw.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file - * raw API (to be used from TCPIP thread)\n - * See also @ref raw_raw - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_RAW_H -#define LWIP_HDR_RAW_H - -#include "net/opt.h" - -#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/def.h" -#include "net/ip.h" -#include "net/ip_addr.h" -#include "net/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct raw_pcb; - -/** Function prototype for raw pcb receive callback functions. - * @param arg user supplied argument (raw_pcb.recv_arg) - * @param pcb the raw_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IP address from which the packet was received - * @return 1 if the packet was 'eaten' (aka. deleted), - * 0 if the packet lives on - * If returning 1, the callback is responsible for freeing the pbuf - * if it's not used any more. - */ -typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, - const ip_addr_t *addr); - -/** the RAW protocol control block */ -struct raw_pcb { - /* Common members of all PCB types */ - IP_PCB; - - struct raw_pcb *next; - - u8_t protocol; - - /** receive callback function */ - raw_recv_fn recv; - /* user-supplied argument for the recv callback */ - void *recv_arg; -#if LWIP_IPV6 - /* fields for handling checksum computations as per RFC3542. */ - u16_t chksum_offset; - u8_t chksum_reqd; -#endif -}; - -/* The following functions is the application layer interface to the - RAW code. */ -struct raw_pcb * raw_new (u8_t proto); -struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto); -void raw_remove (struct raw_pcb *pcb); -err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr); -err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr); - -err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr); -err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); - -void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); - -/* The following functions are the lower layer interface to RAW. */ -u8_t raw_input (struct pbuf *p, struct netif *inp); -#define raw_init() /* Compatibility define, no init needed. */ - -void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); - -/* for compatibility with older implementation */ -#define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_RAW */ - -#endif /* LWIP_HDR_RAW_H */ diff --git a/include/net/sio.h b/include/net/sio.h deleted file mode 100644 index fff6d25..0000000 --- a/include/net/sio.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - */ - -/* - * This is the interface to the platform specific serial IO module - * It needs to be implemented by those platforms which need SLIP or PPP - */ - -#ifndef SIO_H -#define SIO_H - -#include "net/arch.h" -#include "net/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* If you want to define sio_fd_t elsewhere or differently, - define this in your cc.h file. */ -#ifndef __sio_fd_t_defined -typedef void * sio_fd_t; -#endif - -/* The following functions can be defined to something else in your cc.h file - or be implemented in your custom sio.c file. */ - -#ifndef sio_open -/** - * Opens a serial device for communication. - * - * @param devnum device number - * @return handle to serial device if successful, NULL otherwise - */ -sio_fd_t sio_open(u8_t devnum); -#endif - -#ifndef sio_send -/** - * Sends a single character to the serial device. - * - * @param c character to send - * @param fd serial device handle - * - * @note This function will block until the character can be sent. - */ -void sio_send(u8_t c, sio_fd_t fd); -#endif - -#ifndef sio_recv -/** - * Receives a single character from the serial device. - * - * @param fd serial device handle - * - * @note This function will block until a character is received. - */ -u8_t sio_recv(sio_fd_t fd); -#endif - -#ifndef sio_read -/** - * Reads from the serial device. - * - * @param fd serial device handle - * @param data pointer to data buffer for receiving - * @param len maximum length (in bytes) of data to receive - * @return number of bytes actually received - may be 0 if aborted by sio_read_abort - * - * @note This function will block until data can be received. The blocking - * can be cancelled by calling sio_read_abort(). - */ -u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_tryread -/** - * Tries to read from the serial device. Same as sio_read but returns - * immediately if no data is available and never blocks. - * - * @param fd serial device handle - * @param data pointer to data buffer for receiving - * @param len maximum length (in bytes) of data to receive - * @return number of bytes actually received - */ -u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_write -/** - * Writes to the serial device. - * - * @param fd serial device handle - * @param data pointer to data to send - * @param len length (in bytes) of data to send - * @return number of bytes actually sent - * - * @note This function will block until all data can be sent. - */ -u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_read_abort -/** - * Aborts a blocking sio_read() call. - * - * @param fd serial device handle - */ -void sio_read_abort(sio_fd_t fd); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SIO_H */ diff --git a/include/net/snmp.h b/include/net/snmp.h deleted file mode 100644 index ba2dd54..0000000 --- a/include/net/snmp.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @file - * SNMP support API for implementing netifs and statitics for MIB2 - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Dirk Ziegelmeier - * - */ -#ifndef LWIP_HDR_SNMP_H -#define LWIP_HDR_SNMP_H - -#include "net/opt.h" -#include "net/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct udp_pcb; -struct netif; - -/** - * @defgroup netif_mib2 MIB2 statistics - * @ingroup netif - */ - -/* MIB2 statistics functions */ -#if MIB2_STATS /* don't build if not configured for use in lwipopts.h */ -/** - * @ingroup netif_mib2 - * @see RFC1213, "MIB-II, 6. Definitions" - */ -enum snmp_ifType { - snmp_ifType_other=1, /* none of the following */ - snmp_ifType_regular1822, - snmp_ifType_hdh1822, - snmp_ifType_ddn_x25, - snmp_ifType_rfc877_x25, - snmp_ifType_ethernet_csmacd, - snmp_ifType_iso88023_csmacd, - snmp_ifType_iso88024_tokenBus, - snmp_ifType_iso88025_tokenRing, - snmp_ifType_iso88026_man, - snmp_ifType_starLan, - snmp_ifType_proteon_10Mbit, - snmp_ifType_proteon_80Mbit, - snmp_ifType_hyperchannel, - snmp_ifType_fddi, - snmp_ifType_lapb, - snmp_ifType_sdlc, - snmp_ifType_ds1, /* T-1 */ - snmp_ifType_e1, /* european equiv. of T-1 */ - snmp_ifType_basicISDN, - snmp_ifType_primaryISDN, /* proprietary serial */ - snmp_ifType_propPointToPointSerial, - snmp_ifType_ppp, - snmp_ifType_softwareLoopback, - snmp_ifType_eon, /* CLNP over IP [11] */ - snmp_ifType_ethernet_3Mbit, - snmp_ifType_nsip, /* XNS over IP */ - snmp_ifType_slip, /* generic SLIP */ - snmp_ifType_ultra, /* ULTRA technologies */ - snmp_ifType_ds3, /* T-3 */ - snmp_ifType_sip, /* SMDS */ - snmp_ifType_frame_relay -}; - -/** This macro has a precision of ~49 days because sys_now returns u32_t. \#define your own if you want ~490 days. */ -#ifndef MIB2_COPY_SYSUPTIME_TO -#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10)) -#endif - -/** - * @ingroup netif_mib2 - * Increment stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs) - */ -#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0) -/** - * @ingroup netif_mib2 - * Add value to stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs) - */ -#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0) - -/** - * @ingroup netif_mib2 - * Init MIB2 statistic counters in netif - * @param netif Netif to init - * @param type one of enum @ref snmp_ifType - * @param speed your link speed here (units: bits per second) - */ -#define MIB2_INIT_NETIF(netif, type, speed) do { \ - (netif)->link_type = (type); \ - (netif)->link_speed = (speed);\ - (netif)->ts = 0; \ - (netif)->mib2_counters.ifinoctets = 0; \ - (netif)->mib2_counters.ifinucastpkts = 0; \ - (netif)->mib2_counters.ifinnucastpkts = 0; \ - (netif)->mib2_counters.ifindiscards = 0; \ - (netif)->mib2_counters.ifinerrors = 0; \ - (netif)->mib2_counters.ifinunknownprotos = 0; \ - (netif)->mib2_counters.ifoutoctets = 0; \ - (netif)->mib2_counters.ifoutucastpkts = 0; \ - (netif)->mib2_counters.ifoutnucastpkts = 0; \ - (netif)->mib2_counters.ifoutdiscards = 0; \ - (netif)->mib2_counters.ifouterrors = 0; } while(0) -#else /* MIB2_STATS */ -#ifndef MIB2_COPY_SYSUPTIME_TO -#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) -#endif -#define MIB2_INIT_NETIF(netif, type, speed) -#define MIB2_STATS_NETIF_INC(n, x) -#define MIB2_STATS_NETIF_ADD(n, x, val) -#endif /* MIB2_STATS */ - -/* LWIP MIB2 callbacks */ -#if LWIP_MIB2_CALLBACKS /* don't build if not configured for use in lwipopts.h */ -/* network interface */ -void mib2_netif_added(struct netif *ni); -void mib2_netif_removed(struct netif *ni); - -#if LWIP_IPV4 && LWIP_ARP -/* ARP (for atTable and ipNetToMediaTable) */ -void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip); -void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip); -#else /* LWIP_IPV4 && LWIP_ARP */ -#define mib2_add_arp_entry(ni,ip) -#define mib2_remove_arp_entry(ni,ip) -#endif /* LWIP_IPV4 && LWIP_ARP */ - -/* IP */ -#if LWIP_IPV4 -void mib2_add_ip4(struct netif *ni); -void mib2_remove_ip4(struct netif *ni); -void mib2_add_route_ip4(u8_t dflt, struct netif *ni); -void mib2_remove_route_ip4(u8_t dflt, struct netif *ni); -#endif /* LWIP_IPV4 */ - -/* UDP */ -#if LWIP_UDP -void mib2_udp_bind(struct udp_pcb *pcb); -void mib2_udp_unbind(struct udp_pcb *pcb); -#endif /* LWIP_UDP */ - -#else /* LWIP_MIB2_CALLBACKS */ -/* LWIP_MIB2_CALLBACKS support not available */ -/* define everything to be empty */ - -/* network interface */ -#define mib2_netif_added(ni) -#define mib2_netif_removed(ni) - -/* ARP */ -#define mib2_add_arp_entry(ni,ip) -#define mib2_remove_arp_entry(ni,ip) - -/* IP */ -#define mib2_add_ip4(ni) -#define mib2_remove_ip4(ni) -#define mib2_add_route_ip4(dflt, ni) -#define mib2_remove_route_ip4(dflt, ni) - -/* UDP */ -#define mib2_udp_bind(pcb) -#define mib2_udp_unbind(pcb) -#endif /* LWIP_MIB2_CALLBACKS */ - -/* for source-code compatibility reasons only, can be removed (not used internally) */ -#define NETIF_INIT_SNMP MIB2_INIT_NETIF -#define snmp_add_ifinoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifinoctets, value) -#define snmp_inc_ifinucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinucastpkts) -#define snmp_inc_ifinnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinnucastpkts) -#define snmp_inc_ifindiscards(ni) MIB2_STATS_NETIF_INC(ni, ifindiscards) -#define snmp_inc_ifinerrors(ni) MIB2_STATS_NETIF_INC(ni, ifinerrors) -#define snmp_inc_ifinunknownprotos(ni) MIB2_STATS_NETIF_INC(ni, ifinunknownprotos) -#define snmp_add_ifoutoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifoutoctets, value) -#define snmp_inc_ifoutucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutucastpkts) -#define snmp_inc_ifoutnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutnucastpkts) -#define snmp_inc_ifoutdiscards(ni) MIB2_STATS_NETIF_INC(ni, ifoutdiscards) -#define snmp_inc_ifouterrors(ni) MIB2_STATS_NETIF_INC(ni, ifouterrors) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_SNMP_H */ diff --git a/include/net/sockets.h b/include/net/sockets.h deleted file mode 100644 index a094de2..0000000 --- a/include/net/sockets.h +++ /dev/null @@ -1,592 +0,0 @@ -/** - * @file - * Socket API (to be used from non-TCPIP threads) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - -#ifndef LWIP_HDR_SOCKETS_H -#define LWIP_HDR_SOCKETS_H - -#include - -#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED - to prevent this code from redefining it. */ -#if !defined(sa_family_t) && !defined(SA_FAMILY_T_DEFINED) -typedef u8_t sa_family_t; -#endif -/* If your port already typedef's in_port_t, define IN_PORT_T_DEFINED - to prevent this code from redefining it. */ -#if !defined(in_port_t) && !defined(IN_PORT_T_DEFINED) -typedef u16_t in_port_t; -#endif - -#if LWIP_IPV4 -/* members are in network byte order */ -struct sockaddr_in { - u8_t sin_len; - sa_family_t sin_family; - in_port_t sin_port; - struct in_addr sin_addr; -#define SIN_ZERO_LEN 8 - char sin_zero[SIN_ZERO_LEN]; -}; -#endif /* LWIP_IPV4 */ - -#if LWIP_IPV6 -struct sockaddr_in6 { - u8_t sin6_len; /* length of this structure */ - sa_family_t sin6_family; /* AF_INET6 */ - in_port_t sin6_port; /* Transport layer port # */ - u32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - u32_t sin6_scope_id; /* Set of interfaces for scope */ -}; -#endif /* LWIP_IPV6 */ - -struct sockaddr { - u8_t sa_len; - sa_family_t sa_family; - char sa_data[14]; -}; - -struct sockaddr_storage { - u8_t s2_len; - sa_family_t ss_family; - char s2_data1[2]; - u32_t s2_data2[3]; -#if LWIP_IPV6 - u32_t s2_data3[3]; -#endif /* LWIP_IPV6 */ -}; - -/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED - to prevent this code from redefining it. */ -#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) -typedef u32_t socklen_t; -#endif - -struct lwip_sock; - -#if !LWIP_TCPIP_CORE_LOCKING -/** Maximum optlen used by setsockopt/getsockopt */ -#define LWIP_SETGETSOCKOPT_MAXOPTLEN 16 - -/** This struct is used to pass data to the set/getsockopt_internal - * functions running in tcpip_thread context (only a void* is allowed) */ -struct lwip_setgetsockopt_data { - /** socket index for which to change options */ - int s; - /** level of the option to process */ - int level; - /** name of the option to process */ - int optname; - /** set: value to set the option to - * get: value of the option is stored here */ -#if LWIP_MPU_COMPATIBLE - u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN]; -#else - union { - void *p; - const void *pc; - } optval; -#endif - /** size of *optval */ - socklen_t optlen; - /** if an error occurs, it is temporarily stored here */ - err_t err; - /** semaphore to wake up the calling task */ - void* completed_sem; -}; -#endif /* !LWIP_TCPIP_CORE_LOCKING */ - -#if !defined(iovec) -struct iovec { - void *iov_base; - size_t iov_len; -}; -#endif - -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen; - void *msg_control; - socklen_t msg_controllen; - int msg_flags; -}; - -/* Socket protocol types (TCP/UDP/RAW) */ -#define SOCK_STREAM 1 -#define SOCK_DGRAM 2 -#define SOCK_RAW 3 - -/* - * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c) - */ -#define SO_REUSEADDR 0x0004 /* Allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ - - -/* - * Additional options, not kept in so_options. - */ -#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ -#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_DONTLINGER ((int)(~SO_LINGER)) -#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */ -#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */ -#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ -#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */ -#define SO_NO_CHECK 0x100a /* don't create UDP checksum */ - - -/* - * Structure used for manipulating linger option. - */ -struct linger { - int l_onoff; /* option on/off */ - int l_linger; /* linger time in seconds */ -}; - -/* - * Level number for (get/set)sockopt() to apply to socket itself. - */ -#define SOL_SOCKET 0xfff /* options for socket level */ - - -#define AF_UNSPEC 0 -#define AF_INET 2 -#if LWIP_IPV6 -#define AF_INET6 10 -#else /* LWIP_IPV6 */ -#define AF_INET6 AF_UNSPEC -#endif /* LWIP_IPV6 */ -#define PF_INET AF_INET -#define PF_INET6 AF_INET6 -#define PF_UNSPEC AF_UNSPEC - -#define IPPROTO_IP 0 -#define IPPROTO_ICMP 1 -#define IPPROTO_TCP 6 -#define IPPROTO_UDP 17 -#if LWIP_IPV6 -#define IPPROTO_IPV6 41 -#define IPPROTO_ICMPV6 58 -#endif /* LWIP_IPV6 */ -#define IPPROTO_UDPLITE 136 -#define IPPROTO_RAW 255 - -/* Flags we can use with send and recv. */ -#define MSG_PEEK 0x01 /* Peeks at an incoming message */ -#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */ -#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */ -#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */ -#define MSG_MORE 0x10 /* Sender will send more */ - - -/* - * Options for level IPPROTO_IP - */ -#define IP_TOS 1 -#define IP_TTL 2 - -#if LWIP_TCP -/* - * Options for level IPPROTO_TCP - */ -#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ -#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */ -#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */ -#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */ -#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */ -#endif /* LWIP_TCP */ - -#if LWIP_IPV6 -/* - * Options for level IPPROTO_IPV6 - */ -#define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */ -#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */ -#endif /* LWIP_IPV6 */ - -#if LWIP_UDP && LWIP_UDPLITE -/* - * Options for level IPPROTO_UDPLITE - */ -#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ -#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ -#endif /* LWIP_UDP && LWIP_UDPLITE*/ - - -#if LWIP_MULTICAST_TX_OPTIONS -/* - * Options and types for UDP multicast traffic handling - */ -#define IP_MULTICAST_TTL 5 -#define IP_MULTICAST_IF 6 -#define IP_MULTICAST_LOOP 7 -#endif /* LWIP_MULTICAST_TX_OPTIONS */ - -#if LWIP_IGMP -/* - * Options and types related to multicast membership - */ -#define IP_ADD_MEMBERSHIP 3 -#define IP_DROP_MEMBERSHIP 4 - -typedef struct ip_mreq { - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_interface; /* local IP address of interface */ -} ip_mreq; -#endif /* LWIP_IGMP */ - -/* - * The Type of Service provides an indication of the abstract - * parameters of the quality of service desired. These parameters are - * to be used to guide the selection of the actual service parameters - * when transmitting a datagram through a particular network. Several - * networks offer service precedence, which somehow treats high - * precedence traffic as more important than other traffic (generally - * by accepting only traffic above a certain precedence at time of high - * load). The major choice is a three way tradeoff between low-delay, - * high-reliability, and high-throughput. - * The use of the Delay, Throughput, and Reliability indications may - * increase the cost (in some sense) of the service. In many networks - * better performance for one of these parameters is coupled with worse - * performance on another. Except for very unusual cases at most two - * of these three indications should be set. - */ -#define IPTOS_TOS_MASK 0x1E -#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#define IPTOS_LOWCOST 0x02 -#define IPTOS_MINCOST IPTOS_LOWCOST - -/* - * The Network Control precedence designation is intended to be used - * within a network only. The actual use and control of that - * designation is up to each network. The Internetwork Control - * designation is intended for use by gateway control originators only. - * If the actual use of these precedence designations is of concern to - * a particular network, it is the responsibility of that network to - * control the access to, and use of, those precedence designations. - */ -#define IPTOS_PREC_MASK 0xe0 -#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) -#define IPTOS_PREC_NETCONTROL 0xe0 -#define IPTOS_PREC_INTERNETCONTROL 0xc0 -#define IPTOS_PREC_CRITIC_ECP 0xa0 -#define IPTOS_PREC_FLASHOVERRIDE 0x80 -#define IPTOS_PREC_FLASH 0x60 -#define IPTOS_PREC_IMMEDIATE 0x40 -#define IPTOS_PREC_PRIORITY 0x20 -#define IPTOS_PREC_ROUTINE 0x00 - - -/* - * Commands for ioctlsocket(), taken from the BSD file fcntl.h. - * lwip_ioctl only supports FIONREAD and FIONBIO, for now - * - * Ioctl's have the command encoded in the lower word, - * and the size of any in or out parameters in the upper - * word. The high 2 bits of the upper word are used - * to encode the in/out status of the parameter; for now - * we restrict parameters to at most 128 bytes. - */ -#if !defined(FIONREAD) || !defined(FIONBIO) -#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000UL /* no parameters */ -#define IOC_OUT 0x40000000UL /* copy out parameters */ -#define IOC_IN 0x80000000UL /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) - /* 0x20000000 distinguishes new & - old ioctl's */ -#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) - -#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) - -#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) -#endif /* !defined(FIONREAD) || !defined(FIONBIO) */ - -#ifndef FIONREAD -#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */ -#endif -#ifndef FIONBIO -#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */ -#endif - -/* Socket I/O Controls: unimplemented */ -#ifndef SIOCSHIWAT -#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */ -#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */ -#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */ -#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */ -#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */ -#endif - -/* commands for fnctl */ -#ifndef F_GETFL -#define F_GETFL 3 -#endif -#ifndef F_SETFL -#define F_SETFL 4 -#endif - -/* File status flags and file access modes for fnctl, - these are bits in an int. */ -#ifndef O_NONBLOCK -#define O_NONBLOCK 1 /* nonblocking I/O */ -#endif -#ifndef O_NDELAY -#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */ -#endif - -#ifndef SHUT_RD - #define SHUT_RD 0 - #define SHUT_WR 1 - #define SHUT_RDWR 2 -#endif - -/* FD_SET used for lwip_select */ -#ifndef FD_SET -#undef FD_SETSIZE -/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */ -#define FD_SETSIZE MEMP_NUM_NETCONN -#define FDSETSAFESET(n, code) do { \ - if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \ - code; }} while(0) -#define FDSETSAFEGET(n, code) (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\ - (code) : 0) -#define FD_SET(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7))) -#define FD_CLR(n, p) FDSETSAFESET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7))) -#define FD_ISSET(n,p) FDSETSAFEGET(n, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7))) -#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p))) - -typedef struct fd_set -{ - unsigned char fd_bits [(FD_SETSIZE+7)/8]; -} fd_set; - -#elif LWIP_SOCKET_OFFSET -#error LWIP_SOCKET_OFFSET does not work with external FD_SET! -#elif FD_SETSIZE < MEMP_NUM_NETCONN -#error "external FD_SETSIZE too small for number of sockets" -#endif /* FD_SET */ - -/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided - * by your system, set this to 0 and include in cc.h */ -#ifndef LWIP_TIMEVAL_PRIVATE -#define LWIP_TIMEVAL_PRIVATE 1 -#endif - -#if LWIP_TIMEVAL_PRIVATE -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; -#endif /* LWIP_TIMEVAL_PRIVATE */ - -#define lwip_socket_init() /* Compatibility define, no init needed. */ -void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */ -void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */ - -#if LWIP_COMPAT_SOCKETS == 2 -/* This helps code parsers/code completion by not having the COMPAT functions as defines */ -#define lwip_accept accept -#define lwip_bind bind -#define lwip_shutdown shutdown -#define lwip_getpeername getpeername -#define lwip_getsockname getsockname -#define lwip_setsockopt setsockopt -#define lwip_getsockopt getsockopt -#define lwip_close closesocket -#define lwip_connect connect -#define lwip_listen listen -#define lwip_recv recv -#define lwip_recvfrom recvfrom -#define lwip_send send -#define lwip_sendmsg sendmsg -#define lwip_sendto sendto -#define lwip_socket socket -#define lwip_select select -#define lwip_ioctlsocket ioctl - -#if LWIP_POSIX_SOCKETS_IO_NAMES -#define lwip_read read -#define lwip_write write -#define lwip_writev writev -#undef lwip_close -#define lwip_close close -#define closesocket(s) close(s) -#define lwip_fcntl fcntl -#define lwip_ioctl ioctl -#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */ -#endif /* LWIP_COMPAT_SOCKETS == 2 */ - -int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen); -int lwip_shutdown(int s, int how); -int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); -int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); -int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); -int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); -int lwip_close(int s); -int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); -int lwip_listen(int s, int backlog); -int lwip_recv(int s, void *mem, size_t len, int flags); -int lwip_read(int s, void *mem, size_t len); -int lwip_recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen); -int lwip_send(int s, const void *dataptr, size_t size, int flags); -int lwip_sendmsg(int s, const struct msghdr *message, int flags); -int lwip_sendto(int s, const void *dataptr, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen); -int lwip_socket(int domain, int type, int protocol); -int lwip_write(int s, const void *dataptr, size_t size); -int lwip_writev(int s, const struct iovec *iov, int iovcnt); -int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); -int lwip_ioctl(int s, long cmd, void *argp); -int lwip_fcntl(int s, int cmd, int val); - -#if LWIP_COMPAT_SOCKETS -#if LWIP_COMPAT_SOCKETS != 2 -/** @ingroup socket */ -#define accept(s,addr,addrlen) lwip_accept(s,addr,addrlen) -/** @ingroup socket */ -#define bind(s,name,namelen) lwip_bind(s,name,namelen) -/** @ingroup socket */ -#define shutdown(s,how) lwip_shutdown(s,how) -/** @ingroup socket */ -#define getpeername(s,name,namelen) lwip_getpeername(s,name,namelen) -/** @ingroup socket */ -#define getsockname(s,name,namelen) lwip_getsockname(s,name,namelen) -/** @ingroup socket */ -#define setsockopt(s,level,optname,opval,optlen) lwip_setsockopt(s,level,optname,opval,optlen) -/** @ingroup socket */ -#define getsockopt(s,level,optname,opval,optlen) lwip_getsockopt(s,level,optname,opval,optlen) -/** @ingroup socket */ -#define closesocket(s) lwip_close(s) -/** @ingroup socket */ -#define connect(s,name,namelen) lwip_connect(s,name,namelen) -/** @ingroup socket */ -#define listen(s,backlog) lwip_listen(s,backlog) -/** @ingroup socket */ -#define recv(s,mem,len,flags) lwip_recv(s,mem,len,flags) -/** @ingroup socket */ -#define recvfrom(s,mem,len,flags,from,fromlen) lwip_recvfrom(s,mem,len,flags,from,fromlen) -/** @ingroup socket */ -#define send(s,dataptr,size,flags) lwip_send(s,dataptr,size,flags) -/** @ingroup socket */ -#define sendmsg(s,message,flags) lwip_sendmsg(s,message,flags) -/** @ingroup socket */ -#define sendto(s,dataptr,size,flags,to,tolen) lwip_sendto(s,dataptr,size,flags,to,tolen) -/** @ingroup socket */ -#define socket(domain,type,protocol) lwip_socket(domain,type,protocol) -/** @ingroup socket */ -#define select(maxfdp1,readset,writeset,exceptset,timeout) lwip_select(maxfdp1,readset,writeset,exceptset,timeout) -/** @ingroup socket */ -#define ioctlsocket(s,cmd,argp) lwip_ioctl(s,cmd,argp) - -#if LWIP_POSIX_SOCKETS_IO_NAMES -/** @ingroup socket */ -#define read(s,mem,len) lwip_read(s,mem,len) -/** @ingroup socket */ -#define write(s,dataptr,len) lwip_write(s,dataptr,len) -/** @ingroup socket */ -#define writev(s,iov,iovcnt) lwip_writev(s,iov,iovcnt) -/** @ingroup socket */ -#define close(s) lwip_close(s) -/** @ingroup socket */ -#define fcntl(s,cmd,val) lwip_fcntl(s,cmd,val) -/** @ingroup socket */ -#define ioctl(s,cmd,argp) lwip_ioctl(s,cmd,argp) -#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */ -#endif /* LWIP_COMPAT_SOCKETS != 2 */ - -#if LWIP_IPV4 && LWIP_IPV6 -/** @ingroup socket */ -#define inet_ntop(af,src,dst,size) \ - (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) \ - : (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL)) -/** @ingroup socket */ -#define inet_pton(af,src,dst) \ - (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) \ - : (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0)) -#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */ -#define inet_ntop(af,src,dst,size) \ - (((af) == AF_INET) ? ip4addr_ntoa_r((const ip4_addr_t*)(src),(dst),(size)) : NULL) -#define inet_pton(af,src,dst) \ - (((af) == AF_INET) ? ip4addr_aton((src),(ip4_addr_t*)(dst)) : 0) -#else /* LWIP_IPV4 && LWIP_IPV6 */ -#define inet_ntop(af,src,dst,size) \ - (((af) == AF_INET6) ? ip6addr_ntoa_r((const ip6_addr_t*)(src),(dst),(size)) : NULL) -#define inet_pton(af,src,dst) \ - (((af) == AF_INET6) ? ip6addr_aton((src),(ip6_addr_t*)(dst)) : 0) -#endif /* LWIP_IPV4 && LWIP_IPV6 */ - -#endif /* LWIP_COMPAT_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SOCKET */ - -#endif /* LWIP_HDR_SOCKETS_H */ diff --git a/include/net/stats.h b/include/net/stats.h deleted file mode 100644 index 6cec14a..0000000 --- a/include/net/stats.h +++ /dev/null @@ -1,491 +0,0 @@ -/** - * @file - * Statistics API (to be used from TCPIP thread) - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_STATS_H -#define LWIP_HDR_STATS_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_STATS - -#ifndef LWIP_STATS_LARGE -#define LWIP_STATS_LARGE 0 -#endif - -#if LWIP_STATS_LARGE -#define STAT_COUNTER u32_t -#define STAT_COUNTER_F U32_F -#else -#define STAT_COUNTER u16_t -#define STAT_COUNTER_F U16_F -#endif - -/** Protocol related stats */ -struct stats_proto { - STAT_COUNTER xmit; /* Transmitted packets. */ - STAT_COUNTER recv; /* Received packets. */ - STAT_COUNTER fw; /* Forwarded packets. */ - STAT_COUNTER drop; /* Dropped packets. */ - STAT_COUNTER chkerr; /* Checksum error. */ - STAT_COUNTER lenerr; /* Invalid length error. */ - STAT_COUNTER memerr; /* Out of memory error. */ - STAT_COUNTER rterr; /* Routing error. */ - STAT_COUNTER proterr; /* Protocol error. */ - STAT_COUNTER opterr; /* Error in options. */ - STAT_COUNTER err; /* Misc error. */ - STAT_COUNTER cachehit; -}; - -/** IGMP stats */ -struct stats_igmp { - STAT_COUNTER xmit; /* Transmitted packets. */ - STAT_COUNTER recv; /* Received packets. */ - STAT_COUNTER drop; /* Dropped packets. */ - STAT_COUNTER chkerr; /* Checksum error. */ - STAT_COUNTER lenerr; /* Invalid length error. */ - STAT_COUNTER memerr; /* Out of memory error. */ - STAT_COUNTER proterr; /* Protocol error. */ - STAT_COUNTER rx_v1; /* Received v1 frames. */ - STAT_COUNTER rx_group; /* Received group-specific queries. */ - STAT_COUNTER rx_general; /* Received general queries. */ - STAT_COUNTER rx_report; /* Received reports. */ - STAT_COUNTER tx_join; /* Sent joins. */ - STAT_COUNTER tx_leave; /* Sent leaves. */ - STAT_COUNTER tx_report; /* Sent reports. */ -}; - -/** Memory stats */ -struct stats_mem { -#if defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY - const char *name; -#endif /* defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY */ - STAT_COUNTER err; - mem_size_t avail; - mem_size_t used; - mem_size_t max; - STAT_COUNTER illegal; -}; - -/** System element stats */ -struct stats_syselem { - STAT_COUNTER used; - STAT_COUNTER max; - STAT_COUNTER err; -}; - -/** System stats */ -struct stats_sys { - struct stats_syselem sem; - struct stats_syselem mutex; - struct stats_syselem mbox; -}; - -/** SNMP MIB2 stats */ -struct stats_mib2 { - /* IP */ - u32_t ipinhdrerrors; - u32_t ipinaddrerrors; - u32_t ipinunknownprotos; - u32_t ipindiscards; - u32_t ipindelivers; - u32_t ipoutrequests; - u32_t ipoutdiscards; - u32_t ipoutnoroutes; - u32_t ipreasmoks; - u32_t ipreasmfails; - u32_t ipfragoks; - u32_t ipfragfails; - u32_t ipfragcreates; - u32_t ipreasmreqds; - u32_t ipforwdatagrams; - u32_t ipinreceives; - - /* TCP */ - u32_t tcpactiveopens; - u32_t tcppassiveopens; - u32_t tcpattemptfails; - u32_t tcpestabresets; - u32_t tcpoutsegs; - u32_t tcpretranssegs; - u32_t tcpinsegs; - u32_t tcpinerrs; - u32_t tcpoutrsts; - - /* UDP */ - u32_t udpindatagrams; - u32_t udpnoports; - u32_t udpinerrors; - u32_t udpoutdatagrams; - - /* ICMP */ - u32_t icmpinmsgs; - u32_t icmpinerrors; - u32_t icmpindestunreachs; - u32_t icmpintimeexcds; - u32_t icmpinparmprobs; - u32_t icmpinsrcquenchs; - u32_t icmpinredirects; - u32_t icmpinechos; - u32_t icmpinechoreps; - u32_t icmpintimestamps; - u32_t icmpintimestampreps; - u32_t icmpinaddrmasks; - u32_t icmpinaddrmaskreps; - u32_t icmpoutmsgs; - u32_t icmpouterrors; - u32_t icmpoutdestunreachs; - u32_t icmpouttimeexcds; - u32_t icmpoutechos; /* can be incremented by user application ('ping') */ - u32_t icmpoutechoreps; -}; - -/** - * @ingroup netif_mib2 - * SNMP MIB2 interface stats - */ -struct stats_mib2_netif_ctrs { - /** The total number of octets received on the interface, including framing characters */ - u32_t ifinoctets; - /** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were - * not addressed to a multicast or broadcast address at this sub-layer */ - u32_t ifinucastpkts; - /** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were - * addressed to a multicast or broadcast address at this sub-layer */ - u32_t ifinnucastpkts; - /** The number of inbound packets which were chosen to be discarded even though no errors had - * been detected to prevent their being deliverable to a higher-layer protocol. One possible - * reason for discarding such a packet could be to free up buffer space */ - u32_t ifindiscards; - /** For packet-oriented interfaces, the number of inbound packets that contained errors - * preventing them from being deliverable to a higher-layer protocol. For character- - * oriented or fixed-length interfaces, the number of inbound transmission units that - * contained errors preventing them from being deliverable to a higher-layer protocol. */ - u32_t ifinerrors; - /** For packet-oriented interfaces, the number of packets received via the interface which - * were discarded because of an unknown or unsupported protocol. For character-oriented - * or fixed-length interfaces that support protocol multiplexing the number of transmission - * units received via the interface which were discarded because of an unknown or unsupported - * protocol. For any interface that does not support protocol multiplexing, this counter will - * always be 0 */ - u32_t ifinunknownprotos; - /** The total number of octets transmitted out of the interface, including framing characters. */ - u32_t ifoutoctets; - /** The total number of packets that higher-level protocols requested be transmitted, and - * which were not addressed to a multicast or broadcast address at this sub-layer, including - * those that were discarded or not sent. */ - u32_t ifoutucastpkts; - /** The total number of packets that higher-level protocols requested be transmitted, and which - * were addressed to a multicast or broadcast address at this sub-layer, including - * those that were discarded or not sent. */ - u32_t ifoutnucastpkts; - /** The number of outbound packets which were chosen to be discarded even though no errors had - * been detected to prevent their being transmitted. One possible reason for discarding - * such a packet could be to free up buffer space. */ - u32_t ifoutdiscards; - /** For packet-oriented interfaces, the number of outbound packets that could not be transmitted - * because of errors. For character-oriented or fixed-length interfaces, the number of outbound - * transmission units that could not be transmitted because of errors. */ - u32_t ifouterrors; -}; - -/** lwIP stats container */ -struct stats_ { -#if LINK_STATS - /** Link level */ - struct stats_proto link; -#endif -#if ETHARP_STATS - /** ARP */ - struct stats_proto etharp; -#endif -#if IPFRAG_STATS - /** Fragmentation */ - struct stats_proto ip_frag; -#endif -#if IP_STATS - /** IP */ - struct stats_proto ip; -#endif -#if ICMP_STATS - /** ICMP */ - struct stats_proto icmp; -#endif -#if IGMP_STATS - /** IGMP */ - struct stats_igmp igmp; -#endif -#if UDP_STATS - /** UDP */ - struct stats_proto udp; -#endif -#if TCP_STATS - /** TCP */ - struct stats_proto tcp; -#endif -#if MEM_STATS - /** Heap */ - struct stats_mem mem; -#endif -#if MEMP_STATS - /** Internal memory pools */ - struct stats_mem *memp[MEMP_MAX]; -#endif -#if SYS_STATS - /** System */ - struct stats_sys sys; -#endif -#if IP6_STATS - /** IPv6 */ - struct stats_proto ip6; -#endif -#if ICMP6_STATS - /** ICMP6 */ - struct stats_proto icmp6; -#endif -#if IP6_FRAG_STATS - /** IPv6 fragmentation */ - struct stats_proto ip6_frag; -#endif -#if MLD6_STATS - /** Multicast listener discovery */ - struct stats_igmp mld6; -#endif -#if ND6_STATS - /** Neighbor discovery */ - struct stats_proto nd6; -#endif -#if MIB2_STATS - /** SNMP MIB2 */ - struct stats_mib2 mib2; -#endif -}; - -/** Global variable containing lwIP internal statistics. Add this to your debugger's watchlist. */ -extern struct stats_ lwip_stats; - -/** Init statistics */ -void stats_init(void); - -#define STATS_INC(x) ++lwip_stats.x -#define STATS_DEC(x) --lwip_stats.x -#define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \ - if (lwip_stats.x.max < lwip_stats.x.used) { \ - lwip_stats.x.max = lwip_stats.x.used; \ - } \ - } while(0) -#define STATS_GET(x) lwip_stats.x -#else /* LWIP_STATS */ -#define stats_init() -#define STATS_INC(x) -#define STATS_DEC(x) -#define STATS_INC_USED(x) -#endif /* LWIP_STATS */ - -#if TCP_STATS -#define TCP_STATS_INC(x) STATS_INC(x) -#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP") -#else -#define TCP_STATS_INC(x) -#define TCP_STATS_DISPLAY() -#endif - -#if UDP_STATS -#define UDP_STATS_INC(x) STATS_INC(x) -#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP") -#else -#define UDP_STATS_INC(x) -#define UDP_STATS_DISPLAY() -#endif - -#if ICMP_STATS -#define ICMP_STATS_INC(x) STATS_INC(x) -#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP") -#else -#define ICMP_STATS_INC(x) -#define ICMP_STATS_DISPLAY() -#endif - -#if IGMP_STATS -#define IGMP_STATS_INC(x) STATS_INC(x) -#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp, "IGMP") -#else -#define IGMP_STATS_INC(x) -#define IGMP_STATS_DISPLAY() -#endif - -#if IP_STATS -#define IP_STATS_INC(x) STATS_INC(x) -#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP") -#else -#define IP_STATS_INC(x) -#define IP_STATS_DISPLAY() -#endif - -#if IPFRAG_STATS -#define IPFRAG_STATS_INC(x) STATS_INC(x) -#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG") -#else -#define IPFRAG_STATS_INC(x) -#define IPFRAG_STATS_DISPLAY() -#endif - -#if ETHARP_STATS -#define ETHARP_STATS_INC(x) STATS_INC(x) -#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP") -#else -#define ETHARP_STATS_INC(x) -#define ETHARP_STATS_DISPLAY() -#endif - -#if LINK_STATS -#define LINK_STATS_INC(x) STATS_INC(x) -#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK") -#else -#define LINK_STATS_INC(x) -#define LINK_STATS_DISPLAY() -#endif - -#if MEM_STATS -#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y -#define MEM_STATS_INC(x) SYS_ARCH_INC(lwip_stats.mem.x, 1) -#define MEM_STATS_INC_USED(x, y) SYS_ARCH_INC(lwip_stats.mem.x, y) -#define MEM_STATS_DEC_USED(x, y) SYS_ARCH_DEC(lwip_stats.mem.x, y) -#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP") -#else -#define MEM_STATS_AVAIL(x, y) -#define MEM_STATS_INC(x) -#define MEM_STATS_INC_USED(x, y) -#define MEM_STATS_DEC_USED(x, y) -#define MEM_STATS_DISPLAY() -#endif - - #if MEMP_STATS -#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i]->x) -#define MEMP_STATS_DISPLAY(i) stats_display_memp(lwip_stats.memp[i], i) -#define MEMP_STATS_GET(x, i) STATS_GET(memp[i]->x) - #else -#define MEMP_STATS_DEC(x, i) -#define MEMP_STATS_DISPLAY(i) -#define MEMP_STATS_GET(x, i) 0 -#endif - -#if SYS_STATS -#define SYS_STATS_INC(x) STATS_INC(sys.x) -#define SYS_STATS_DEC(x) STATS_DEC(sys.x) -#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1) -#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys) -#else -#define SYS_STATS_INC(x) -#define SYS_STATS_DEC(x) -#define SYS_STATS_INC_USED(x) -#define SYS_STATS_DISPLAY() -#endif - -#if IP6_STATS -#define IP6_STATS_INC(x) STATS_INC(x) -#define IP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6, "IPv6") -#else -#define IP6_STATS_INC(x) -#define IP6_STATS_DISPLAY() -#endif - -#if ICMP6_STATS -#define ICMP6_STATS_INC(x) STATS_INC(x) -#define ICMP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp6, "ICMPv6") -#else -#define ICMP6_STATS_INC(x) -#define ICMP6_STATS_DISPLAY() -#endif - -#if IP6_FRAG_STATS -#define IP6_FRAG_STATS_INC(x) STATS_INC(x) -#define IP6_FRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6_frag, "IPv6 FRAG") -#else -#define IP6_FRAG_STATS_INC(x) -#define IP6_FRAG_STATS_DISPLAY() -#endif - -#if MLD6_STATS -#define MLD6_STATS_INC(x) STATS_INC(x) -#define MLD6_STATS_DISPLAY() stats_display_igmp(&lwip_stats.mld6, "MLDv1") -#else -#define MLD6_STATS_INC(x) -#define MLD6_STATS_DISPLAY() -#endif - -#if ND6_STATS -#define ND6_STATS_INC(x) STATS_INC(x) -#define ND6_STATS_DISPLAY() stats_display_proto(&lwip_stats.nd6, "ND") -#else -#define ND6_STATS_INC(x) -#define ND6_STATS_DISPLAY() -#endif - -#if MIB2_STATS -#define MIB2_STATS_INC(x) STATS_INC(x) -#else -#define MIB2_STATS_INC(x) -#endif - -/* Display of statistics */ -#if LWIP_STATS_DISPLAY -void stats_display(void); -void stats_display_proto(struct stats_proto *proto, const char *name); -void stats_display_igmp(struct stats_igmp *igmp, const char *name); -void stats_display_mem(struct stats_mem *mem, const char *name); -void stats_display_memp(struct stats_mem *mem, int index); -void stats_display_sys(struct stats_sys *sys); -#else /* LWIP_STATS_DISPLAY */ -#define stats_display() -#define stats_display_proto(proto, name) -#define stats_display_igmp(igmp, name) -#define stats_display_mem(mem, name) -#define stats_display_memp(mem, index) -#define stats_display_sys(sys) -#endif /* LWIP_STATS_DISPLAY */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_STATS_H */ diff --git a/include/net/sys.h b/include/net/sys.h deleted file mode 100644 index c7e73fa..0000000 --- a/include/net/sys.h +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - */ - -#ifndef NET_HDR_SYS_H -#define NET_HDR_SYS_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if NO_SYS - -#else /* NO_SYS */ - -/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ -#define SYS_ARCH_TIMEOUT 0xffffffffUL - -/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. - * For now we use the same magic value, but we allow this to change in future. - */ -#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT - -#include "net/err.h" -#include "net/arch/sys_arch.h" - -/** Function prototype for thread functions */ -typedef void (*lwip_thread_fn)(void *arg); - -/* Function prototypes for functions to be implemented by platform ports - (in sys_arch.c) */ - -/* Mutex functions: */ - -/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores - should be used instead */ -#ifndef LWIP_COMPAT_MUTEX -#define LWIP_COMPAT_MUTEX 0 -#endif - -#if LWIP_COMPAT_MUTEX -/* for old ports that don't have mutexes: define them to binary semaphores */ -#define sys_mutex_t sys_sem_t -#define sys_mutex_new(mutex) sys_sem_new(mutex, 1) -#define sys_mutex_lock(mutex) sys_sem_wait(mutex) -#define sys_mutex_unlock(mutex) sys_sem_signal(mutex) -#define sys_mutex_free(mutex) sys_sem_free(mutex) -#define sys_mutex_valid(mutex) sys_sem_valid(mutex) -#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) - -#else /* LWIP_COMPAT_MUTEX */ - -/** - * @ingroup sys_mutex - * Create a new mutex. - * Note that mutexes are expected to not be taken recursively by the lwIP code, - * so both implementation types (recursive or non-recursive) should work. - * @param mutex pointer to the mutex to create - * @return ERR_OK if successful, another err_t otherwise - */ -err_t sys_mutex_new(sys_mutex_t *mutex); -/** - * @ingroup sys_mutex - * Lock a mutex - * @param mutex the mutex to lock - */ -void sys_mutex_lock(sys_mutex_t *mutex); -/** - * @ingroup sys_mutex - * Unlock a mutex - * @param mutex the mutex to unlock - */ -void sys_mutex_unlock(sys_mutex_t *mutex); -/** - * @ingroup sys_mutex - * Delete a semaphore - * @param mutex the mutex to delete - */ -void sys_mutex_free(sys_mutex_t *mutex); -#ifndef sys_mutex_valid -/** - * @ingroup sys_mutex - * Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid - */ -int sys_mutex_valid(sys_mutex_t *mutex); -#endif -#ifndef sys_mutex_set_invalid -/** - * @ingroup sys_mutex - * Set a mutex invalid so that sys_mutex_valid returns 0 - */ -void sys_mutex_set_invalid(sys_mutex_t *mutex); -#endif -#endif /* LWIP_COMPAT_MUTEX */ - -/* Semaphore functions: */ - -/** - * @ingroup sys_sem - * Create a new semaphore - * @param sem pointer to the semaphore to create - * @param count initial count of the semaphore - * @return ERR_OK if successful, another err_t otherwise - */ -err_t sys_sem_new(sys_sem_t **sem, u8_t count); -/** - * @ingroup sys_sem - * Signals a semaphore - * @param sem the semaphore to signal - */ -void sys_sem_signal(struct sys_sem **s); -/** - * @ingroup sys_sem - * Wait for a semaphore for the specified timeout - * @param sem the semaphore to wait for - * @param timeout timeout in milliseconds to wait (0 = wait forever) - * @return time (in milliseconds) waited for the semaphore - * or SYS_ARCH_TIMEOUT on timeout - */ -uint32_t sys_arch_sem_wait(struct sys_sem **s, uint32_t timeout); -/** - * @ingroup sys_sem - * Delete a semaphore - * @param sem semaphore to delete - */ -void sys_sem_free(sys_sem_t **sem); -/** Wait for a semaphore - forever/no timeout */ -#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0) -#ifndef sys_sem_valid -/** - * @ingroup sys_sem - * Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid - */ -int sys_sem_valid(struct sys_sem **s); -#endif -#ifndef sys_sem_set_invalid -/** - * @ingroup sys_sem - * Set a semaphore invalid so that sys_sem_valid returns 0 - */ -void sys_sem_set_invalid(struct sys_sem **s); -#endif -#ifndef sys_sem_valid_val -/** - * Same as sys_sem_valid() but taking a value, not a pointer - */ -#define sys_sem_valid_val(sem) sys_sem_valid(&(sem)) -#endif -#ifndef sys_sem_set_invalid_val -/** - * Same as sys_sem_set_invalid() but taking a value, not a pointer - */ -#define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem)) -#endif - -#ifndef sys_msleep -/** - * @ingroup sys_misc - * Sleep for specified number of ms - */ -void sys_msleep(u32_t ms); /* only has a (close to) 1 ms resolution. */ -#endif - -/* Mailbox functions. */ - -/** - * @ingroup sys_mbox - * Create a new mbox of specified size - * @param mbox pointer to the mbox to create - * @param size (minimum) number of messages in this mbox - * @return ERR_OK if successful, another err_t otherwise - */ -err_t sys_mbox_new(struct sys_mbox **mb, int size); -/** - * @ingroup sys_mbox - * Post a message to an mbox - may not fail - * -> blocks if full, only used from tasks not from ISR - * @param mbox mbox to posts the message - * @param msg message to post (ATTENTION: can be NULL) - */ -void sys_mbox_post(struct sys_mbox **mb, void *msg); -/** - * @ingroup sys_mbox - * Try to post a message to an mbox - may fail if full or ISR - * @param mbox mbox to posts the message - * @param msg message to post (ATTENTION: can be NULL) - */ -err_t sys_mbox_trypost(struct sys_mbox **mb, void *msg); -/** - * @ingroup sys_mbox - * Wait for a new message to arrive in the mbox - * @param mbox mbox to get a message from - * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever) - * @return time (in milliseconds) waited for a message, may be 0 if not waited - or SYS_ARCH_TIMEOUT on timeout - * The returned time has to be accurate to prevent timer jitter! - */ -uint32_t sys_arch_mbox_fetch(struct sys_mbox **mb, void **msg, uint32_t timeout); -/* Allow port to override with a macro, e.g. special timeout for sys_arch_mbox_fetch() */ -#ifndef sys_arch_mbox_tryfetch -/** - * @ingroup sys_mbox - * Wait for a new message to arrive in the mbox - * @param mbox mbox to get a message from - * @param msg pointer where the message is stored - * @return 0 (milliseconds) if a message has been received - * or SYS_MBOX_EMPTY if the mailbox is empty - */ -uint32_t sys_arch_mbox_tryfetch(struct sys_mbox **mb, void **msg); -#endif -/** - * For now, we map straight to sys_arch implementation. - */ -#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) -/** - * @ingroup sys_mbox - * Delete an mbox - * @param mbox mbox to delete - */ -void sys_mbox_free(struct sys_mbox **mb); -#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0) -#ifndef sys_mbox_valid -/** - * @ingroup sys_mbox - * Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid - */ -int sys_mbox_valid(struct sys_mbox **mb); -#endif -#ifndef sys_mbox_set_invalid -/** - * @ingroup sys_mbox - * Set an mbox invalid so that sys_mbox_valid returns 0 - */ -void sys_mbox_set_invalid(struct sys_mbox **mb); -#endif -#ifndef sys_mbox_valid_val -/** - * Same as sys_mbox_valid() but taking a value, not a pointer - */ -#define sys_mbox_valid_val(mbox) sys_mbox_valid(&(mbox)) -#endif -#ifndef sys_mbox_set_invalid_val -/** - * Same as sys_mbox_set_invalid() but taking a value, not a pointer - */ -#define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox)) -#endif - - -/** - * @ingroup sys_misc - * The only thread function: - * Creates a new thread - * ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!) - * @param name human-readable name for the thread (used for debugging purposes) - * @param thread thread-function - * @param arg parameter passed to 'thread' - * @param stacksize stack size in bytes for the new thread (may be ignored by ports) - * @param prio priority of the new thread (may be ignored by ports) */ -sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio); - -#endif /* NO_SYS */ - -/* sys_init() must be called before anything else. */ -void sys_init(void); - -#ifndef sys_jiffies -/** - * Ticks/jiffies since power up. - */ -u32_t sys_jiffies(void); -#endif - -/** - * @ingroup sys_time - * Returns the current time in milliseconds, - * may be the same as sys_jiffies or at least based on it. - */ -u32_t sys_now(void); - -/* Critical Region Protection */ -/* These functions must be implemented in the sys_arch.c file. - In some implementations they can provide a more light-weight protection - mechanism than using semaphores. Otherwise semaphores can be used for - implementation */ -#ifndef SYS_ARCH_PROTECT -/** SYS_LIGHTWEIGHT_PROT - * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection - * for certain critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -#if SYS_LIGHTWEIGHT_PROT - -/** - * @ingroup sys_prot - * SYS_ARCH_DECL_PROTECT - * declare a protection variable. This macro will default to defining a variable of - * type sys_prot_t. If a particular port needs a different implementation, then - * this macro may be defined in sys_arch.h. - */ -#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev -/** - * @ingroup sys_prot - * SYS_ARCH_PROTECT - * Perform a "fast" protect. This could be implemented by - * disabling interrupts for an embedded system or by using a semaphore or - * mutex. The implementation should allow calling SYS_ARCH_PROTECT when - * already protected. The old protection level is returned in the variable - * "lev". This macro will default to calling the sys_arch_protect() function - * which should be implemented in sys_arch.c. If a particular port needs a - * different implementation, then this macro may be defined in sys_arch.h - */ -#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() -/** - * @ingroup sys_prot - * SYS_ARCH_UNPROTECT - * Perform a "fast" set of the protection level to "lev". This could be - * implemented by setting the interrupt level to "lev" within the MACRO or by - * using a semaphore or mutex. This macro will default to calling the - * sys_arch_unprotect() function which should be implemented in - * sys_arch.c. If a particular port needs a different implementation, then - * this macro may be defined in sys_arch.h - */ -#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) -sys_prot_t sys_arch_protect(void); -void sys_arch_unprotect(sys_prot_t pval); - -#else - -#define SYS_ARCH_DECL_PROTECT(lev) -#define SYS_ARCH_PROTECT(lev) -#define SYS_ARCH_UNPROTECT(lev) - -#endif /* SYS_LIGHTWEIGHT_PROT */ - -#endif /* SYS_ARCH_PROTECT */ - -/* - * Macros to set/get and increase/decrease variables in a thread-safe way. - * Use these for accessing variable that are used from more than one thread. - */ - -#ifndef SYS_ARCH_INC -#define SYS_ARCH_INC(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var += val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_INC */ - -#ifndef SYS_ARCH_DEC -#define SYS_ARCH_DEC(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var -= val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_DEC */ - -#ifndef SYS_ARCH_GET -#define SYS_ARCH_GET(var, ret) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - ret = var; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_GET */ - -#ifndef SYS_ARCH_SET -#define SYS_ARCH_SET(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var = val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_SET */ - - -#ifdef __cplusplus -} -#endif - -#endif /* NET_HDR_SYS_H */ diff --git a/include/net/tcp.h b/include/net/tcp.h deleted file mode 100644 index 4f321fb..0000000 --- a/include/net/tcp.h +++ /dev/null @@ -1,433 +0,0 @@ -/** - * @file - * TCP API (to be used from TCPIP thread)\n - * See also @ref tcp_raw - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_TCP_H -#define LWIP_HDR_TCP_H - -#include "net/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "net/mem.h" -#include "net/pbuf.h" -#include "net/ip.h" -#include "net/icmp.h" -#include "net/err.h" -#include "net/ip6.h" -#include "net/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct tcp_pcb; - -/** Function prototype for tcp accept callback functions. Called when a new - * connection can be accepted on a listening pcb. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param newpcb The new connection pcb - * @param err An error code if there has been an error accepting. - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err); - -/** Function prototype for tcp receive callback functions. Called when data has - * been received. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb which received data - * @param p The received data (or NULL when the connection has been closed!) - * @param err An error code if there has been an error receiving - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb, - struct pbuf *p, err_t err); - -/** Function prototype for tcp sent callback functions. Called when sent data has - * been acknowledged by the remote side. Use it to free corresponding resources. - * This also means that the pcb has now space available to send new data. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb for which data has been acknowledged - * @param len The amount of bytes acknowledged - * @return ERR_OK: try to send some data by calling tcp_output - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb, - u16_t len); - -/** Function prototype for tcp poll callback functions. Called periodically as - * specified by @see tcp_poll. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb tcp pcb - * @return ERR_OK: try to send some data by calling tcp_output - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb); - -/** Function prototype for tcp error callback functions. Called when the pcb - * receives a RST or is unexpectedly closed for any other reason. - * - * @note The corresponding pcb is already freed when this callback is called! - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param err Error code to indicate why the pcb has been closed - * ERR_ABRT: aborted through tcp_abort or by a TCP timer - * ERR_RST: the connection was reset by the remote host - */ -typedef void (*tcp_err_fn)(void *arg, err_t err); - -/** Function prototype for tcp connected callback functions. Called when a pcb - * is connected to the remote side after initiating a connection attempt by - * calling tcp_connect(). - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb which is connected - * @param err An unused error code, always ERR_OK currently ;-) @todo! - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - * - * @note When a connection attempt fails, the error callback is currently called! - */ -typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err); - -#if LWIP_WND_SCALE -#define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale)) -#define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale)) -#define TCPWND16(x) ((u16_t)LWIP_MIN((x), 0xFFFF)) -#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND))) -typedef u32_t tcpwnd_size_t; -#else -#define RCV_WND_SCALE(pcb, wnd) (wnd) -#define SND_WND_SCALE(pcb, wnd) (wnd) -#define TCPWND16(x) (x) -#define TCP_WND_MAX(pcb) TCP_WND -typedef u16_t tcpwnd_size_t; -#endif - -#if LWIP_WND_SCALE || TCP_LISTEN_BACKLOG || LWIP_TCP_TIMESTAMPS -typedef u16_t tcpflags_t; -#else -typedef u8_t tcpflags_t; -#endif - -enum tcp_state { - CLOSED = 0, - LISTEN = 1, - SYN_SENT = 2, - SYN_RCVD = 3, - ESTABLISHED = 4, - FIN_WAIT_1 = 5, - FIN_WAIT_2 = 6, - CLOSE_WAIT = 7, - CLOSING = 8, - LAST_ACK = 9, - TIME_WAIT = 10 -}; - -/** - * members common to struct tcp_pcb and struct tcp_listen_pcb - */ -#define TCP_PCB_COMMON(type) \ - type *next; /* for the linked list */ \ - void *callback_arg; \ - enum tcp_state state; /* TCP state */ \ - u8_t prio; \ - /* ports are in host byte order */ \ - u16_t local_port - - -/** the TCP protocol control block for listening pcbs */ -struct tcp_pcb_listen { -/** Common members of all PCB types */ - IP_PCB; -/** Protocol specific PCB members */ - TCP_PCB_COMMON(struct tcp_pcb_listen); - -#if LWIP_CALLBACK_API - /* Function to call when a listener has been connected. */ - tcp_accept_fn accept; -#endif /* LWIP_CALLBACK_API */ - -#if TCP_LISTEN_BACKLOG - u8_t backlog; - u8_t accepts_pending; -#endif /* TCP_LISTEN_BACKLOG */ -}; - - -/** the TCP protocol control block */ -struct tcp_pcb { -/** common PCB members */ - IP_PCB; -/** protocol specific PCB members */ - TCP_PCB_COMMON(struct tcp_pcb); - - /* ports are in host byte order */ - u16_t remote_port; - - tcpflags_t flags; -#define TF_ACK_DELAY 0x01U /* Delayed ACK. */ -#define TF_ACK_NOW 0x02U /* Immediate ACK. */ -#define TF_INFR 0x04U /* In fast recovery. */ -#define TF_CLOSEPEND 0x08U /* If this is set, tcp_close failed to enqueue the FIN (retried in tcp_tmr) */ -#define TF_RXCLOSED 0x10U /* rx closed by tcp_shutdown */ -#define TF_FIN 0x20U /* Connection was closed locally (FIN segment enqueued). */ -#define TF_NODELAY 0x40U /* Disable Nagle algorithm */ -#define TF_NAGLEMEMERR 0x80U /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ -#if LWIP_WND_SCALE -#define TF_WND_SCALE 0x0100U /* Window Scale option enabled */ -#endif -#if TCP_LISTEN_BACKLOG -#define TF_BACKLOGPEND 0x0200U /* If this is set, a connection pcb has increased the backlog on its listener */ -#endif -#if LWIP_TCP_TIMESTAMPS -#define TF_TIMESTAMP 0x0400U /* Timestamp option enabled */ -#endif - - /* the rest of the fields are in host byte order - as we have to do some math with them */ - - /* Timers */ - u8_t polltmr, pollinterval; - u8_t last_timer; - u32_t tmr; - - /* receiver variables */ - u32_t rcv_nxt; /* next seqno expected */ - tcpwnd_size_t rcv_wnd; /* receiver window available */ - tcpwnd_size_t rcv_ann_wnd; /* receiver window to announce */ - u32_t rcv_ann_right_edge; /* announced right edge of window */ - - /* Retransmission timer. */ - s16_t rtime; - - u16_t mss; /* maximum segment size */ - - /* RTT (round trip time) estimation variables */ - u32_t rttest; /* RTT estimate in 500ms ticks */ - u32_t rtseq; /* sequence number being timed */ - s16_t sa, sv; /* @todo document this */ - - s16_t rto; /* retransmission time-out */ - u8_t nrtx; /* number of retransmissions */ - - /* fast retransmit/recovery */ - u8_t dupacks; - u32_t lastack; /* Highest acknowledged seqno. */ - - /* congestion avoidance/control variables */ - tcpwnd_size_t cwnd; - tcpwnd_size_t ssthresh; - - /* sender variables */ - u32_t snd_nxt; /* next new seqno to be sent */ - u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last - window update. */ - u32_t snd_lbb; /* Sequence number of next byte to be buffered. */ - tcpwnd_size_t snd_wnd; /* sender window */ - tcpwnd_size_t snd_wnd_max; /* the maximum sender window announced by the remote host */ - - tcpwnd_size_t snd_buf; /* Available buffer space for sending (in bytes). */ -#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) - u16_t snd_queuelen; /* Number of pbufs currently in the send buffer. */ - -#if TCP_OVERSIZE - /* Extra bytes available at the end of the last pbuf in unsent. */ - u16_t unsent_oversize; -#endif /* TCP_OVERSIZE */ - - /* These are ordered by sequence number: */ - struct tcp_seg *unsent; /* Unsent (queued) segments. */ - struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ -#if TCP_QUEUE_OOSEQ - struct tcp_seg *ooseq; /* Received out of sequence segments. */ -#endif /* TCP_QUEUE_OOSEQ */ - - struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */ - -#if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG - struct tcp_pcb_listen* listener; -#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */ - -#if LWIP_CALLBACK_API - /* Function to be called when more send buffer space is available. */ - tcp_sent_fn sent; - /* Function to be called when (in-sequence) data has arrived. */ - tcp_recv_fn recv; - /* Function to be called when a connection has been set up. */ - tcp_connected_fn connected; - /* Function which is called periodically. */ - tcp_poll_fn poll; - /* Function to be called whenever a fatal error occurs. */ - tcp_err_fn errf; -#endif /* LWIP_CALLBACK_API */ - -#if LWIP_TCP_TIMESTAMPS - u32_t ts_lastacksent; - u32_t ts_recent; -#endif /* LWIP_TCP_TIMESTAMPS */ - - /* idle time before KEEPALIVE is sent */ - u32_t keep_idle; -#if LWIP_TCP_KEEPALIVE - u32_t keep_intvl; - u32_t keep_cnt; -#endif /* LWIP_TCP_KEEPALIVE */ - - /* Persist timer counter */ - u8_t persist_cnt; - /* Persist timer back-off */ - u8_t persist_backoff; - - /* KEEPALIVE counter */ - u8_t keep_cnt_sent; - -#if LWIP_WND_SCALE - u8_t snd_scale; - u8_t rcv_scale; -#endif -}; - -#if LWIP_EVENT_API - -enum lwip_event { - LWIP_EVENT_ACCEPT, - LWIP_EVENT_SENT, - LWIP_EVENT_RECV, - LWIP_EVENT_CONNECTED, - LWIP_EVENT_POLL, - LWIP_EVENT_ERR -}; - -err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, - enum lwip_event, - struct pbuf *p, - u16_t size, - err_t err); - -#endif /* LWIP_EVENT_API */ - -/* Application program's interface: */ -struct tcp_pcb * tcp_new (void); -struct tcp_pcb * tcp_new_ip_type (u8_t type); - -void tcp_arg (struct tcp_pcb *pcb, void *arg); -#if LWIP_CALLBACK_API -void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv); -void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent); -void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); -void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); -#endif /* LWIP_CALLBACK_API */ -void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval); - -#if LWIP_TCP_TIMESTAMPS -#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss) -#else /* LWIP_TCP_TIMESTAMPS */ -#define tcp_mss(pcb) ((pcb)->mss) -#endif /* LWIP_TCP_TIMESTAMPS */ -#define tcp_sndbuf(pcb) (TCPWND16((pcb)->snd_buf)) -#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) -/** @ingroup tcp_raw */ -#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) -/** @ingroup tcp_raw */ -#define tcp_nagle_enable(pcb) ((pcb)->flags = (tcpflags_t)((pcb)->flags & ~TF_NODELAY)) -/** @ingroup tcp_raw */ -#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) - -#if TCP_LISTEN_BACKLOG -#define tcp_backlog_set(pcb, new_backlog) do { \ - LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", (pcb)->state == LISTEN); \ - ((struct tcp_pcb_listen *)(pcb))->backlog = ((new_backlog) ? (new_backlog) : 1); } while(0) -void tcp_backlog_delayed(struct tcp_pcb* pcb); -void tcp_backlog_accepted(struct tcp_pcb* pcb); -#else /* TCP_LISTEN_BACKLOG */ -#define tcp_backlog_set(pcb, new_backlog) -#define tcp_backlog_delayed(pcb) -#define tcp_backlog_accepted(pcb) -#endif /* TCP_LISTEN_BACKLOG */ -#define tcp_accepted(pcb) /* compatibility define, not needed any more */ - -void tcp_recved (struct tcp_pcb *pcb, u16_t len); -err_t tcp_bind (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, - u16_t port); -err_t tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, - u16_t port, tcp_connected_fn connected); - -struct tcp_pcb * tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err); -struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); -/** @ingroup tcp_raw */ -#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) - -void tcp_abort (struct tcp_pcb *pcb); -err_t tcp_close (struct tcp_pcb *pcb); -err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx); - -/* Flags for "apiflags" parameter in tcp_write */ -#define TCP_WRITE_FLAG_COPY 0x01 -#define TCP_WRITE_FLAG_MORE 0x02 - -err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, - u8_t apiflags); - -void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); - -#define TCP_PRIO_MIN 1 -#define TCP_PRIO_NORMAL 64 -#define TCP_PRIO_MAX 127 - -err_t tcp_output (struct tcp_pcb *pcb); - - -const char* tcp_debug_state_str(enum tcp_state s); - -/* for compatibility with older implementation */ -#define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TCP */ - -#endif /* LWIP_HDR_TCP_H */ diff --git a/include/net/tcpip.h b/include/net/tcpip.h deleted file mode 100644 index a4c91e6..0000000 --- a/include/net/tcpip.h +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @file - * Functions to sync with TCPIP thread - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_TCPIP_H -#define LWIP_HDR_TCPIP_H - -#include "net/opt.h" - -#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ - -#include "net/err.h" -#include "net/timeouts.h" -#include "net/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_TCPIP_CORE_LOCKING -/** The global semaphore to lock the stack. */ -extern sys_mutex_t lock_tcpip_core; -/** Lock lwIP core mutex (needs @ref LWIP_TCPIP_CORE_LOCKING 1) */ -#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core) -/** Unlock lwIP core mutex (needs @ref LWIP_TCPIP_CORE_LOCKING 1) */ -#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core) -#else /* LWIP_TCPIP_CORE_LOCKING */ -#define LOCK_TCPIP_CORE() -#define UNLOCK_TCPIP_CORE() -#endif /* LWIP_TCPIP_CORE_LOCKING */ - -struct pbuf; -struct netif; - -/** Function prototype for the init_done function passed to tcpip_init */ -typedef void (*tcpip_init_done_fn)(void *arg); -/** Function prototype for functions passed to tcpip_callback() */ -typedef void (*tcpip_callback_fn)(void *ctx); - -/* Forward declarations */ -struct tcpip_callback_msg; - -void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); - -err_t tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn); -err_t tcpip_input(struct pbuf *p, struct netif *inp); - -err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); -/** - * @ingroup lwip_os - * @see tcpip_callback_with_block - */ -#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) - -struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx); -void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg); -err_t tcpip_trycallback(struct tcpip_callback_msg* msg); - -/* free pbufs or heap memory from another context without blocking */ -err_t pbuf_free_callback(struct pbuf *p); -err_t mem_free_callback(void *m); - -#if LWIP_TCPIP_TIMEOUT && LWIP_TIMERS -err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); -err_t tcpip_untimeout(sys_timeout_handler h, void *arg); -#endif /* LWIP_TCPIP_TIMEOUT && LWIP_TIMERS */ - -#ifdef __cplusplus -} -#endif - -#endif /* !NO_SYS */ - -#endif /* LWIP_HDR_TCPIP_H */ diff --git a/include/net/timeouts.h b/include/net/timeouts.h deleted file mode 100644 index e0e4b52..0000000 --- a/include/net/timeouts.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @file - * Timer implementations - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_TIMEOUTS_H -#define LWIP_HDR_TIMEOUTS_H - -#include "net/opt.h" -#include "net/err.h" -#if !NO_SYS -#include "net/sys.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef LWIP_DEBUG_TIMERNAMES -#ifdef LWIP_DEBUG -#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG -#else /* LWIP_DEBUG */ -#define LWIP_DEBUG_TIMERNAMES 0 -#endif /* LWIP_DEBUG*/ -#endif - -/** Function prototype for a stack-internal timer function that has to be - * called at a defined interval */ -typedef void (* lwip_cyclic_timer_handler)(void); - -/** This struct contains information about a stack-internal timer function - that has to be called at a defined interval */ -struct lwip_cyclic_timer { - u32_t interval_ms; - lwip_cyclic_timer_handler handler; -#if LWIP_DEBUG_TIMERNAMES - const char* handler_name; -#endif /* LWIP_DEBUG_TIMERNAMES */ -}; - -/** This array contains all stack-internal cyclic timers. To get the number of - * timers, use LWIP_ARRAYSIZE() */ -extern const struct lwip_cyclic_timer lwip_cyclic_timers[]; - -#if LWIP_TIMERS - -/** Function prototype for a timeout callback function. Register such a function - * using sys_timeout(). - * - * @param arg Additional argument to pass to the function - set up by sys_timeout() - */ -typedef void (* sys_timeout_handler)(void *arg); - -struct sys_timeo { - struct sys_timeo *next; - u32_t time; - sys_timeout_handler h; - void *arg; -#if LWIP_DEBUG_TIMERNAMES - const char* handler_name; -#endif /* LWIP_DEBUG_TIMERNAMES */ -}; - -void sys_timeouts_init(void); - -#if LWIP_DEBUG_TIMERNAMES -void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); -#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) -#else /* LWIP_DEBUG_TIMERNAMES */ -void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); -#endif /* LWIP_DEBUG_TIMERNAMES */ - -void sys_untimeout(sys_timeout_handler handler, void *arg); -void sys_restart_timeouts(void); -#if NO_SYS -void sys_check_timeouts(void); -u32_t sys_timeouts_sleeptime(void); -#else /* NO_SYS */ -void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); -#endif /* NO_SYS */ - - -#endif /* LWIP_TIMERS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_TIMEOUTS_H */ diff --git a/include/net/udp.h b/include/net/udp.h deleted file mode 100644 index 129d380..0000000 --- a/include/net/udp.h +++ /dev/null @@ -1,182 +0,0 @@ -/** - * @file - * UDP API (to be used from TCPIP thread)\n - * See also @ref udp_raw - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_UDP_H -#define LWIP_HDR_UDP_H - -#include "net/opt.h" - -#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/netif.h" -#include "net/ip_addr.h" -#include "net/ip.h" -#include "net/ip6_addr.h" -#include "net/prot/udp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define UDP_FLAGS_NOCHKSUM 0x01U -#define UDP_FLAGS_UDPLITE 0x02U -#define UDP_FLAGS_CONNECTED 0x04U -#define UDP_FLAGS_MULTICAST_LOOP 0x08U - -struct udp_pcb; - -/** Function prototype for udp pcb receive callback functions - * addr and port are in same byte order as in the pcb - * The callback is responsible for freeing the pbuf - * if it's not used any more. - * - * ATTENTION: Be aware that 'addr' might point into the pbuf 'p' so freeing this pbuf - * can make 'addr' invalid, too. - * - * @param arg user supplied argument (udp_pcb.recv_arg) - * @param pcb the udp_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IP address from which the packet was received - * @param port the remote port from which the packet was received - */ -typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *addr, u16_t port); - -/** the UDP protocol control block */ -struct udp_pcb { -/** Common members of all PCB types */ - IP_PCB; - -/* Protocol specific PCB members */ - - struct udp_pcb *next; - - u8_t flags; - /** ports are in host byte order */ - u16_t local_port, remote_port; - -#if LWIP_MULTICAST_TX_OPTIONS - /** outgoing network interface for multicast packets */ - ip_addr_t multicast_ip; - /** TTL for outgoing multicast packets */ - u8_t mcast_ttl; -#endif /* LWIP_MULTICAST_TX_OPTIONS */ - -#if LWIP_UDPLITE - /** used for UDP_LITE only */ - u16_t chksum_len_rx, chksum_len_tx; -#endif /* LWIP_UDPLITE */ - - /** receive callback function */ - udp_recv_fn recv; - /** user-supplied argument for the recv callback */ - void *recv_arg; -}; -/* udp_pcbs export for external reference (e.g. SNMP agent) */ -extern struct udp_pcb *udp_pcbs; - -/* The following functions is the application layer interface to the - UDP code. */ -struct udp_pcb * udp_new (void); -struct udp_pcb * udp_new_ip_type(u8_t type); -void udp_remove (struct udp_pcb *pcb); -err_t udp_bind (struct udp_pcb *pcb, const ip_addr_t *ipaddr, - u16_t port); -err_t udp_connect (struct udp_pcb *pcb, const ip_addr_t *ipaddr, - u16_t port); -void udp_disconnect (struct udp_pcb *pcb); -void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, - void *recv_arg); -err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif); -err_t udp_sendto_if_src(struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif, const ip_addr_t *src_ip); -err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *dst_ip, u16_t dst_port); -err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); - -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP -err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif, u8_t have_chksum, - u16_t chksum); -err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *dst_ip, u16_t dst_port, - u8_t have_chksum, u16_t chksum); -err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, - u8_t have_chksum, u16_t chksum); -err_t udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, - const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif, - u8_t have_chksum, u16_t chksum, const ip_addr_t *src_ip); -#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ - -#define udp_flags(pcb) ((pcb)->flags) -#define udp_setflags(pcb, f) ((pcb)->flags = (f)) - -/* The following functions are the lower layer interface to UDP. */ -void udp_input (struct pbuf *p, struct netif *inp); - -void udp_init (void); - -/* for compatibility with older implementation */ -#define udp_new_ip6() udp_new_ip_type(IPADDR_TYPE_V6) - -#if LWIP_MULTICAST_TX_OPTIONS -#define udp_set_multicast_netif_addr(pcb, ip4addr) ip_addr_copy_from_ip4((pcb)->multicast_ip, *(ip4addr)) -#define udp_get_multicast_netif_addr(pcb) ip_2_ip4(&(pcb)->multicast_ip) -#define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0) -#define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl) -#endif /* LWIP_MULTICAST_TX_OPTIONS */ - -#if UDP_DEBUG -void udp_debug_print(struct udp_hdr *udphdr); -#else -#define udp_debug_print(udphdr) -#endif - -void udp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_UDP */ - -#endif /* LWIP_HDR_UDP_H */ diff --git a/include/netif/etharp.h b/include/netif/etharp.h deleted file mode 100644 index 993e07c..0000000 --- a/include/netif/etharp.h +++ /dev/null @@ -1,3 +0,0 @@ -/* ARP has been moved to core/ipv4, provide this #include for compatibility only */ -#include "net/etharp.h" -#include "netif/ethernet.h" diff --git a/include/netif/ethernet.h b/include/netif/ethernet.h deleted file mode 100644 index 1cf4811..0000000 --- a/include/netif/ethernet.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file - * Ethernet input function - handles INCOMING ethernet level traffic - * To be used in most low-level netif implementations - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * Copyright (c) 2003-2004 Leon Woestenberg - * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef LWIP_HDR_NETIF_ETHERNET_H -#define LWIP_HDR_NETIF_ETHERNET_H - -#include "net/opt.h" - -#include "net/pbuf.h" -#include "net/netif.h" -#include "net/prot/ethernet.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_ARP || LWIP_ETHERNET - -/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) - * to a filter function that returns the correct netif when using multiple - * netifs on one hardware interface where the netif's low-level receive - * routine cannot decide for the correct netif (e.g. when mapping multiple - * IP addresses to one hardware interface). - */ -#ifndef LWIP_ARP_FILTER_NETIF -#define LWIP_ARP_FILTER_NETIF 0 -#endif - -err_t ethernet_input(struct pbuf *p, struct netif *netif); -err_t ethernet_output(struct netif* netif, struct pbuf* p, const struct eth_addr* src, const struct eth_addr* dst, u16_t eth_type); - -extern const struct eth_addr ethbroadcast, ethzero; - -#endif /* LWIP_ARP || LWIP_ETHERNET */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_NETIF_ETHERNET_H */ diff --git a/include/netif/ethernetif.h b/include/netif/ethernetif.h deleted file mode 100644 index 4444e01..0000000 --- a/include/netif/ethernetif.h +++ /dev/null @@ -1 +0,0 @@ -err_t ethernetif_init(struct netif *netif); diff --git a/include/netif/lowpan6.h b/include/netif/lowpan6.h deleted file mode 100644 index e72add1..0000000 --- a/include/netif/lowpan6.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file - * - * 6LowPAN output for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. - */ - -/* - * Copyright (c) 2015 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_LOWPAN6_H -#define LWIP_HDR_LOWPAN6_H - -#include "netif/lowpan6_opts.h" - -#if LWIP_IPV6 && LWIP_6LOWPAN /* don't build if not configured for use in lwipopts.h */ - -#include "net/pbuf.h" -#include "net/ip.h" -#include "net/ip_addr.h" -#include "net/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** 1 second period */ -#define LOWPAN6_TMR_INTERVAL 1000 - -void lowpan6_tmr(void); - -err_t lowpan6_set_context(u8_t index, const ip6_addr_t * context); -err_t lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low); - -#if LWIP_IPV4 -err_t lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); -#endif /* LWIP_IPV4 */ -err_t lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); -err_t lowpan6_input(struct pbuf * p, struct netif *netif); -err_t lowpan6_if_init(struct netif *netif); - -/* pan_id in network byte order. */ -err_t lowpan6_set_pan_id(u16_t pan_id); - -#if !NO_SYS -err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp); -#endif /* !NO_SYS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 && LWIP_6LOWPAN */ - -#endif /* LWIP_HDR_LOWPAN6_H */ diff --git a/include/netif/lowpan6_opts.h b/include/netif/lowpan6_opts.h deleted file mode 100644 index 19c64b6..0000000 --- a/include/netif/lowpan6_opts.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * 6LowPAN options list - */ - -/* - * Copyright (c) 2015 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef LWIP_HDR_LOWPAN6_OPTS_H -#define LWIP_HDR_LOWPAN6_OPTS_H - -#include "net/opt.h" - -#ifndef LWIP_6LOWPAN -#define LWIP_6LOWPAN 0 -#endif - -#ifndef LWIP_6LOWPAN_NUM_CONTEXTS -#define LWIP_6LOWPAN_NUM_CONTEXTS 10 -#endif - -#ifndef LWIP_6LOWPAN_INFER_SHORT_ADDRESS -#define LWIP_6LOWPAN_INFER_SHORT_ADDRESS 1 -#endif - -#ifndef LWIP_6LOWPAN_IPHC -#define LWIP_6LOWPAN_IPHC 1 -#endif - -#ifndef LWIP_6LOWPAN_HW_CRC -#define LWIP_6LOWPAN_HW_CRC 1 -#endif - -#ifndef LOWPAN6_DEBUG -#define LOWPAN6_DEBUG LWIP_DBG_OFF -#endif - -#endif /* LWIP_HDR_LOWPAN6_OPTS_H */ diff --git a/include/netif/ppp/ccp.h b/include/netif/ppp/ccp.h deleted file mode 100644 index 14dd659..0000000 --- a/include/netif/ppp/ccp.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * ccp.h - Definitions for PPP Compression Control Protocol. - * - * Copyright (c) 1994-2002 Paul Mackerras. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 3. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Paul Mackerras - * ". - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && CCP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef CCP_H -#define CCP_H - -/* - * CCP codes. - */ - -#define CCP_CONFREQ 1 -#define CCP_CONFACK 2 -#define CCP_TERMREQ 5 -#define CCP_TERMACK 6 -#define CCP_RESETREQ 14 -#define CCP_RESETACK 15 - -/* - * Max # bytes for a CCP option - */ - -#define CCP_MAX_OPTION_LENGTH 32 - -/* - * Parts of a CCP packet. - */ - -#define CCP_CODE(dp) ((dp)[0]) -#define CCP_ID(dp) ((dp)[1]) -#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3]) -#define CCP_HDRLEN 4 - -#define CCP_OPT_CODE(dp) ((dp)[0]) -#define CCP_OPT_LENGTH(dp) ((dp)[1]) -#define CCP_OPT_MINLEN 2 - -#if BSDCOMPRESS_SUPPORT -/* - * Definitions for BSD-Compress. - */ - -#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */ -#define CILEN_BSD_COMPRESS 3 /* length of config. option */ - -/* Macros for handling the 3rd byte of the BSD-Compress config option. */ -#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */ -#define BSD_VERSION(x) ((x) >> 5) /* version of option format */ -#define BSD_CURRENT_VERSION 1 /* current version number */ -#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n)) - -#define BSD_MIN_BITS 9 /* smallest code size supported */ -#define BSD_MAX_BITS 15 /* largest code size supported */ -#endif /* BSDCOMPRESS_SUPPORT */ - -#if DEFLATE_SUPPORT -/* - * Definitions for Deflate. - */ - -#define CI_DEFLATE 26 /* config option for Deflate */ -#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */ -#define CILEN_DEFLATE 4 /* length of its config option */ - -#define DEFLATE_MIN_SIZE 9 -#define DEFLATE_MAX_SIZE 15 -#define DEFLATE_METHOD_VAL 8 -#define DEFLATE_SIZE(x) (((x) >> 4) + 8) -#define DEFLATE_METHOD(x) ((x) & 0x0F) -#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) -#define DEFLATE_CHK_SEQUENCE 0 -#endif /* DEFLATE_SUPPORT */ - -#if MPPE_SUPPORT -/* - * Definitions for MPPE. - */ - -#define CI_MPPE 18 /* config option for MPPE */ -#define CILEN_MPPE 6 /* length of config option */ -#endif /* MPPE_SUPPORT */ - -#if PREDICTOR_SUPPORT -/* - * Definitions for other, as yet unsupported, compression methods. - */ - -#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */ -#define CILEN_PREDICTOR_1 2 /* length of its config option */ -#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */ -#define CILEN_PREDICTOR_2 2 /* length of its config option */ -#endif /* PREDICTOR_SUPPORT */ - -typedef struct ccp_options { -#if DEFLATE_SUPPORT - unsigned int deflate :1; /* do Deflate? */ - unsigned int deflate_correct :1; /* use correct code for deflate? */ - unsigned int deflate_draft :1; /* use draft RFC code for deflate? */ -#endif /* DEFLATE_SUPPORT */ -#if BSDCOMPRESS_SUPPORT - unsigned int bsd_compress :1; /* do BSD Compress? */ -#endif /* BSDCOMPRESS_SUPPORT */ -#if PREDICTOR_SUPPORT - unsigned int predictor_1 :1; /* do Predictor-1? */ - unsigned int predictor_2 :1; /* do Predictor-2? */ -#endif /* PREDICTOR_SUPPORT */ - -#if MPPE_SUPPORT - u8_t mppe; /* MPPE bitfield */ -#endif /* MPPE_SUPPORT */ -#if BSDCOMPRESS_SUPPORT - u_short bsd_bits; /* # bits/code for BSD Compress */ -#endif /* BSDCOMPRESS_SUPPORT */ -#if DEFLATE_SUPPORT - u_short deflate_size; /* lg(window size) for Deflate */ -#endif /* DEFLATE_SUPPORT */ - u8_t method; /* code for chosen compression method */ -} ccp_options; - -extern const struct protent ccp_protent; - -void ccp_resetrequest(ppp_pcb *pcb); /* Issue a reset-request. */ - -#endif /* CCP_H */ -#endif /* PPP_SUPPORT && CCP_SUPPORT */ diff --git a/include/netif/ppp/chap-md5.h b/include/netif/ppp/chap-md5.h deleted file mode 100644 index eb0269f..0000000 --- a/include/netif/ppp/chap-md5.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * chap-md5.h - New CHAP/MD5 implementation. - * - * Copyright (c) 2003 Paul Mackerras. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 3. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Paul Mackerras - * ". - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -extern const struct chap_digest_type md5_digest; - -#endif /* PPP_SUPPORT && CHAP_SUPPORT */ diff --git a/include/netif/ppp/chap-new.h b/include/netif/ppp/chap-new.h deleted file mode 100644 index 64eae32..0000000 --- a/include/netif/ppp/chap-new.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * chap-new.c - New CHAP implementation. - * - * Copyright (c) 2003 Paul Mackerras. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 3. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Paul Mackerras - * ". - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef CHAP_H -#define CHAP_H - -#include "ppp.h" - -/* - * CHAP packets begin with a standard header with code, id, len (2 bytes). - */ -#define CHAP_HDRLEN 4 - -/* - * Values for the code field. - */ -#define CHAP_CHALLENGE 1 -#define CHAP_RESPONSE 2 -#define CHAP_SUCCESS 3 -#define CHAP_FAILURE 4 - -/* - * CHAP digest codes. - */ -#define CHAP_MD5 5 -#if MSCHAP_SUPPORT -#define CHAP_MICROSOFT 0x80 -#define CHAP_MICROSOFT_V2 0x81 -#endif /* MSCHAP_SUPPORT */ - -/* - * Semi-arbitrary limits on challenge and response fields. - */ -#define MAX_CHALLENGE_LEN 64 -#define MAX_RESPONSE_LEN 64 - -/* - * These limits apply to challenge and response packets we send. - * The +4 is the +1 that we actually need rounded up. - */ -#define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN) -#define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN) - -/* bitmask of supported algorithms */ -#if MSCHAP_SUPPORT -#define MDTYPE_MICROSOFT_V2 0x1 -#define MDTYPE_MICROSOFT 0x2 -#endif /* MSCHAP_SUPPORT */ -#define MDTYPE_MD5 0x4 -#define MDTYPE_NONE 0 - -#if MSCHAP_SUPPORT -/* Return the digest alg. ID for the most preferred digest type. */ -#define CHAP_DIGEST(mdtype) \ - ((mdtype) & MDTYPE_MD5)? CHAP_MD5: \ - ((mdtype) & MDTYPE_MICROSOFT_V2)? CHAP_MICROSOFT_V2: \ - ((mdtype) & MDTYPE_MICROSOFT)? CHAP_MICROSOFT: \ - 0 -#else /* !MSCHAP_SUPPORT */ -#define CHAP_DIGEST(mdtype) \ - ((mdtype) & MDTYPE_MD5)? CHAP_MD5: \ - 0 -#endif /* MSCHAP_SUPPORT */ - -/* Return the bit flag (lsb set) for our most preferred digest type. */ -#define CHAP_MDTYPE(mdtype) ((mdtype) ^ ((mdtype) - 1)) & (mdtype) - -/* Return the bit flag for a given digest algorithm ID. */ -#if MSCHAP_SUPPORT -#define CHAP_MDTYPE_D(digest) \ - ((digest) == CHAP_MICROSOFT_V2)? MDTYPE_MICROSOFT_V2: \ - ((digest) == CHAP_MICROSOFT)? MDTYPE_MICROSOFT: \ - ((digest) == CHAP_MD5)? MDTYPE_MD5: \ - 0 -#else /* !MSCHAP_SUPPORT */ -#define CHAP_MDTYPE_D(digest) \ - ((digest) == CHAP_MD5)? MDTYPE_MD5: \ - 0 -#endif /* MSCHAP_SUPPORT */ - -/* Can we do the requested digest? */ -#if MSCHAP_SUPPORT -#define CHAP_CANDIGEST(mdtype, digest) \ - ((digest) == CHAP_MICROSOFT_V2)? (mdtype) & MDTYPE_MICROSOFT_V2: \ - ((digest) == CHAP_MICROSOFT)? (mdtype) & MDTYPE_MICROSOFT: \ - ((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \ - 0 -#else /* !MSCHAP_SUPPORT */ -#define CHAP_CANDIGEST(mdtype, digest) \ - ((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \ - 0 -#endif /* MSCHAP_SUPPORT */ - -/* - * The code for each digest type has to supply one of these. - */ -struct chap_digest_type { - int code; - -#if PPP_SERVER - /* - * Note: challenge and response arguments below are formatted as - * a length byte followed by the actual challenge/response data. - */ - void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge); - int (*verify_response)(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space); -#endif /* PPP_SERVER */ - void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *priv); - int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); - void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); -}; - -/* - * Each interface is described by chap structure. - */ -#if CHAP_SUPPORT -typedef struct chap_client_state { - u8_t flags; - const char *name; - const struct chap_digest_type *digest; - unsigned char priv[64]; /* private area for digest's use */ -} chap_client_state; - -#if PPP_SERVER -typedef struct chap_server_state { - u8_t flags; - u8_t id; - const char *name; - const struct chap_digest_type *digest; - int challenge_xmits; - int challenge_pktlen; - unsigned char challenge[CHAL_MAX_PKTLEN]; -} chap_server_state; -#endif /* PPP_SERVER */ -#endif /* CHAP_SUPPORT */ - -#if 0 /* UNUSED */ -/* Hook for a plugin to validate CHAP challenge */ -extern int (*chap_verify_hook)(char *name, char *ourname, int id, - const struct chap_digest_type *digest, - unsigned char *challenge, unsigned char *response, - char *message, int message_space); -#endif /* UNUSED */ - -#if PPP_SERVER -/* Called by authentication code to start authenticating the peer. */ -extern void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code); -#endif /* PPP_SERVER */ - -/* Called by auth. code to start authenticating us to the peer. */ -extern void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code); - -/* Represents the CHAP protocol to the main pppd code */ -extern const struct protent chap_protent; - -#endif /* CHAP_H */ -#endif /* PPP_SUPPORT && CHAP_SUPPORT */ diff --git a/include/netif/ppp/chap_ms.h b/include/netif/ppp/chap_ms.h deleted file mode 100644 index 0795291..0000000 --- a/include/netif/ppp/chap_ms.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * chap_ms.h - Challenge Handshake Authentication Protocol definitions. - * - * Copyright (c) 1995 Eric Rosenquist. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef CHAPMS_INCLUDE -#define CHAPMS_INCLUDE - -extern const struct chap_digest_type chapms_digest; -extern const struct chap_digest_type chapms2_digest; - -#endif /* CHAPMS_INCLUDE */ - -#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ diff --git a/include/netif/ppp/eap.h b/include/netif/ppp/eap.h deleted file mode 100644 index 3ee9aaf..0000000 --- a/include/netif/ppp/eap.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * eap.h - Extensible Authentication Protocol for PPP (RFC 2284) - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - * - * Non-exclusive rights to redistribute, modify, translate, and use - * this software in source and binary forms, in whole or in part, is - * hereby granted, provided that the above copyright notice is - * duplicated in any source form, and that neither the name of the - * copyright holder nor the author is used to endorse or promote - * products derived from this software. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Original version by James Carlson - * - * $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef PPP_EAP_H -#define PPP_EAP_H - -#include "ppp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Packet header = Code, id, length. - */ -#define EAP_HEADERLEN 4 - - -/* EAP message codes. */ -#define EAP_REQUEST 1 -#define EAP_RESPONSE 2 -#define EAP_SUCCESS 3 -#define EAP_FAILURE 4 - -/* EAP types */ -#define EAPT_IDENTITY 1 -#define EAPT_NOTIFICATION 2 -#define EAPT_NAK 3 /* (response only) */ -#define EAPT_MD5CHAP 4 -#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */ -#define EAPT_TOKEN 6 /* Generic Token Card */ -/* 7 and 8 are unassigned. */ -#define EAPT_RSA 9 /* RSA Public Key Authentication */ -#define EAPT_DSS 10 /* DSS Unilateral */ -#define EAPT_KEA 11 /* KEA */ -#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */ -#define EAPT_TLS 13 /* EAP-TLS */ -#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */ -#define EAPT_W2K 15 /* Windows 2000 EAP */ -#define EAPT_ARCOT 16 /* Arcot Systems */ -#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */ -#define EAPT_NOKIACARD 18 /* Nokia IP smart card */ -#define EAPT_SRP 19 /* Secure Remote Password */ -/* 20 is deprecated */ - -/* EAP SRP-SHA1 Subtypes */ -#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */ -#define EAPSRP_CKEY 1 /* Response 1 - Client Key */ -#define EAPSRP_SKEY 2 /* Request 2 - Server Key */ -#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */ -#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */ -#define EAPSRP_ACK 3 /* Response 3 - final ack */ -#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */ - -#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */ - -#define SRP_PSEUDO_ID "pseudo_" -#define SRP_PSEUDO_LEN 7 - -#define MD5_SIGNATURE_SIZE 16 -#define EAP_MIN_CHALLENGE_LENGTH 17 -#define EAP_MAX_CHALLENGE_LENGTH 24 -#define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */ - -#define EAP_STATES \ - "Initial", "Pending", "Closed", "Listen", "Identify", \ - "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth" - -#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen) -#if PPP_SERVER -#define eap_server_active(pcb) \ - ((pcb)->eap.es_server.ea_state >= eapIdentify && \ - (pcb)->eap.es_server.ea_state <= eapMD5Chall) -#endif /* PPP_SERVER */ - -/* - * Complete EAP state for one PPP session. - */ -enum eap_state_code { - eapInitial = 0, /* No EAP authentication yet requested */ - eapPending, /* Waiting for LCP (no timer) */ - eapClosed, /* Authentication not in use */ - eapListen, /* Client ready (and timer running) */ - eapIdentify, /* EAP Identify sent */ - eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */ - eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */ - eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */ - eapMD5Chall, /* Sent MD5-Challenge */ - eapOpen, /* Completed authentication */ - eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */ - eapBadAuth /* Failed authentication */ -}; - -struct eap_auth { - const char *ea_name; /* Our name */ - char ea_peer[MAXNAMELEN +1]; /* Peer's name */ - void *ea_session; /* Authentication library linkage */ - u_char *ea_skey; /* Shared encryption key */ - u_short ea_namelen; /* Length of our name */ - u_short ea_peerlen; /* Length of peer's name */ - enum eap_state_code ea_state; - u_char ea_id; /* Current id */ - u_char ea_requests; /* Number of Requests sent/received */ - u_char ea_responses; /* Number of Responses */ - u_char ea_type; /* One of EAPT_* */ - u32_t ea_keyflags; /* SRP shared key usage flags */ -}; - -#ifndef EAP_MAX_CHALLENGE_LENGTH -#define EAP_MAX_CHALLENGE_LENGTH 24 -#endif -typedef struct eap_state { - struct eap_auth es_client; /* Client (authenticatee) data */ -#if PPP_SERVER - struct eap_auth es_server; /* Server (authenticator) data */ -#endif /* PPP_SERVER */ - int es_savedtime; /* Saved timeout */ - int es_rechallenge; /* EAP rechallenge interval */ - int es_lwrechallenge; /* SRP lightweight rechallenge inter */ - u8_t es_usepseudo; /* Use SRP Pseudonym if offered one */ - int es_usedpseudo; /* Set if we already sent PN */ - int es_challen; /* Length of challenge string */ - u_char es_challenge[EAP_MAX_CHALLENGE_LENGTH]; -} eap_state; - -/* - * Timeouts. - */ -#if 0 /* moved to ppp_opts.h */ -#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */ -#define EAP_DEFTRANSMITS 10 /* max # times to transmit */ -#define EAP_DEFREQTIME 20 /* Time to wait for peer request */ -#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */ -#endif /* moved to ppp_opts.h */ - -void eap_authwithpeer(ppp_pcb *pcb, const char *localname); -void eap_authpeer(ppp_pcb *pcb, const char *localname); - -extern const struct protent eap_protent; - -#ifdef __cplusplus -} -#endif - -#endif /* PPP_EAP_H */ - -#endif /* PPP_SUPPORT && EAP_SUPPORT */ diff --git a/include/netif/ppp/ecp.h b/include/netif/ppp/ecp.h deleted file mode 100644 index 5cdce29..0000000 --- a/include/netif/ppp/ecp.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ecp.h - Definitions for PPP Encryption Control Protocol. - * - * Copyright (c) 2002 Google, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -typedef struct ecp_options { - bool required; /* Is ECP required? */ - unsigned enctype; /* Encryption type */ -} ecp_options; - -extern fsm ecp_fsm[]; -extern ecp_options ecp_wantoptions[]; -extern ecp_options ecp_gotoptions[]; -extern ecp_options ecp_allowoptions[]; -extern ecp_options ecp_hisoptions[]; - -extern const struct protent ecp_protent; - -#endif /* PPP_SUPPORT && ECP_SUPPORT */ diff --git a/include/netif/ppp/eui64.h b/include/netif/ppp/eui64.h deleted file mode 100644 index 20ac22e..0000000 --- a/include/netif/ppp/eui64.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * eui64.h - EUI64 routines for IPv6CP. - * - * Copyright (c) 1999 Tommi Komulainen. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Tommi Komulainen - * ". - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $ -*/ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef EUI64_H -#define EUI64_H - -/* - * @todo: - * - * Maybe this should be done by processing struct in6_addr directly... - */ -typedef union -{ - u8_t e8[8]; - u16_t e16[4]; - u32_t e32[2]; -} eui64_t; - -#define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) -#define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ - ((e).e32[1] == (o).e32[1])) -#define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0; - -#define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t)) - -#define eui64_magic(e) do { \ - (e).e32[0] = magic(); \ - (e).e32[1] = magic(); \ - (e).e8[0] &= ~2; \ - } while (0) -#define eui64_magic_nz(x) do { \ - eui64_magic(x); \ - } while (eui64_iszero(x)) -#define eui64_magic_ne(x, y) do { \ - eui64_magic(x); \ - } while (eui64_equals(x, y)) - -#define eui64_get(ll, cp) do { \ - eui64_copy((*cp), (ll)); \ - (cp) += sizeof(eui64_t); \ - } while (0) - -#define eui64_put(ll, cp) do { \ - eui64_copy((ll), (*cp)); \ - (cp) += sizeof(eui64_t); \ - } while (0) - -#define eui64_set32(e, l) do { \ - (e).e32[0] = 0; \ - (e).e32[1] = lwip_htonl(l); \ - } while (0) -#define eui64_setlo32(e, l) eui64_set32(e, l) - -char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ - -#endif /* EUI64_H */ -#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ diff --git a/include/netif/ppp/fsm.h b/include/netif/ppp/fsm.h deleted file mode 100644 index b6915d3..0000000 --- a/include/netif/ppp/fsm.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions. - * - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef FSM_H -#define FSM_H - -#include "ppp.h" - -/* - * Packet header = Code, id, length. - */ -#define HEADERLEN 4 - - -/* - * CP (LCP, IPCP, etc.) codes. - */ -#define CONFREQ 1 /* Configuration Request */ -#define CONFACK 2 /* Configuration Ack */ -#define CONFNAK 3 /* Configuration Nak */ -#define CONFREJ 4 /* Configuration Reject */ -#define TERMREQ 5 /* Termination Request */ -#define TERMACK 6 /* Termination Ack */ -#define CODEREJ 7 /* Code Reject */ - - -/* - * Each FSM is described by an fsm structure and fsm callbacks. - */ -typedef struct fsm { - ppp_pcb *pcb; /* PPP Interface */ - const struct fsm_callbacks *callbacks; /* Callback routines */ - const char *term_reason; /* Reason for closing protocol */ - u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */ - /* -- This is our only flag, we might use u_int :1 if we have more flags */ - u16_t protocol; /* Data Link Layer Protocol field value */ - u8_t state; /* State */ - u8_t flags; /* Contains option bits */ - u8_t id; /* Current id */ - u8_t reqid; /* Current request id */ - u8_t retransmits; /* Number of retransmissions left */ - u8_t nakloops; /* Number of nak loops since last ack */ - u8_t rnakloops; /* Number of naks received */ - u8_t maxnakloops; /* Maximum number of nak loops tolerated - (necessary because IPCP require a custom large max nak loops value) */ - u8_t term_reason_len; /* Length of term_reason */ -} fsm; - - -typedef struct fsm_callbacks { - void (*resetci) /* Reset our Configuration Information */ - (fsm *); - int (*cilen) /* Length of our Configuration Information */ - (fsm *); - void (*addci) /* Add our Configuration Information */ - (fsm *, u_char *, int *); - int (*ackci) /* ACK our Configuration Information */ - (fsm *, u_char *, int); - int (*nakci) /* NAK our Configuration Information */ - (fsm *, u_char *, int, int); - int (*rejci) /* Reject our Configuration Information */ - (fsm *, u_char *, int); - int (*reqci) /* Request peer's Configuration Information */ - (fsm *, u_char *, int *, int); - void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */ - (fsm *); - void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */ - (fsm *); - void (*starting) /* Called when we want the lower layer */ - (fsm *); - void (*finished) /* Called when we don't want the lower layer */ - (fsm *); - void (*protreject) /* Called when Protocol-Reject received */ - (int); - void (*retransmit) /* Retransmission is necessary */ - (fsm *); - int (*extcode) /* Called when unknown code received */ - (fsm *, int, int, u_char *, int); - const char *proto_name; /* String name for protocol (for messages) */ -} fsm_callbacks; - - -/* - * Link states. - */ -#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */ -#define PPP_FSM_STARTING 1 /* Down, been opened */ -#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */ -#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */ -#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */ -#define PPP_FSM_STOPPING 5 /* Terminating, but open */ -#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */ -#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */ -#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */ -#define PPP_FSM_OPENED 9 /* Connection available */ - - -/* - * Flags - indicate options controlling FSM operation - */ -#define OPT_PASSIVE 1 /* Don't die if we don't get a response */ -#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */ -#define OPT_SILENT 4 /* Wait for peer to speak first */ - - -/* - * Timeouts. - */ -#if 0 /* moved to ppp_opts.h */ -#define DEFTIMEOUT 3 /* Timeout time in seconds */ -#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ -#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ -#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */ -#endif /* moved to ppp_opts.h */ - - -/* - * Prototypes - */ -void fsm_init(fsm *f); -void fsm_lowerup(fsm *f); -void fsm_lowerdown(fsm *f); -void fsm_open(fsm *f); -void fsm_close(fsm *f, const char *reason); -void fsm_input(fsm *f, u_char *inpacket, int l); -void fsm_protreject(fsm *f); -void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen); - - -#endif /* FSM_H */ -#endif /* PPP_SUPPORT */ diff --git a/include/netif/ppp/ipcp.h b/include/netif/ppp/ipcp.h deleted file mode 100644 index 45f46b3..0000000 --- a/include/netif/ppp/ipcp.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * ipcp.h - IP Control Protocol definitions. - * - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: ipcp.h,v 1.14 2002/12/04 23:03:32 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PPP_IPV4_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef IPCP_H -#define IPCP_H - -/* - * Options. - */ -#define CI_ADDRS 1 /* IP Addresses */ -#if VJ_SUPPORT -#define CI_COMPRESSTYPE 2 /* Compression Type */ -#endif /* VJ_SUPPORT */ -#define CI_ADDR 3 - -#if LWIP_DNS -#define CI_MS_DNS1 129 /* Primary DNS value */ -#define CI_MS_DNS2 131 /* Secondary DNS value */ -#endif /* LWIP_DNS */ -#if 0 /* UNUSED - WINS */ -#define CI_MS_WINS1 130 /* Primary WINS value */ -#define CI_MS_WINS2 132 /* Secondary WINS value */ -#endif /* UNUSED - WINS */ - -#if VJ_SUPPORT -#define MAX_STATES 16 /* from slcompress.h */ - -#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */ -#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */ -#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */ - /* maxslot and slot number compression) */ - -#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/ -#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */ - /* compression option*/ -#endif /* VJ_SUPPORT */ - -typedef struct ipcp_options { - unsigned int neg_addr :1; /* Negotiate IP Address? */ - unsigned int old_addrs :1; /* Use old (IP-Addresses) option? */ - unsigned int req_addr :1; /* Ask peer to send IP address? */ -#if 0 /* UNUSED */ - unsigned int default_route :1; /* Assign default route through interface? */ - unsigned int replace_default_route :1; /* Replace default route through interface? */ -#endif /* UNUSED */ -#if 0 /* UNUSED - PROXY ARP */ - unsigned int proxy_arp :1; /* Make proxy ARP entry for peer? */ -#endif /* UNUSED - PROXY ARP */ -#if VJ_SUPPORT - unsigned int neg_vj :1; /* Van Jacobson Compression? */ - unsigned int old_vj :1; /* use old (short) form of VJ option? */ - unsigned int cflag :1; -#endif /* VJ_SUPPORT */ - unsigned int accept_local :1; /* accept peer's value for ouraddr */ - unsigned int accept_remote :1; /* accept peer's value for hisaddr */ -#if LWIP_DNS - unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */ - unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */ -#endif /* LWIP_DNS */ - - u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ -#if LWIP_DNS - u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ -#endif /* LWIP_DNS */ -#if 0 /* UNUSED - WINS */ - u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ -#endif /* UNUSED - WINS */ - -#if VJ_SUPPORT - u16_t vj_protocol; /* protocol value to use in VJ option */ - u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */ -#endif /* VJ_SUPPORT */ -} ipcp_options; - -#if 0 /* UNUSED, already defined by lwIP */ -char *ip_ntoa (u32_t); -#endif /* UNUSED, already defined by lwIP */ - -extern const struct protent ipcp_protent; - -#endif /* IPCP_H */ -#endif /* PPP_SUPPORT && PPP_IPV4_SUPPORT */ diff --git a/include/netif/ppp/ipv6cp.h b/include/netif/ppp/ipv6cp.h deleted file mode 100644 index 07d1ae3..0000000 --- a/include/netif/ppp/ipv6cp.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * ipv6cp.h - PPP IPV6 Control Protocol. - * - * Copyright (c) 1999 Tommi Komulainen. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Tommi Komulainen - * ". - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -/* Original version, based on RFC2023 : - - Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt, - Alain.Durand@imag.fr, IMAG, - Jean-Luc.Richier@imag.fr, IMAG-LSR. - - Copyright (c) 1998, 1999 Francis.Dupont@inria.fr, GIE DYADE, - Alain.Durand@imag.fr, IMAG, - Jean-Luc.Richier@imag.fr, IMAG-LSR. - - Ce travail a été fait au sein du GIE DYADE (Groupement d'Intérêt - Économique ayant pour membres BULL S.A. et l'INRIA). - - Ce logiciel informatique est disponible aux conditions - usuelles dans la recherche, c'est-à-dire qu'il peut - être utilisé, copié, modifié, distribué à l'unique - condition que ce texte soit conservé afin que - l'origine de ce logiciel soit reconnue. - - Le nom de l'Institut National de Recherche en Informatique - et en Automatique (INRIA), de l'IMAG, ou d'une personne morale - ou physique ayant participé à l'élaboration de ce logiciel ne peut - être utilisé sans son accord préalable explicite. - - Ce logiciel est fourni tel quel sans aucune garantie, - support ou responsabilité d'aucune sorte. - Ce logiciel est dérivé de sources d'origine - "University of California at Berkeley" et - "Digital Equipment Corporation" couvertes par des copyrights. - - L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG) - est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National - Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant - sept laboratoires dont le laboratoire Logiciels, Systèmes, Réseaux (LSR). - - This work has been done in the context of GIE DYADE (joint R & D venture - between BULL S.A. and INRIA). - - This software is available with usual "research" terms - with the aim of retain credits of the software. - Permission to use, copy, modify and distribute this software for any - purpose and without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies, - and the name of INRIA, IMAG, or any contributor not be used in advertising - or publicity pertaining to this material without the prior explicit - permission. The software is provided "as is" without any - warranties, support or liabilities of any kind. - This software is derived from source code from - "University of California at Berkeley" and - "Digital Equipment Corporation" protected by copyrights. - - Grenoble's Institute of Computer Science and Applied Mathematics (IMAG) - is a federation of seven research units funded by the CNRS, National - Polytechnic Institute of Grenoble and University Joseph Fourier. - The research unit in Software, Systems, Networks (LSR) is member of IMAG. -*/ - -/* - * Derived from : - * - * - * ipcp.h - IP Control Protocol definitions. - * - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: ipv6cp.h,v 1.7 2002/12/04 23:03:32 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef IPV6CP_H -#define IPV6CP_H - -#include "eui64.h" - -/* - * Options. - */ -#define CI_IFACEID 1 /* Interface Identifier */ -#ifdef IPV6CP_COMP -#define CI_COMPRESSTYPE 2 /* Compression Type */ -#endif /* IPV6CP_COMP */ - -/* No compression types yet defined. - *#define IPV6CP_COMP 0x004f - */ -typedef struct ipv6cp_options { - unsigned int neg_ifaceid :1; /* Negotiate interface identifier? */ - unsigned int req_ifaceid :1; /* Ask peer to send interface identifier? */ - unsigned int accept_local :1; /* accept peer's value for iface id? */ - unsigned int opt_local :1; /* ourtoken set by option */ - unsigned int opt_remote :1; /* histoken set by option */ - unsigned int use_ip :1; /* use IP as interface identifier */ -#if 0 - unsigned int use_persistent :1; /* use uniquely persistent value for address */ -#endif -#ifdef IPV6CP_COMP - unsigned int neg_vj :1; /* Van Jacobson Compression? */ -#endif /* IPV6CP_COMP */ - -#ifdef IPV6CP_COMP - u_short vj_protocol; /* protocol value to use in VJ option */ -#endif /* IPV6CP_COMP */ - eui64_t ourid, hisid; /* Interface identifiers */ -} ipv6cp_options; - -extern const struct protent ipv6cp_protent; - -#endif /* IPV6CP_H */ -#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ diff --git a/include/netif/ppp/lcp.h b/include/netif/ppp/lcp.h deleted file mode 100644 index 12e2a05..0000000 --- a/include/netif/ppp/lcp.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - * lcp.h - Link Control Protocol definitions. - * - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: lcp.h,v 1.20 2004/11/14 22:53:42 carlsonj Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef LCP_H -#define LCP_H - -#include "ppp.h" - -/* - * Options. - */ -#define CI_VENDOR 0 /* Vendor Specific */ -#define CI_MRU 1 /* Maximum Receive Unit */ -#define CI_ASYNCMAP 2 /* Async Control Character Map */ -#define CI_AUTHTYPE 3 /* Authentication Type */ -#define CI_QUALITY 4 /* Quality Protocol */ -#define CI_MAGICNUMBER 5 /* Magic Number */ -#define CI_PCOMPRESSION 7 /* Protocol Field Compression */ -#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */ -#define CI_FCSALTERN 9 /* FCS-Alternatives */ -#define CI_SDP 10 /* Self-Describing-Pad */ -#define CI_NUMBERED 11 /* Numbered-Mode */ -#define CI_CALLBACK 13 /* callback */ -#define CI_MRRU 17 /* max reconstructed receive unit; multilink */ -#define CI_SSNHF 18 /* short sequence numbers for multilink */ -#define CI_EPDISC 19 /* endpoint discriminator */ -#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */ -#define CI_LDISC 23 /* Link-Discriminator */ -#define CI_LCPAUTH 24 /* LCP Authentication */ -#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */ -#define CI_PREFELIS 26 /* Prefix Elision */ -#define CI_MPHDRFMT 27 /* MP Header Format */ -#define CI_I18N 28 /* Internationalization */ -#define CI_SDL 29 /* Simple Data Link */ - -/* - * LCP-specific packet types (code numbers). - */ -#define PROTREJ 8 /* Protocol Reject */ -#define ECHOREQ 9 /* Echo Request */ -#define ECHOREP 10 /* Echo Reply */ -#define DISCREQ 11 /* Discard Request */ -#define IDENTIF 12 /* Identification */ -#define TIMEREM 13 /* Time Remaining */ - -/* Value used as data for CI_CALLBACK option */ -#define CBCP_OPT 6 /* Use callback control protocol */ - -#if 0 /* moved to ppp_opts.h */ -#define DEFMRU 1500 /* Try for this */ -#define MINMRU 128 /* No MRUs below this */ -#define MAXMRU 16384 /* Normally limit MRU to this */ -#endif /* moved to ppp_opts.h */ - -/* An endpoint discriminator, used with multilink. */ -#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */ -struct epdisc { - unsigned char class_; /* -- The word "class" is reserved in C++. */ - unsigned char length; - unsigned char value[MAX_ENDP_LEN]; -}; - -/* - * The state of options is described by an lcp_options structure. - */ -typedef struct lcp_options { - unsigned int passive :1; /* Don't die if we don't get a response */ - unsigned int silent :1; /* Wait for the other end to start first */ -#if 0 /* UNUSED */ - unsigned int restart :1; /* Restart vs. exit after close */ -#endif /* UNUSED */ - unsigned int neg_mru :1; /* Negotiate the MRU? */ - unsigned int neg_asyncmap :1; /* Negotiate the async map? */ -#if PAP_SUPPORT - unsigned int neg_upap :1; /* Ask for UPAP authentication? */ -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT - unsigned int neg_chap :1; /* Ask for CHAP authentication? */ -#endif /* CHAP_SUPPORT */ -#if EAP_SUPPORT - unsigned int neg_eap :1; /* Ask for EAP authentication? */ -#endif /* EAP_SUPPORT */ - unsigned int neg_magicnumber :1; /* Ask for magic number? */ - unsigned int neg_pcompression :1; /* HDLC Protocol Field Compression? */ - unsigned int neg_accompression :1; /* HDLC Address/Control Field Compression? */ -#if LQR_SUPPORT - unsigned int neg_lqr :1; /* Negotiate use of Link Quality Reports */ -#endif /* LQR_SUPPORT */ - unsigned int neg_cbcp :1; /* Negotiate use of CBCP */ -#ifdef HAVE_MULTILINK - unsigned int neg_mrru :1; /* negotiate multilink MRRU */ -#endif /* HAVE_MULTILINK */ - unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */ - unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */ - - u16_t mru; /* Value of MRU */ -#ifdef HAVE_MULTILINK - u16_t mrru; /* Value of MRRU, and multilink enable */ -#endif /* MULTILINK */ -#if CHAP_SUPPORT - u8_t chap_mdtype; /* which MD types (hashing algorithm) */ -#endif /* CHAP_SUPPORT */ - u32_t asyncmap; /* Value of async map */ - u32_t magicnumber; - u8_t numloops; /* Number of loops during magic number neg. */ -#if LQR_SUPPORT - u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ -#endif /* LQR_SUPPORT */ - struct epdisc endpoint; /* endpoint discriminator */ -} lcp_options; - -void lcp_open(ppp_pcb *pcb); -void lcp_close(ppp_pcb *pcb, const char *reason); -void lcp_lowerup(ppp_pcb *pcb); -void lcp_lowerdown(ppp_pcb *pcb); -void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */ - -extern const struct protent lcp_protent; - -#if 0 /* moved to ppp_opts.h */ -/* Default number of times we receive our magic number from the peer - before deciding the link is looped-back. */ -#define DEFLOOPBACKFAIL 10 -#endif /* moved to ppp_opts.h */ - -#endif /* LCP_H */ -#endif /* PPP_SUPPORT */ diff --git a/include/netif/ppp/magic.h b/include/netif/ppp/magic.h deleted file mode 100644 index a2a9b53..0000000 --- a/include/netif/ppp/magic.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * magic.h - PPP Magic Number definitions. - * - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $ - */ -/***************************************************************************** -* randm.h - Random number generator header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* Copyright (c) 1998 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 98-05-29 Guy Lancaster , Global Election Systems Inc. -* Extracted from avos. -*****************************************************************************/ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef MAGIC_H -#define MAGIC_H - -/*********************** -*** PUBLIC FUNCTIONS *** -***********************/ - -/* - * Initialize the random number generator. - */ -void magic_init(void); - -/* - * Randomize our random seed value. To be called for truely random events - * such as user operations and network traffic. - */ -void magic_randomize(void); - -/* - * Return a new random number. - */ -u32_t magic(void); /* Returns the next magic number */ - -/* - * Fill buffer with random bytes - * - * Use the random pool to generate random data. This degrades to pseudo - * random when used faster than randomness is supplied using magic_churnrand(). - * Thus it's important to make sure that the results of this are not - * published directly because one could predict the next result to at - * least some degree. Also, it's important to get a good seed before - * the first use. - */ -void magic_random_bytes(unsigned char *buf, u32_t buf_len); - -/* - * Return a new random number between 0 and (2^pow)-1 included. - */ -u32_t magic_pow(u8_t pow); - -#endif /* MAGIC_H */ - -#endif /* PPP_SUPPORT */ diff --git a/include/netif/ppp/mppe.h b/include/netif/ppp/mppe.h deleted file mode 100644 index 1ae8a5d..0000000 --- a/include/netif/ppp/mppe.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * mppe.h - Definitions for MPPE - * - * Copyright (c) 2008 Paul Mackerras. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Paul Mackerras - * ". - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && MPPE_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef MPPE_H -#define MPPE_H - -#include "netif/ppp/pppcrypt.h" - -#define MPPE_PAD 4 /* MPPE growth per frame */ -#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ - -/* option bits for ccp_options.mppe */ -#define MPPE_OPT_40 0x01 /* 40 bit */ -#define MPPE_OPT_128 0x02 /* 128 bit */ -#define MPPE_OPT_STATEFUL 0x04 /* stateful mode */ -/* unsupported opts */ -#define MPPE_OPT_56 0x08 /* 56 bit */ -#define MPPE_OPT_MPPC 0x10 /* MPPC compression */ -#define MPPE_OPT_D 0x20 /* Unknown */ -#define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D) -#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */ - -/* - * This is not nice ... the alternative is a bitfield struct though. - * And unfortunately, we cannot share the same bits for the option - * names above since C and H are the same bit. We could do a u_int32 - * but then we have to do a lwip_htonl() all the time and/or we still need - * to know which octet is which. - */ -#define MPPE_C_BIT 0x01 /* MPPC */ -#define MPPE_D_BIT 0x10 /* Obsolete, usage unknown */ -#define MPPE_L_BIT 0x20 /* 40-bit */ -#define MPPE_S_BIT 0x40 /* 128-bit */ -#define MPPE_M_BIT 0x80 /* 56-bit, not supported */ -#define MPPE_H_BIT 0x01 /* Stateless (in a different byte) */ - -/* Does not include H bit; used for least significant octet only. */ -#define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT) - -/* Build a CI from mppe opts (see RFC 3078) */ -#define MPPE_OPTS_TO_CI(opts, ci) \ - do { \ - u_char *ptr = ci; /* u_char[4] */ \ - \ - /* H bit */ \ - if (opts & MPPE_OPT_STATEFUL) \ - *ptr++ = 0x0; \ - else \ - *ptr++ = MPPE_H_BIT; \ - *ptr++ = 0; \ - *ptr++ = 0; \ - \ - /* S,L bits */ \ - *ptr = 0; \ - if (opts & MPPE_OPT_128) \ - *ptr |= MPPE_S_BIT; \ - if (opts & MPPE_OPT_40) \ - *ptr |= MPPE_L_BIT; \ - /* M,D,C bits not supported */ \ - } while (/* CONSTCOND */ 0) - -/* The reverse of the above */ -#define MPPE_CI_TO_OPTS(ci, opts) \ - do { \ - const u_char *ptr = ci; /* u_char[4] */ \ - \ - opts = 0; \ - \ - /* H bit */ \ - if (!(ptr[0] & MPPE_H_BIT)) \ - opts |= MPPE_OPT_STATEFUL; \ - \ - /* S,L bits */ \ - if (ptr[3] & MPPE_S_BIT) \ - opts |= MPPE_OPT_128; \ - if (ptr[3] & MPPE_L_BIT) \ - opts |= MPPE_OPT_40; \ - \ - /* M,D,C bits */ \ - if (ptr[3] & MPPE_M_BIT) \ - opts |= MPPE_OPT_56; \ - if (ptr[3] & MPPE_D_BIT) \ - opts |= MPPE_OPT_D; \ - if (ptr[3] & MPPE_C_BIT) \ - opts |= MPPE_OPT_MPPC; \ - \ - /* Other bits */ \ - if (ptr[0] & ~MPPE_H_BIT) \ - opts |= MPPE_OPT_UNKNOWN; \ - if (ptr[1] || ptr[2]) \ - opts |= MPPE_OPT_UNKNOWN; \ - if (ptr[3] & ~MPPE_ALL_BITS) \ - opts |= MPPE_OPT_UNKNOWN; \ - } while (/* CONSTCOND */ 0) - -/* Shared MPPE padding between MSCHAP and MPPE */ -#define SHA1_PAD_SIZE 40 - -static const u8_t mppe_sha1_pad1[SHA1_PAD_SIZE] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; -static const u8_t mppe_sha1_pad2[SHA1_PAD_SIZE] = { - 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, - 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, - 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, - 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2 -}; - -/* - * State for an MPPE (de)compressor. - */ -typedef struct ppp_mppe_state { - lwip_arc4_context arc4; - u8_t master_key[MPPE_MAX_KEY_LEN]; - u8_t session_key[MPPE_MAX_KEY_LEN]; - u8_t keylen; /* key length in bytes */ - /* NB: 128-bit == 16, 40-bit == 8! - * If we want to support 56-bit, the unit has to change to bits - */ - u8_t bits; /* MPPE control bits */ - u16_t ccount; /* 12-bit coherency count (seqno) */ - u16_t sanity_errors; /* take down LCP if too many */ - unsigned int stateful :1; /* stateful mode flag */ - unsigned int discard :1; /* stateful mode packet loss flag */ -} ppp_mppe_state; - -void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key); -void mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options); -void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state); -err_t mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t protocol); -void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state); -err_t mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb); - -#endif /* MPPE_H */ -#endif /* PPP_SUPPORT && MPPE_SUPPORT */ diff --git a/include/netif/ppp/polarssl/arc4.h b/include/netif/ppp/polarssl/arc4.h deleted file mode 100644 index 863626d..0000000 --- a/include/netif/ppp/polarssl/arc4.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * \file arc4.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_ARC4 - -#ifndef LWIP_INCLUDED_POLARSSL_ARC4_H -#define LWIP_INCLUDED_POLARSSL_ARC4_H - -/** - * \brief ARC4 context structure - */ -typedef struct -{ - int x; /*!< permutation index */ - int y; /*!< permutation index */ - unsigned char m[256]; /*!< permutation table */ -} -arc4_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief ARC4 key schedule - * - * \param ctx ARC4 context to be initialized - * \param key the secret key - * \param keylen length of the key - */ -void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); - -/** - * \brief ARC4 cipher function - * - * \param ctx ARC4 context - * \param buf buffer to be processed - * \param buflen amount of data in buf - */ -void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ diff --git a/include/netif/ppp/polarssl/des.h b/include/netif/ppp/polarssl/des.h deleted file mode 100644 index ad2f0a2..0000000 --- a/include/netif/ppp/polarssl/des.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * \file des.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_DES - -#ifndef LWIP_INCLUDED_POLARSSL_DES_H -#define LWIP_INCLUDED_POLARSSL_DES_H - -#define DES_ENCRYPT 1 -#define DES_DECRYPT 0 - -/** - * \brief DES context structure - */ -typedef struct -{ - int mode; /*!< encrypt/decrypt */ - unsigned long sk[32]; /*!< DES subkeys */ -} -des_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief DES key schedule (56-bit, encryption) - * - * \param ctx DES context to be initialized - * \param key 8-byte secret key - */ -void des_setkey_enc( des_context *ctx, unsigned char key[8] ); - -/** - * \brief DES key schedule (56-bit, decryption) - * - * \param ctx DES context to be initialized - * \param key 8-byte secret key - */ -void des_setkey_dec( des_context *ctx, unsigned char key[8] ); - -/** - * \brief DES-ECB block encryption/decryption - * - * \param ctx DES context - * \param input 64-bit input block - * \param output 64-bit output block - */ -void des_crypt_ecb( des_context *ctx, - const unsigned char input[8], - unsigned char output[8] ); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_DES_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_DES */ diff --git a/include/netif/ppp/polarssl/md4.h b/include/netif/ppp/polarssl/md4.h deleted file mode 100644 index 2262995..0000000 --- a/include/netif/ppp/polarssl/md4.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * \file md4.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_MD4 - -#ifndef LWIP_INCLUDED_POLARSSL_MD4_H -#define LWIP_INCLUDED_POLARSSL_MD4_H - -/** - * \brief MD4 context structure - */ -typedef struct -{ - unsigned long total[2]; /*!< number of bytes processed */ - unsigned long state[4]; /*!< intermediate digest state */ - unsigned char buffer[64]; /*!< data block being processed */ -} -md4_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief MD4 context setup - * - * \param ctx context to be initialized - */ -void md4_starts( md4_context *ctx ); - -/** - * \brief MD4 process buffer - * - * \param ctx MD4 context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); - -/** - * \brief MD4 final digest - * - * \param ctx MD4 context - * \param output MD4 checksum result - */ -void md4_finish( md4_context *ctx, unsigned char output[16] ); - -/** - * \brief Output = MD4( input buffer ) - * - * \param input buffer holding the data - * \param ilen length of the input data - * \param output MD4 checksum result - */ -void md4( unsigned char *input, int ilen, unsigned char output[16] ); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_MD4_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_MD4 */ diff --git a/include/netif/ppp/polarssl/md5.h b/include/netif/ppp/polarssl/md5.h deleted file mode 100644 index 3059e1d..0000000 --- a/include/netif/ppp/polarssl/md5.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * \file md5.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_MD5 - -#ifndef LWIP_INCLUDED_POLARSSL_MD5_H -#define LWIP_INCLUDED_POLARSSL_MD5_H - -/** - * \brief MD5 context structure - */ -typedef struct -{ - unsigned long total[2]; /*!< number of bytes processed */ - unsigned long state[4]; /*!< intermediate digest state */ - unsigned char buffer[64]; /*!< data block being processed */ -} -md5_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief MD5 context setup - * - * \param ctx context to be initialized - */ -void md5_starts( md5_context *ctx ); - -/** - * \brief MD5 process buffer - * - * \param ctx MD5 context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); - -/** - * \brief MD5 final digest - * - * \param ctx MD5 context - * \param output MD5 checksum result - */ -void md5_finish( md5_context *ctx, unsigned char output[16] ); - -/** - * \brief Output = MD5( input buffer ) - * - * \param input buffer holding the data - * \param ilen length of the input data - * \param output MD5 checksum result - */ -void md5( unsigned char *input, int ilen, unsigned char output[16] ); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_MD5 */ diff --git a/include/netif/ppp/polarssl/sha1.h b/include/netif/ppp/polarssl/sha1.h deleted file mode 100644 index 6d2a76e..0000000 --- a/include/netif/ppp/polarssl/sha1.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * \file sha1.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_SHA1 - -#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H -#define LWIP_INCLUDED_POLARSSL_SHA1_H - -/** - * \brief SHA-1 context structure - */ -typedef struct -{ - unsigned long total[2]; /*!< number of bytes processed */ - unsigned long state[5]; /*!< intermediate digest state */ - unsigned char buffer[64]; /*!< data block being processed */ -} -sha1_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief SHA-1 context setup - * - * \param ctx context to be initialized - */ -void sha1_starts( sha1_context *ctx ); - -/** - * \brief SHA-1 process buffer - * - * \param ctx SHA-1 context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); - -/** - * \brief SHA-1 final digest - * - * \param ctx SHA-1 context - * \param output SHA-1 checksum result - */ -void sha1_finish( sha1_context *ctx, unsigned char output[20] ); - -/** - * \brief Output = SHA-1( input buffer ) - * - * \param input buffer holding the data - * \param ilen length of the input data - * \param output SHA-1 checksum result - */ -void sha1( unsigned char *input, int ilen, unsigned char output[20] ); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ diff --git a/include/netif/ppp/ppp.h b/include/netif/ppp/ppp.h deleted file mode 100644 index d966a96..0000000 --- a/include/netif/ppp/ppp.h +++ /dev/null @@ -1,690 +0,0 @@ -/***************************************************************************** -* ppp.h - Network Point to Point Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef PPP_H -#define PPP_H - -#include "net/def.h" -#include "net/stats.h" -#include "net/mem.h" -#include "net/netif.h" -#include "net/sys.h" -#include "net/timeouts.h" -#if PPP_IPV6_SUPPORT -#include "net/ip6_addr.h" -#endif /* PPP_IPV6_SUPPORT */ - -/* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat ppp_opts.h with them */ -#ifndef PPP_OPTIONS -#define PPP_OPTIONS 0 -#endif - -#ifndef PPP_NOTIFY -#define PPP_NOTIFY 0 -#endif - -#ifndef PPP_REMOTENAME -#define PPP_REMOTENAME 0 -#endif - -#ifndef PPP_IDLETIMELIMIT -#define PPP_IDLETIMELIMIT 0 -#endif - -#ifndef PPP_LCP_ADAPTIVE -#define PPP_LCP_ADAPTIVE 0 -#endif - -#ifndef PPP_MAXCONNECT -#define PPP_MAXCONNECT 0 -#endif - -#ifndef PPP_ALLOWED_ADDRS -#define PPP_ALLOWED_ADDRS 0 -#endif - -#ifndef PPP_PROTOCOLNAME -#define PPP_PROTOCOLNAME 0 -#endif - -#ifndef PPP_STATS_SUPPORT -#define PPP_STATS_SUPPORT 0 -#endif - -#ifndef DEFLATE_SUPPORT -#define DEFLATE_SUPPORT 0 -#endif - -#ifndef BSDCOMPRESS_SUPPORT -#define BSDCOMPRESS_SUPPORT 0 -#endif - -#ifndef PREDICTOR_SUPPORT -#define PREDICTOR_SUPPORT 0 -#endif - -/************************* -*** PUBLIC DEFINITIONS *** -*************************/ - -/* - * The basic PPP frame. - */ -#define PPP_HDRLEN 4 /* octets for standard ppp header */ -#define PPP_FCSLEN 2 /* octets for FCS */ - -/* - * Values for phase. - */ -#define PPP_PHASE_DEAD 0 -#define PPP_PHASE_MASTER 1 -#define PPP_PHASE_HOLDOFF 2 -#define PPP_PHASE_INITIALIZE 3 -#define PPP_PHASE_SERIALCONN 4 -#define PPP_PHASE_DORMANT 5 -#define PPP_PHASE_ESTABLISH 6 -#define PPP_PHASE_AUTHENTICATE 7 -#define PPP_PHASE_CALLBACK 8 -#define PPP_PHASE_NETWORK 9 -#define PPP_PHASE_RUNNING 10 -#define PPP_PHASE_TERMINATE 11 -#define PPP_PHASE_DISCONNECT 12 - -/* Error codes. */ -#define PPPERR_NONE 0 /* No error. */ -#define PPPERR_PARAM 1 /* Invalid parameter. */ -#define PPPERR_OPEN 2 /* Unable to open PPP session. */ -#define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */ -#define PPPERR_ALLOC 4 /* Unable to allocate resources. */ -#define PPPERR_USER 5 /* User interrupt. */ -#define PPPERR_CONNECT 6 /* Connection lost. */ -#define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */ -#define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */ -#define PPPERR_PEERDEAD 9 /* Connection timeout */ -#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */ -#define PPPERR_CONNECTTIME 11 /* Max connect time reached */ -#define PPPERR_LOOPBACK 12 /* Loopback detected */ - -/* Whether auth support is enabled at all */ -#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT) - -/************************ -*** PUBLIC DATA TYPES *** -************************/ - -/* - * Other headers require ppp_pcb definition for prototypes, but ppp_pcb - * require some structure definition from other headers as well, we are - * fixing the dependency loop here by declaring the ppp_pcb type then - * by including headers containing necessary struct definition for ppp_pcb - */ -typedef struct ppp_pcb_s ppp_pcb; - -/* Type definitions for BSD code. */ -#ifndef __u_char_defined -typedef unsigned long u_long; -typedef unsigned int u_int; -typedef unsigned short u_short; -typedef unsigned char u_char; -#endif - -#include "fsm.h" -#include "lcp.h" -#if CCP_SUPPORT -#include "ccp.h" -#endif /* CCP_SUPPORT */ -#if MPPE_SUPPORT -#include "mppe.h" -#endif /* MPPE_SUPPORT */ -#if PPP_IPV4_SUPPORT -#include "ipcp.h" -#endif /* PPP_IPV4_SUPPORT */ -#if PPP_IPV6_SUPPORT -#include "ipv6cp.h" -#endif /* PPP_IPV6_SUPPORT */ -#if PAP_SUPPORT -#include "upap.h" -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT -#include "chap-new.h" -#endif /* CHAP_SUPPORT */ -#if EAP_SUPPORT -#include "eap.h" -#endif /* EAP_SUPPORT */ -#if VJ_SUPPORT -#include "vj.h" -#endif /* VJ_SUPPORT */ - -/* Link status callback function prototype */ -typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx); - -/* - * PPP configuration. - */ -typedef struct ppp_settings_s { - -#if PPP_SERVER && PPP_AUTH_SUPPORT - unsigned int auth_required :1; /* Peer is required to authenticate */ - unsigned int null_login :1; /* Username of "" and a password of "" are acceptable */ -#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */ -#if PPP_REMOTENAME - unsigned int explicit_remote :1; /* remote_name specified with remotename opt */ -#endif /* PPP_REMOTENAME */ -#if PAP_SUPPORT - unsigned int refuse_pap :1; /* Don't proceed auth. with PAP */ -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT - unsigned int refuse_chap :1; /* Don't proceed auth. with CHAP */ -#endif /* CHAP_SUPPORT */ -#if MSCHAP_SUPPORT - unsigned int refuse_mschap :1; /* Don't proceed auth. with MS-CHAP */ - unsigned int refuse_mschap_v2 :1; /* Don't proceed auth. with MS-CHAPv2 */ -#endif /* MSCHAP_SUPPORT */ -#if EAP_SUPPORT - unsigned int refuse_eap :1; /* Don't proceed auth. with EAP */ -#endif /* EAP_SUPPORT */ -#if LWIP_DNS - unsigned int usepeerdns :1; /* Ask peer for DNS adds */ -#endif /* LWIP_DNS */ - unsigned int persist :1; /* Persist mode, always try to open the connection */ -#if PRINTPKT_SUPPORT - unsigned int hide_password :1; /* Hide password in dumped packets */ -#endif /* PRINTPKT_SUPPORT */ - unsigned int noremoteip :1; /* Let him have no IP address */ - unsigned int lax_recv :1; /* accept control chars in asyncmap */ - unsigned int noendpoint :1; /* don't send/accept endpoint discriminator */ -#if PPP_LCP_ADAPTIVE - unsigned int lcp_echo_adaptive :1; /* request echo only if the link was idle */ -#endif /* PPP_LCP_ADAPTIVE */ -#if MPPE_SUPPORT - unsigned int require_mppe :1; /* Require MPPE (Microsoft Point to Point Encryption) */ - unsigned int refuse_mppe_40 :1; /* Allow MPPE 40-bit mode? */ - unsigned int refuse_mppe_128 :1; /* Allow MPPE 128-bit mode? */ - unsigned int refuse_mppe_stateful :1; /* Allow MPPE stateful mode? */ -#endif /* MPPE_SUPPORT */ - - u16_t listen_time; /* time to listen first (ms), waiting for peer to send LCP packet */ - -#if PPP_IDLETIMELIMIT - u16_t idle_time_limit; /* Disconnect if idle for this many seconds */ -#endif /* PPP_IDLETIMELIMIT */ -#if PPP_MAXCONNECT - u32_t maxconnect; /* Maximum connect time (seconds) */ -#endif /* PPP_MAXCONNECT */ - -#if PPP_AUTH_SUPPORT - /* auth data */ - const char *user; /* Username for PAP */ - const char *passwd; /* Password for PAP, secret for CHAP */ -#if PPP_REMOTENAME - char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ -#endif /* PPP_REMOTENAME */ - -#if PAP_SUPPORT - u8_t pap_timeout_time; /* Timeout (seconds) for auth-req retrans. */ - u8_t pap_max_transmits; /* Number of auth-reqs sent */ -#if PPP_SERVER - u8_t pap_req_timeout; /* Time to wait for auth-req from peer */ -#endif /* PPP_SERVER */ -#endif /* PAP_SUPPPORT */ - -#if CHAP_SUPPORT - u8_t chap_timeout_time; /* Timeout (seconds) for retransmitting req */ - u8_t chap_max_transmits; /* max # times to send challenge */ -#if PPP_SERVER - u8_t chap_rechallenge_time; /* Time to wait for auth-req from peer */ -#endif /* PPP_SERVER */ -#endif /* CHAP_SUPPPORT */ - -#if EAP_SUPPORT - u8_t eap_req_time; /* Time to wait (for retransmit/fail) */ - u8_t eap_allow_req; /* Max Requests allowed */ -#if PPP_SERVER - u8_t eap_timeout_time; /* Time to wait (for retransmit/fail) */ - u8_t eap_max_transmits; /* Max Requests allowed */ -#endif /* PPP_SERVER */ -#endif /* EAP_SUPPORT */ - -#endif /* PPP_AUTH_SUPPORT */ - - u8_t fsm_timeout_time; /* Timeout time in seconds */ - u8_t fsm_max_conf_req_transmits; /* Maximum Configure-Request transmissions */ - u8_t fsm_max_term_transmits; /* Maximum Terminate-Request transmissions */ - u8_t fsm_max_nak_loops; /* Maximum number of nak loops tolerated */ - - u8_t lcp_loopbackfail; /* Number of times we receive our magic number from the peer - before deciding the link is looped-back. */ - u8_t lcp_echo_interval; /* Interval between LCP echo-requests */ - u8_t lcp_echo_fails; /* Tolerance to unanswered echo-requests */ - -} ppp_settings; - -#if PPP_SERVER -struct ppp_addrs { -#if PPP_IPV4_SUPPORT - ip4_addr_t our_ipaddr, his_ipaddr, netmask; -#if LWIP_DNS - ip4_addr_t dns1, dns2; -#endif /* LWIP_DNS */ -#endif /* PPP_IPV4_SUPPORT */ -#if PPP_IPV6_SUPPORT - ip6_addr_t our6_ipaddr, his6_ipaddr; -#endif /* PPP_IPV6_SUPPORT */ -}; -#endif /* PPP_SERVER */ - -/* - * PPP interface control block. - */ -struct ppp_pcb_s { - ppp_settings settings; - const struct link_callbacks *link_cb; - void *link_ctx_cb; - void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */ -#if PPP_NOTIFY_PHASE - void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase, void *ctx); /* Notify phase callback */ -#endif /* PPP_NOTIFY_PHASE */ - void *ctx_cb; /* Callbacks optional pointer */ - struct netif *netif; /* PPP interface */ - u8_t phase; /* where the link is at */ - u8_t err_code; /* Code indicating why interface is down. */ - - /* flags */ -#if PPP_IPV4_SUPPORT - unsigned int ask_for_local :1; /* request our address from peer */ - unsigned int ipcp_is_open :1; /* haven't called np_finished() */ - unsigned int ipcp_is_up :1; /* have called ipcp_up() */ - unsigned int if4_up :1; /* True when the IPv4 interface is up. */ -#if 0 /* UNUSED - PROXY ARP */ - unsigned int proxy_arp_set :1; /* Have created proxy arp entry */ -#endif /* UNUSED - PROXY ARP */ -#endif /* PPP_IPV4_SUPPORT */ -#if PPP_IPV6_SUPPORT - unsigned int ipv6cp_is_up :1; /* have called ip6cp_up() */ - unsigned int if6_up :1; /* True when the IPv6 interface is up. */ -#endif /* PPP_IPV6_SUPPORT */ - unsigned int lcp_echo_timer_running :1; /* set if a timer is running */ -#if VJ_SUPPORT - unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */ -#endif /* VJ_SUPPORT */ -#if CCP_SUPPORT - unsigned int ccp_all_rejected :1; /* we rejected all peer's options */ -#endif /* CCP_SUPPORT */ -#if MPPE_SUPPORT - unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */ -#endif /* MPPE_SUPPORT */ - -#if PPP_AUTH_SUPPORT - /* auth data */ -#if PPP_SERVER && defined(HAVE_MULTILINK) - char peer_authname[MAXNAMELEN + 1]; /* The name by which the peer authenticated itself to us. */ -#endif /* PPP_SERVER && defined(HAVE_MULTILINK) */ - u16_t auth_pending; /* Records which authentication operations haven't completed yet. */ - u16_t auth_done; /* Records which authentication operations have been completed. */ - -#if PAP_SUPPORT - upap_state upap; /* PAP data */ -#endif /* PAP_SUPPORT */ - -#if CHAP_SUPPORT - chap_client_state chap_client; /* CHAP client data */ -#if PPP_SERVER - chap_server_state chap_server; /* CHAP server data */ -#endif /* PPP_SERVER */ -#endif /* CHAP_SUPPORT */ - -#if EAP_SUPPORT - eap_state eap; /* EAP data */ -#endif /* EAP_SUPPORT */ -#endif /* PPP_AUTH_SUPPORT */ - - fsm lcp_fsm; /* LCP fsm structure */ - lcp_options lcp_wantoptions; /* Options that we want to request */ - lcp_options lcp_gotoptions; /* Options that peer ack'd */ - lcp_options lcp_allowoptions; /* Options we allow peer to request */ - lcp_options lcp_hisoptions; /* Options that we ack'd */ - u16_t peer_mru; /* currently negotiated peer MRU */ - u8_t lcp_echos_pending; /* Number of outstanding echo msgs */ - u8_t lcp_echo_number; /* ID number of next echo frame */ - - u8_t num_np_open; /* Number of network protocols which we have opened. */ - u8_t num_np_up; /* Number of network protocols which have come up. */ - -#if VJ_SUPPORT - struct vjcompress vj_comp; /* Van Jacobson compression header. */ -#endif /* VJ_SUPPORT */ - -#if CCP_SUPPORT - fsm ccp_fsm; /* CCP fsm structure */ - ccp_options ccp_wantoptions; /* what to request the peer to use */ - ccp_options ccp_gotoptions; /* what the peer agreed to do */ - ccp_options ccp_allowoptions; /* what we'll agree to do */ - ccp_options ccp_hisoptions; /* what we agreed to do */ - u8_t ccp_localstate; /* Local state (mainly for handling reset-reqs and reset-acks). */ - u8_t ccp_receive_method; /* Method chosen on receive path */ - u8_t ccp_transmit_method; /* Method chosen on transmit path */ -#if MPPE_SUPPORT - ppp_mppe_state mppe_comp; /* MPPE "compressor" structure */ - ppp_mppe_state mppe_decomp; /* MPPE "decompressor" structure */ -#endif /* MPPE_SUPPORT */ -#endif /* CCP_SUPPORT */ - -#if PPP_IPV4_SUPPORT - fsm ipcp_fsm; /* IPCP fsm structure */ - ipcp_options ipcp_wantoptions; /* Options that we want to request */ - ipcp_options ipcp_gotoptions; /* Options that peer ack'd */ - ipcp_options ipcp_allowoptions; /* Options we allow peer to request */ - ipcp_options ipcp_hisoptions; /* Options that we ack'd */ -#endif /* PPP_IPV4_SUPPORT */ - -#if PPP_IPV6_SUPPORT - fsm ipv6cp_fsm; /* IPV6CP fsm structure */ - ipv6cp_options ipv6cp_wantoptions; /* Options that we want to request */ - ipv6cp_options ipv6cp_gotoptions; /* Options that peer ack'd */ - ipv6cp_options ipv6cp_allowoptions; /* Options we allow peer to request */ - ipv6cp_options ipv6cp_hisoptions; /* Options that we ack'd */ -#endif /* PPP_IPV6_SUPPORT */ -}; - -/************************ - *** PUBLIC FUNCTIONS *** - ************************/ - -/* - * WARNING: For multi-threads environment, all ppp_set_* functions most - * only be called while the PPP is in the dead phase (i.e. disconnected). - */ - -#if PPP_AUTH_SUPPORT -/* - * Set PPP authentication. - * - * Warning: Using PPPAUTHTYPE_ANY might have security consequences. - * RFC 1994 says: - * - * In practice, within or associated with each PPP server, there is a - * database which associates "user" names with authentication - * information ("secrets"). It is not anticipated that a particular - * named user would be authenticated by multiple methods. This would - * make the user vulnerable to attacks which negotiate the least secure - * method from among a set (such as PAP rather than CHAP). If the same - * secret was used, PAP would reveal the secret to be used later with - * CHAP. - * - * Instead, for each user name there should be an indication of exactly - * one method used to authenticate that user name. If a user needs to - * make use of different authentication methods under different - * circumstances, then distinct user names SHOULD be employed, each of - * which identifies exactly one authentication method. - * - * Default is none auth type, unset (NULL) user and passwd. - */ -#define PPPAUTHTYPE_NONE 0x00 -#define PPPAUTHTYPE_PAP 0x01 -#define PPPAUTHTYPE_CHAP 0x02 -#define PPPAUTHTYPE_MSCHAP 0x04 -#define PPPAUTHTYPE_MSCHAP_V2 0x08 -#define PPPAUTHTYPE_EAP 0x10 -#define PPPAUTHTYPE_ANY 0xff -void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd); - -/* - * If set, peer is required to authenticate. This is mostly necessary for PPP server support. - * - * Default is false. - */ -#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval) -#endif /* PPP_AUTH_SUPPORT */ - -#if PPP_IPV4_SUPPORT -/* - * Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server - * support but it can also be used on a PPP link where each side choose its own IP address. - * - * Default is unset (0.0.0.0). - */ -#define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \ - ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0) -#define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr)) -#if LWIP_DNS -/* - * Set DNS server addresses that are sent if the peer asks for them. This is mostly necessary - * for PPP server support. - * - * Default is unset (0.0.0.0). - */ -#define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr)) - -/* - * If set, we ask the peer for up to 2 DNS server addresses. Received DNS server addresses are - * registered using the dns_setserver() function. - * - * Default is false. - */ -#define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval) -#endif /* LWIP_DNS */ -#endif /* PPP_IPV4_SUPPORT */ - -#if MPPE_SUPPORT -/* Disable MPPE (Microsoft Point to Point Encryption). This parameter is exclusive. */ -#define PPP_MPPE_DISABLE 0x00 -/* Require the use of MPPE (Microsoft Point to Point Encryption). */ -#define PPP_MPPE_ENABLE 0x01 -/* Allow MPPE to use stateful mode. Stateless mode is still attempted first. */ -#define PPP_MPPE_ALLOW_STATEFUL 0x02 -/* Refuse the use of MPPE with 40-bit encryption. Conflict with PPP_MPPE_REFUSE_128. */ -#define PPP_MPPE_REFUSE_40 0x04 -/* Refuse the use of MPPE with 128-bit encryption. Conflict with PPP_MPPE_REFUSE_40. */ -#define PPP_MPPE_REFUSE_128 0x08 -/* - * Set MPPE configuration - * - * Default is disabled. - */ -void ppp_set_mppe(ppp_pcb *pcb, u8_t flags); -#endif /* MPPE_SUPPORT */ - -/* - * Wait for up to intval milliseconds for a valid PPP packet from the peer. - * At the end of this time, or when a valid PPP packet is received from the - * peer, we commence negotiation by sending our first LCP packet. - * - * Default is 0. - */ -#define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval) - -/* - * If set, we will attempt to initiate a connection but if no reply is received from - * the peer, we will then just wait passively for a valid LCP packet from the peer. - * - * Default is false. - */ -#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval) - -/* - * If set, we will not transmit LCP packets to initiate a connection until a valid - * LCP packet is received from the peer. This is what we usually call the server mode. - * - * Default is false. - */ -#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval) - -/* - * If set, enable protocol field compression negotiation in both the receive and - * the transmit direction. - * - * Default is true. - */ -#define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \ - ppp->lcp_allowoptions.neg_pcompression = boolval) - -/* - * If set, enable Address/Control compression in both the receive and the transmit - * direction. - * - * Default is true. - */ -#define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \ - ppp->lcp_allowoptions.neg_accompression = boolval) - -/* - * If set, enable asyncmap negotiation. Otherwise forcing all control characters to - * be escaped for both the transmit and the receive direction. - * - * Default is true. - */ -#define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \ - ppp->lcp_allowoptions.neg_asyncmap = boolval) - -/* - * This option sets the Async-Control-Character-Map (ACCM) for this end of the link. - * The ACCM is a set of 32 bits, one for each of the ASCII control characters with - * values from 0 to 31, where a 1 bit indicates that the corresponding control - * character should not be used in PPP packets sent to this system. The map is - * an unsigned 32 bits integer where the least significant bit (00000001) represents - * character 0 and the most significant bit (80000000) represents character 31. - * We will then ask the peer to send these characters as a 2-byte escape sequence. - * - * Default is 0. - */ -#define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval) - -/* - * Set a PPP interface as the default network interface - * (used to output all packets for which no specific route is found). - */ -#define ppp_set_default(ppp) netif_set_default(ppp->netif) - -#if PPP_NOTIFY_PHASE -/* - * Set a PPP notify phase callback. - * - * This can be used for example to set a LED pattern depending on the - * current phase of the PPP session. - */ -typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx); -void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb); -#endif /* PPP_NOTIFY_PHASE */ - -/* - * Initiate a PPP connection. - * - * This can only be called if PPP is in the dead phase. - * - * Holdoff is the time to wait (in seconds) before initiating - * the connection. - * - * If this port connects to a modem, the modem connection must be - * established before calling this. - */ -err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff); - -#if PPP_SERVER -/* - * Listen for an incoming PPP connection. - * - * This can only be called if PPP is in the dead phase. - * - * If this port connects to a modem, the modem connection must be - * established before calling this. - */ -err_t ppp_listen(ppp_pcb *pcb); -#endif /* PPP_SERVER */ - -/* - * Initiate the end of a PPP connection. - * Any outstanding packets in the queues are dropped. - * - * Setting nocarrier to 1 close the PPP connection without initiating the - * shutdown procedure. Always using nocarrier = 0 is still recommended, - * this is going to take a little longer time if your link is down, but - * is a safer choice for the PPP state machine. - * - * Return 0 on success, an error code on failure. - */ -err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier); - -/* - * Release the control block. - * - * This can only be called if PPP is in the dead phase. - * - * You must use ppp_close() before if you wish to terminate - * an established PPP session. - * - * Return 0 on success, an error code on failure. - */ -err_t ppp_free(ppp_pcb *pcb); - -/* - * PPP IOCTL commands. - * - * Get the up status - 0 for down, non-zero for up. The argument must - * point to an int. - */ -#define PPPCTLG_UPSTATUS 0 - -/* - * Get the PPP error code. The argument must point to an int. - * Returns a PPPERR_* value. - */ -#define PPPCTLG_ERRCODE 1 - -/* - * Get the fd associated with a PPP over serial - */ -#define PPPCTLG_FD 2 - -/* - * Get and set parameters for the given connection. - * Return 0 on success, an error code on failure. - */ -err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg); - -/* Get the PPP netif interface */ -#define ppp_netif(ppp) (ppp->netif) - -/* Set an lwIP-style status-callback for the selected PPP device */ -#define ppp_set_netif_statuscallback(ppp, status_cb) \ - netif_set_status_callback(ppp->netif, status_cb); - -/* Set an lwIP-style link-callback for the selected PPP device */ -#define ppp_set_netif_linkcallback(ppp, link_cb) \ - netif_set_link_callback(ppp->netif, link_cb); - -#endif /* PPP_H */ - -#endif /* PPP_SUPPORT */ diff --git a/include/netif/ppp/ppp_impl.h b/include/netif/ppp/ppp_impl.h deleted file mode 100644 index f5c2f04..0000000 --- a/include/netif/ppp/ppp_impl.h +++ /dev/null @@ -1,629 +0,0 @@ -/***************************************************************************** -* ppp.h - Network Point to Point Protocol header file. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1997 Global Election Systems Inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 97-11-05 Guy Lancaster , Global Election Systems Inc. -* Original derived from BSD codes. -*****************************************************************************/ -#ifndef LWIP_HDR_PPP_IMPL_H -#define LWIP_HDR_PPP_IMPL_H - -#include "netif/ppp/ppp_opts.h" - -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifdef PPP_INCLUDE_SETTINGS_HEADER -#include "ppp_settings.h" -#endif - -#include /* formats */ -#include -#include -#include /* strtol() */ - -#include "net/netif.h" -#include "net/def.h" -#include "net/timeouts.h" - -#include "ppp.h" -#include "pppdebug.h" - -/* - * Memory used for control packets. - * - * PPP_CTRL_PBUF_MAX_SIZE is the amount of memory we allocate when we - * cannot figure out how much we are going to use before filling the buffer. - */ -#if PPP_USE_PBUF_RAM -#define PPP_CTRL_PBUF_TYPE PBUF_RAM -#define PPP_CTRL_PBUF_MAX_SIZE 512 -#else /* PPP_USE_PBUF_RAM */ -#define PPP_CTRL_PBUF_TYPE PBUF_POOL -#define PPP_CTRL_PBUF_MAX_SIZE PBUF_POOL_BUFSIZE -#endif /* PPP_USE_PBUF_RAM */ - -/* - * The basic PPP frame. - */ -#define PPP_ADDRESS(p) (((u_char *)(p))[0]) -#define PPP_CONTROL(p) (((u_char *)(p))[1]) -#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3]) - -/* - * Significant octet values. - */ -#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ -#define PPP_UI 0x03 /* Unnumbered Information */ -#define PPP_FLAG 0x7e /* Flag Sequence */ -#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ -#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ - -/* - * Protocol field values. - */ -#define PPP_IP 0x21 /* Internet Protocol */ -#if 0 /* UNUSED */ -#define PPP_AT 0x29 /* AppleTalk Protocol */ -#define PPP_IPX 0x2b /* IPX protocol */ -#endif /* UNUSED */ -#if VJ_SUPPORT -#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ -#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ -#endif /* VJ_SUPPORT */ -#if PPP_IPV6_SUPPORT -#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ -#endif /* PPP_IPV6_SUPPORT */ -#if CCP_SUPPORT -#define PPP_COMP 0xfd /* compressed packet */ -#endif /* CCP_SUPPORT */ -#define PPP_IPCP 0x8021 /* IP Control Protocol */ -#if 0 /* UNUSED */ -#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ -#define PPP_IPXCP 0x802b /* IPX Control Protocol */ -#endif /* UNUSED */ -#if PPP_IPV6_SUPPORT -#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ -#endif /* PPP_IPV6_SUPPORT */ -#if CCP_SUPPORT -#define PPP_CCP 0x80fd /* Compression Control Protocol */ -#endif /* CCP_SUPPORT */ -#if ECP_SUPPORT -#define PPP_ECP 0x8053 /* Encryption Control Protocol */ -#endif /* ECP_SUPPORT */ -#define PPP_LCP 0xc021 /* Link Control Protocol */ -#if PAP_SUPPORT -#define PPP_PAP 0xc023 /* Password Authentication Protocol */ -#endif /* PAP_SUPPORT */ -#if LQR_SUPPORT -#define PPP_LQR 0xc025 /* Link Quality Report protocol */ -#endif /* LQR_SUPPORT */ -#if CHAP_SUPPORT -#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ -#endif /* CHAP_SUPPORT */ -#if CBCP_SUPPORT -#define PPP_CBCP 0xc029 /* Callback Control Protocol */ -#endif /* CBCP_SUPPORT */ -#if EAP_SUPPORT -#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ -#endif /* EAP_SUPPORT */ - -/* - * The following struct gives the addresses of procedures to call - * for a particular lower link level protocol. - */ -struct link_callbacks { - /* Start a connection (e.g. Initiate discovery phase) */ - void (*connect) (ppp_pcb *pcb, void *ctx); -#if PPP_SERVER - /* Listen for an incoming connection (Passive mode) */ - void (*listen) (ppp_pcb *pcb, void *ctx); -#endif /* PPP_SERVER */ - /* End a connection (i.e. initiate disconnect phase) */ - void (*disconnect) (ppp_pcb *pcb, void *ctx); - /* Free lower protocol control block */ - err_t (*free) (ppp_pcb *pcb, void *ctx); - /* Write a pbuf to a ppp link, only used from PPP functions to send PPP packets. */ - err_t (*write)(ppp_pcb *pcb, void *ctx, struct pbuf *p); - /* Send a packet from lwIP core (IPv4 or IPv6) */ - err_t (*netif_output)(ppp_pcb *pcb, void *ctx, struct pbuf *p, u_short protocol); - /* configure the transmit-side characteristics of the PPP interface */ - void (*send_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp); - /* confire the receive-side characteristics of the PPP interface */ - void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm, int pcomp, int accomp); -}; - -/* - * What to do with network protocol (NP) packets. - */ -enum NPmode { - NPMODE_PASS, /* pass the packet through */ - NPMODE_DROP, /* silently drop the packet */ - NPMODE_ERROR, /* return an error */ - NPMODE_QUEUE /* save it up for later. */ -}; - -/* - * Statistics. - */ -#if PPP_STATS_SUPPORT -struct pppstat { - unsigned int ppp_ibytes; /* bytes received */ - unsigned int ppp_ipackets; /* packets received */ - unsigned int ppp_ierrors; /* receive errors */ - unsigned int ppp_obytes; /* bytes sent */ - unsigned int ppp_opackets; /* packets sent */ - unsigned int ppp_oerrors; /* transmit errors */ -}; - -#if VJ_SUPPORT -struct vjstat { - unsigned int vjs_packets; /* outbound packets */ - unsigned int vjs_compressed; /* outbound compressed packets */ - unsigned int vjs_searches; /* searches for connection state */ - unsigned int vjs_misses; /* times couldn't find conn. state */ - unsigned int vjs_uncompressedin; /* inbound uncompressed packets */ - unsigned int vjs_compressedin; /* inbound compressed packets */ - unsigned int vjs_errorin; /* inbound unknown type packets */ - unsigned int vjs_tossed; /* inbound packets tossed because of error */ -}; -#endif /* VJ_SUPPORT */ - -struct ppp_stats { - struct pppstat p; /* basic PPP statistics */ -#if VJ_SUPPORT - struct vjstat vj; /* VJ header compression statistics */ -#endif /* VJ_SUPPORT */ -}; - -#if CCP_SUPPORT -struct compstat { - unsigned int unc_bytes; /* total uncompressed bytes */ - unsigned int unc_packets; /* total uncompressed packets */ - unsigned int comp_bytes; /* compressed bytes */ - unsigned int comp_packets; /* compressed packets */ - unsigned int inc_bytes; /* incompressible bytes */ - unsigned int inc_packets; /* incompressible packets */ - unsigned int ratio; /* recent compression ratio << 8 */ -}; - -struct ppp_comp_stats { - struct compstat c; /* packet compression statistics */ - struct compstat d; /* packet decompression statistics */ -}; -#endif /* CCP_SUPPORT */ - -#endif /* PPP_STATS_SUPPORT */ - -#if PPP_IDLETIMELIMIT -/* - * The following structure records the time in seconds since - * the last NP packet was sent or received. - */ -struct ppp_idle { - time_t xmit_idle; /* time since last NP packet sent */ - time_t recv_idle; /* time since last NP packet received */ -}; -#endif /* PPP_IDLETIMELIMIT */ - -/* values for epdisc.class */ -#define EPD_NULL 0 /* null discriminator, no data */ -#define EPD_LOCAL 1 -#define EPD_IP 2 -#define EPD_MAC 3 -#define EPD_MAGIC 4 -#define EPD_PHONENUM 5 - -/* - * Global variables. - */ -#ifdef HAVE_MULTILINK -extern u8_t multilink; /* enable multilink operation */ -extern u8_t doing_multilink; -extern u8_t multilink_master; -extern u8_t bundle_eof; -extern u8_t bundle_terminating; -#endif - -#ifdef MAXOCTETS -extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ -extern int maxoctets_dir; /* Direction : - 0 - in+out (default) - 1 - in - 2 - out - 3 - max(in,out) */ -extern int maxoctets_timeout; /* Timeout for check of octets limit */ -#define PPP_OCTETS_DIRECTION_SUM 0 -#define PPP_OCTETS_DIRECTION_IN 1 -#define PPP_OCTETS_DIRECTION_OUT 2 -#define PPP_OCTETS_DIRECTION_MAXOVERAL 3 -/* same as previos, but little different on RADIUS side */ -#define PPP_OCTETS_DIRECTION_MAXSESSION 4 -#endif - -/* Data input may be used by CCP and ECP, remove this entry - * from struct protent to save some flash - */ -#define PPP_DATAINPUT 0 - -/* - * The following struct gives the addresses of procedures to call - * for a particular protocol. - */ -struct protent { - u_short protocol; /* PPP protocol number */ - /* Initialization procedure */ - void (*init) (ppp_pcb *pcb); - /* Process a received packet */ - void (*input) (ppp_pcb *pcb, u_char *pkt, int len); - /* Process a received protocol-reject */ - void (*protrej) (ppp_pcb *pcb); - /* Lower layer has come up */ - void (*lowerup) (ppp_pcb *pcb); - /* Lower layer has gone down */ - void (*lowerdown) (ppp_pcb *pcb); - /* Open the protocol */ - void (*open) (ppp_pcb *pcb); - /* Close the protocol */ - void (*close) (ppp_pcb *pcb, const char *reason); -#if PRINTPKT_SUPPORT - /* Print a packet in readable form */ - int (*printpkt) (const u_char *pkt, int len, - void (*printer) (void *, const char *, ...), - void *arg); -#endif /* PRINTPKT_SUPPORT */ -#if PPP_DATAINPUT - /* Process a received data packet */ - void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len); -#endif /* PPP_DATAINPUT */ -#if PRINTPKT_SUPPORT - const char *name; /* Text name of protocol */ - const char *data_name; /* Text name of corresponding data protocol */ -#endif /* PRINTPKT_SUPPORT */ -#if PPP_OPTIONS - option_t *options; /* List of command-line options */ - /* Check requested options, assign defaults */ - void (*check_options) (void); -#endif /* PPP_OPTIONS */ -#if DEMAND_SUPPORT - /* Configure interface for demand-dial */ - int (*demand_conf) (int unit); - /* Say whether to bring up link for this pkt */ - int (*active_pkt) (u_char *pkt, int len); -#endif /* DEMAND_SUPPORT */ -}; - -/* Table of pointers to supported protocols */ -extern const struct protent* const protocols[]; - - -/* Values for auth_pending, auth_done */ -#if PAP_SUPPORT -#define PAP_WITHPEER 0x1 -#define PAP_PEER 0x2 -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT -#define CHAP_WITHPEER 0x4 -#define CHAP_PEER 0x8 -#endif /* CHAP_SUPPORT */ -#if EAP_SUPPORT -#define EAP_WITHPEER 0x10 -#define EAP_PEER 0x20 -#endif /* EAP_SUPPORT */ - -/* Values for auth_done only */ -#if CHAP_SUPPORT -#define CHAP_MD5_WITHPEER 0x40 -#define CHAP_MD5_PEER 0x80 -#if MSCHAP_SUPPORT -#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */ -#define CHAP_MS_WITHPEER 0x100 -#define CHAP_MS_PEER 0x200 -#define CHAP_MS2_WITHPEER 0x400 -#define CHAP_MS2_PEER 0x800 -#endif /* MSCHAP_SUPPORT */ -#endif /* CHAP_SUPPORT */ - -/* Supported CHAP protocols */ -#if CHAP_SUPPORT - -#if MSCHAP_SUPPORT -#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5) -#else /* MSCHAP_SUPPORT */ -#define CHAP_MDTYPE_SUPPORTED (MDTYPE_MD5) -#endif /* MSCHAP_SUPPORT */ - -#else /* CHAP_SUPPORT */ -#define CHAP_MDTYPE_SUPPORTED (MDTYPE_NONE) -#endif /* CHAP_SUPPORT */ - -#if PPP_STATS_SUPPORT -/* - * PPP statistics structure - */ -struct pppd_stats { - unsigned int bytes_in; - unsigned int bytes_out; - unsigned int pkts_in; - unsigned int pkts_out; -}; -#endif /* PPP_STATS_SUPPORT */ - - -/* - * PPP private functions - */ - - -/* - * Functions called from lwIP core. - */ - -/* initialize the PPP subsystem */ -int ppp_init(void); - -/* - * Functions called from PPP link protocols. - */ - -/* Create a new PPP control block */ -ppp_pcb *ppp_new(struct netif *pppif, const struct link_callbacks *callbacks, void *link_ctx_cb, - ppp_link_status_cb_fn link_status_cb, void *ctx_cb); - -/* Initiate LCP open request */ -void ppp_start(ppp_pcb *pcb); - -/* Called when link failed to setup */ -void ppp_link_failed(ppp_pcb *pcb); - -/* Called when link is normally down (i.e. it was asked to end) */ -void ppp_link_end(ppp_pcb *pcb); - -/* function called to process input packet */ -void ppp_input(ppp_pcb *pcb, struct pbuf *pb); - -/* helper function, merge a pbuf chain into one pbuf */ -struct pbuf *ppp_singlebuf(struct pbuf *p); - - -/* - * Functions called by PPP protocols. - */ - -/* function called by all PPP subsystems to send packets */ -err_t ppp_write(ppp_pcb *pcb, struct pbuf *p); - -/* functions called by auth.c link_terminated() */ -void ppp_link_terminated(ppp_pcb *pcb); - -void new_phase(ppp_pcb *pcb, int p); - -int ppp_send_config(ppp_pcb *pcb, int mtu, u32_t accm, int pcomp, int accomp); -int ppp_recv_config(ppp_pcb *pcb, int mru, u32_t accm, int pcomp, int accomp); - -#if PPP_IPV4_SUPPORT -int sifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr, u32_t netmask); -int cifaddr(ppp_pcb *pcb, u32_t our_adr, u32_t his_adr); -#if 0 /* UNUSED - PROXY ARP */ -int sifproxyarp(ppp_pcb *pcb, u32_t his_adr); -int cifproxyarp(ppp_pcb *pcb, u32_t his_adr); -#endif /* UNUSED - PROXY ARP */ -#if LWIP_DNS -int sdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2); -int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2); -#endif /* LWIP_DNS */ -#if VJ_SUPPORT -int sifvjcomp(ppp_pcb *pcb, int vjcomp, int cidcomp, int maxcid); -#endif /* VJ_SUPPORT */ -int sifup(ppp_pcb *pcb); -int sifdown (ppp_pcb *pcb); -u32_t get_mask(u32_t addr); -#endif /* PPP_IPV4_SUPPORT */ - -#if PPP_IPV6_SUPPORT -int sif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64); -int cif6addr(ppp_pcb *pcb, eui64_t our_eui64, eui64_t his_eui64); -int sif6up(ppp_pcb *pcb); -int sif6down (ppp_pcb *pcb); -#endif /* PPP_IPV6_SUPPORT */ - -#if DEMAND_SUPPORT -int sifnpmode(ppp_pcb *pcb, int proto, enum NPmode mode); -#endif /* DEMAND_SUPPORt */ - -void netif_set_mtu(ppp_pcb *pcb, int mtu); -int netif_get_mtu(ppp_pcb *pcb); - -#if CCP_SUPPORT -#if 0 /* unused */ -int ccp_test(ppp_pcb *pcb, u_char *opt_ptr, int opt_len, int for_transmit); -#endif /* unused */ -void ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method); -void ccp_reset_comp(ppp_pcb *pcb); -void ccp_reset_decomp(ppp_pcb *pcb); -#if 0 /* unused */ -int ccp_fatal_error(ppp_pcb *pcb); -#endif /* unused */ -#endif /* CCP_SUPPORT */ - -#if PPP_IDLETIMELIMIT -int get_idle_time(ppp_pcb *pcb, struct ppp_idle *ip); -#endif /* PPP_IDLETIMELIMIT */ - -#if DEMAND_SUPPORT -int get_loop_output(void); -#endif /* DEMAND_SUPPORT */ - -/* Optional protocol names list, to make our messages a little more informative. */ -#if PPP_PROTOCOLNAME -const char * protocol_name(int proto); -#endif /* PPP_PROTOCOLNAME */ - -/* Optional stats support, to get some statistics on the PPP interface */ -#if PPP_STATS_SUPPORT -void print_link_stats(void); /* Print stats, if available */ -void reset_link_stats(int u); /* Reset (init) stats when link goes up */ -void update_link_stats(int u); /* Get stats at link termination */ -#endif /* PPP_STATS_SUPPORT */ - - - -/* - * Inline versions of get/put char/short/long. - * Pointer is advanced; we assume that both arguments - * are lvalues and will already be in registers. - * cp MUST be u_char *. - */ -#define GETCHAR(c, cp) { \ - (c) = *(cp)++; \ -} -#define PUTCHAR(c, cp) { \ - *(cp)++ = (u_char) (c); \ -} -#define GETSHORT(s, cp) { \ - (s) = *(cp)++ << 8; \ - (s) |= *(cp)++; \ -} -#define PUTSHORT(s, cp) { \ - *(cp)++ = (u_char) ((s) >> 8); \ - *(cp)++ = (u_char) (s); \ -} -#define GETLONG(l, cp) { \ - (l) = *(cp)++ << 8; \ - (l) |= *(cp)++; (l) <<= 8; \ - (l) |= *(cp)++; (l) <<= 8; \ - (l) |= *(cp)++; \ -} -#define PUTLONG(l, cp) { \ - *(cp)++ = (u_char) ((l) >> 24); \ - *(cp)++ = (u_char) ((l) >> 16); \ - *(cp)++ = (u_char) ((l) >> 8); \ - *(cp)++ = (u_char) (l); \ -} - -#define INCPTR(n, cp) ((cp) += (n)) -#define DECPTR(n, cp) ((cp) -= (n)) - -/* - * System dependent definitions for user-level 4.3BSD UNIX implementation. - */ -#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0) -#define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0) -#define UNTIMEOUT(f, a) sys_untimeout((f), (a)) - -#define BZERO(s, n) memset(s, 0, n) -#define BCMP(s1, s2, l) memcmp(s1, s2, l) - -#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); } - -/* - * MAKEHEADER - Add Header fields to a packet. - */ -#define MAKEHEADER(p, t) { \ - PUTCHAR(PPP_ALLSTATIONS, p); \ - PUTCHAR(PPP_UI, p); \ - PUTSHORT(t, p); } - -/* Procedures exported from auth.c */ -void link_required(ppp_pcb *pcb); /* we are starting to use the link */ -void link_terminated(ppp_pcb *pcb); /* we are finished with the link */ -void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */ -void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */ -void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */ -void start_networks(ppp_pcb *pcb); /* start all the network control protos */ -void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos */ -#if PPP_AUTH_SUPPORT -#if PPP_SERVER -int auth_check_passwd(ppp_pcb *pcb, char *auser, int userlen, char *apasswd, int passwdlen, const char **msg, int *msglen); - /* check the user name and passwd against configuration */ -void auth_peer_fail(ppp_pcb *pcb, int protocol); - /* peer failed to authenticate itself */ -void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char *name, int namelen); - /* peer successfully authenticated itself */ -#endif /* PPP_SERVER */ -void auth_withpeer_fail(ppp_pcb *pcb, int protocol); - /* we failed to authenticate ourselves */ -void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor); - /* we successfully authenticated ourselves */ -#endif /* PPP_AUTH_SUPPORT */ -void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */ -void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */ -void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */ -#if PPP_AUTH_SUPPORT -int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secret, int *secret_len, int am_server); - /* get "secret" for chap */ -#endif /* PPP_AUTH_SUPPORT */ - -/* Procedures exported from ipcp.c */ -/* int parse_dotted_ip (char *, u32_t *); */ - -/* Procedures exported from demand.c */ -#if DEMAND_SUPPORT -void demand_conf (void); /* config interface(s) for demand-dial */ -void demand_block (void); /* set all NPs to queue up packets */ -void demand_unblock (void); /* set all NPs to pass packets */ -void demand_discard (void); /* set all NPs to discard packets */ -void demand_rexmit (int, u32_t); /* retransmit saved frames for an NP*/ -int loop_chars (unsigned char *, int); /* process chars from loopback */ -int loop_frame (unsigned char *, int); /* should we bring link up? */ -#endif /* DEMAND_SUPPORT */ - -/* Procedures exported from multilink.c */ -#ifdef HAVE_MULTILINK -void mp_check_options (void); /* Check multilink-related options */ -int mp_join_bundle (void); /* join our link to an appropriate bundle */ -void mp_exit_bundle (void); /* have disconnected our link from bundle */ -void mp_bundle_terminated (void); -char *epdisc_to_str (struct epdisc *); /* string from endpoint discrim. */ -int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */ -#else -#define mp_bundle_terminated() /* nothing */ -#define mp_exit_bundle() /* nothing */ -#define doing_multilink 0 -#define multilink_master 0 -#endif - -/* Procedures exported from utils.c. */ -void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */ -int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */ -int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args); /* vsprintf++ */ -size_t ppp_strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */ -size_t ppp_strlcat(char *dest, const char *src, size_t len); /* safe strncpy */ -void ppp_dbglog(const char *fmt, ...); /* log a debug message */ -void ppp_info(const char *fmt, ...); /* log an informational message */ -void ppp_notice(const char *fmt, ...); /* log a notice-level message */ -void ppp_warn(const char *fmt, ...); /* log a warning message */ -void ppp_error(const char *fmt, ...); /* log an error message */ -void ppp_fatal(const char *fmt, ...); /* log an error message and die(1) */ -#if PRINTPKT_SUPPORT -void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len); - /* dump packet to debug log if interesting */ -#endif /* PRINTPKT_SUPPORT */ - - -#endif /* PPP_SUPPORT */ -#endif /* LWIP_HDR_PPP_IMPL_H */ diff --git a/include/netif/ppp/ppp_opts.h b/include/netif/ppp/ppp_opts.h deleted file mode 100644 index 49c25b5..0000000 --- a/include/netif/ppp/ppp_opts.h +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#ifndef LWIP_PPP_OPTS_H -#define LWIP_PPP_OPTS_H - -#include "net/opt.h" - -/** - * PPP_SUPPORT==1: Enable PPP. - */ -#ifndef PPP_SUPPORT -#define PPP_SUPPORT 0 -#endif - -/** - * PPPOE_SUPPORT==1: Enable PPP Over Ethernet - */ -#ifndef PPPOE_SUPPORT -#define PPPOE_SUPPORT 0 -#endif - -/** - * PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP - */ -#ifndef PPPOL2TP_SUPPORT -#define PPPOL2TP_SUPPORT 0 -#endif - -/** - * PPPOL2TP_AUTH_SUPPORT==1: Enable PPP Over L2TP Auth (enable MD5 support) - */ -#ifndef PPPOL2TP_AUTH_SUPPORT -#define PPPOL2TP_AUTH_SUPPORT PPPOL2TP_SUPPORT -#endif - -/** - * PPPOS_SUPPORT==1: Enable PPP Over Serial - */ -#ifndef PPPOS_SUPPORT -#define PPPOS_SUPPORT PPP_SUPPORT -#endif - -/** - * LWIP_PPP_API==1: Enable PPP API (in pppapi.c) - */ -#ifndef LWIP_PPP_API -#define LWIP_PPP_API (PPP_SUPPORT && (NO_SYS == 0)) -#endif - -/** - * MEMP_NUM_PPP_PCB: the number of simultaneously active PPP - * connections (requires the PPP_SUPPORT option) - */ -#ifndef MEMP_NUM_PPP_PCB -#define MEMP_NUM_PPP_PCB 1 -#endif - -#if PPP_SUPPORT - -/** - * MEMP_NUM_PPPOS_INTERFACES: the number of concurrently active PPPoS - * interfaces (only used with PPPOS_SUPPORT==1) - */ -#ifndef MEMP_NUM_PPPOS_INTERFACES -#define MEMP_NUM_PPPOS_INTERFACES MEMP_NUM_PPP_PCB -#endif - -/** - * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE - * interfaces (only used with PPPOE_SUPPORT==1) - */ -#ifndef MEMP_NUM_PPPOE_INTERFACES -#define MEMP_NUM_PPPOE_INTERFACES 1 -#endif - -/** - * MEMP_NUM_PPPOL2TP_INTERFACES: the number of concurrently active PPPoL2TP - * interfaces (only used with PPPOL2TP_SUPPORT==1) - */ -#ifndef MEMP_NUM_PPPOL2TP_INTERFACES -#define MEMP_NUM_PPPOL2TP_INTERFACES 1 -#endif - -/** - * MEMP_NUM_PPP_API_MSG: Number of concurrent PPP API messages (in pppapi.c) - */ -#ifndef MEMP_NUM_PPP_API_MSG -#define MEMP_NUM_PPP_API_MSG 5 -#endif - -/** - * PPP_DEBUG: Enable debugging for PPP. - */ -#ifndef PPP_DEBUG -#define PPP_DEBUG LWIP_DBG_OFF -#endif - -/** - * PPP_INPROC_IRQ_SAFE==1 call pppos_input() using tcpip_callback(). - * - * Please read the "PPPoS input path" chapter in the PPP documentation about this option. - */ -#ifndef PPP_INPROC_IRQ_SAFE -#define PPP_INPROC_IRQ_SAFE 0 -#endif - -/** - * PRINTPKT_SUPPORT==1: Enable PPP print packet support - * - * Mandatory for debugging, it displays exchanged packet content in debug trace. - */ -#ifndef PRINTPKT_SUPPORT -#define PRINTPKT_SUPPORT 0 -#endif - -/** - * PPP_IPV4_SUPPORT==1: Enable PPP IPv4 support - */ -#ifndef PPP_IPV4_SUPPORT -#define PPP_IPV4_SUPPORT (LWIP_IPV4) -#endif - -/** - * PPP_IPV6_SUPPORT==1: Enable PPP IPv6 support - */ -#ifndef PPP_IPV6_SUPPORT -#define PPP_IPV6_SUPPORT (LWIP_IPV6) -#endif - -/** - * PPP_NOTIFY_PHASE==1: Support PPP notify phase support - * - * PPP notify phase support allows you to set a callback which is - * called on change of the internal PPP state machine. - * - * This can be used for example to set a LED pattern depending on the - * current phase of the PPP session. - */ -#ifndef PPP_NOTIFY_PHASE -#define PPP_NOTIFY_PHASE 0 -#endif - -/** - * pbuf_type PPP is using for LCP, PAP, CHAP, EAP, CCP, IPCP and IP6CP packets. - * - * Memory allocated must be single buffered for PPP to works, it requires pbuf - * that are not going to be chained when allocated. This requires setting - * PBUF_POOL_BUFSIZE to at least 512 bytes, which is quite huge for small systems. - * - * Setting PPP_USE_PBUF_RAM to 1 makes PPP use memory from heap where continuous - * buffers are required, allowing you to use a smaller PBUF_POOL_BUFSIZE. - */ -#ifndef PPP_USE_PBUF_RAM -#define PPP_USE_PBUF_RAM 0 -#endif - -/** - * PPP_FCS_TABLE: Keep a 256*2 byte table to speed up FCS calculation for PPPoS - */ -#ifndef PPP_FCS_TABLE -#define PPP_FCS_TABLE 1 -#endif - -/** - * PAP_SUPPORT==1: Support PAP. - */ -#ifndef PAP_SUPPORT -#define PAP_SUPPORT 0 -#endif - -/** - * CHAP_SUPPORT==1: Support CHAP. - */ -#ifndef CHAP_SUPPORT -#define CHAP_SUPPORT 0 -#endif - -/** - * MSCHAP_SUPPORT==1: Support MSCHAP. - */ -#ifndef MSCHAP_SUPPORT -#define MSCHAP_SUPPORT 0 -#endif -#if MSCHAP_SUPPORT -/* MSCHAP requires CHAP support */ -#undef CHAP_SUPPORT -#define CHAP_SUPPORT 1 -#endif /* MSCHAP_SUPPORT */ - -/** - * EAP_SUPPORT==1: Support EAP. - */ -#ifndef EAP_SUPPORT -#define EAP_SUPPORT 0 -#endif - -/** - * CCP_SUPPORT==1: Support CCP. - */ -#ifndef CCP_SUPPORT -#define CCP_SUPPORT 0 -#endif - -/** - * MPPE_SUPPORT==1: Support MPPE. - */ -#ifndef MPPE_SUPPORT -#define MPPE_SUPPORT 0 -#endif -#if MPPE_SUPPORT -/* MPPE requires CCP support */ -#undef CCP_SUPPORT -#define CCP_SUPPORT 1 -/* MPPE requires MSCHAP support */ -#undef MSCHAP_SUPPORT -#define MSCHAP_SUPPORT 1 -/* MSCHAP requires CHAP support */ -#undef CHAP_SUPPORT -#define CHAP_SUPPORT 1 -#endif /* MPPE_SUPPORT */ - -/** - * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef CBCP_SUPPORT -#define CBCP_SUPPORT 0 -#endif - -/** - * ECP_SUPPORT==1: Support ECP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef ECP_SUPPORT -#define ECP_SUPPORT 0 -#endif - -/** - * DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef DEMAND_SUPPORT -#define DEMAND_SUPPORT 0 -#endif - -/** - * LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets. - */ -#ifndef LQR_SUPPORT -#define LQR_SUPPORT 0 -#endif - -/** - * PPP_SERVER==1: Enable PPP server support (waiting for incoming PPP session). - * - * Currently only supported for PPPoS. - */ -#ifndef PPP_SERVER -#define PPP_SERVER 0 -#endif - -#if PPP_SERVER -/* - * PPP_OUR_NAME: Our name for authentication purposes - */ -#ifndef PPP_OUR_NAME -#define PPP_OUR_NAME "lwIP" -#endif -#endif /* PPP_SERVER */ - -/** - * VJ_SUPPORT==1: Support VJ header compression. - */ -#ifndef VJ_SUPPORT -#define VJ_SUPPORT 1 -#endif -/* VJ compression is only supported for TCP over IPv4 over PPPoS. */ -#if !PPPOS_SUPPORT || !PPP_IPV4_SUPPORT || !LWIP_TCP -#undef VJ_SUPPORT -#define VJ_SUPPORT 0 -#endif /* !PPPOS_SUPPORT */ - -/** - * PPP_MD5_RANDM==1: Use MD5 for better randomness. - * Enabled by default if CHAP, EAP, or L2TP AUTH support is enabled. - */ -#ifndef PPP_MD5_RANDM -#define PPP_MD5_RANDM (CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT) -#endif - -/** - * PolarSSL embedded library - * - * - * lwIP contains some files fetched from the latest BSD release of - * the PolarSSL project (PolarSSL 0.10.1-bsd) for ciphers and encryption - * methods we need for lwIP PPP support. - * - * The PolarSSL files were cleaned to contain only the necessary struct - * fields and functions needed for lwIP. - * - * The PolarSSL API was not changed at all, so if you are already using - * PolarSSL you can choose to skip the compilation of the included PolarSSL - * library into lwIP. - * - * If you are not using the embedded copy you must include external - * libraries into your arch/cc.h port file. - * - * Beware of the stack requirements which can be a lot larger if you are not - * using our cleaned PolarSSL library. - */ - -/** - * LWIP_USE_EXTERNAL_POLARSSL: Use external PolarSSL library - */ -#ifndef LWIP_USE_EXTERNAL_POLARSSL -#define LWIP_USE_EXTERNAL_POLARSSL 0 -#endif - -/** - * LWIP_USE_EXTERNAL_MBEDTLS: Use external mbed TLS library - */ -#ifndef LWIP_USE_EXTERNAL_MBEDTLS -#define LWIP_USE_EXTERNAL_MBEDTLS 0 -#endif - -/* - * PPP Timeouts - */ - -/** - * FSM_DEFTIMEOUT: Timeout time in seconds - */ -#ifndef FSM_DEFTIMEOUT -#define FSM_DEFTIMEOUT 6 -#endif - -/** - * FSM_DEFMAXTERMREQS: Maximum Terminate-Request transmissions - */ -#ifndef FSM_DEFMAXTERMREQS -#define FSM_DEFMAXTERMREQS 2 -#endif - -/** - * FSM_DEFMAXCONFREQS: Maximum Configure-Request transmissions - */ -#ifndef FSM_DEFMAXCONFREQS -#define FSM_DEFMAXCONFREQS 10 -#endif - -/** - * FSM_DEFMAXNAKLOOPS: Maximum number of nak loops - */ -#ifndef FSM_DEFMAXNAKLOOPS -#define FSM_DEFMAXNAKLOOPS 5 -#endif - -/** - * UPAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req - */ -#ifndef UPAP_DEFTIMEOUT -#define UPAP_DEFTIMEOUT 6 -#endif - -/** - * UPAP_DEFTRANSMITS: Maximum number of auth-reqs to send - */ -#ifndef UPAP_DEFTRANSMITS -#define UPAP_DEFTRANSMITS 10 -#endif - -#if PPP_SERVER -/** - * UPAP_DEFREQTIME: Time to wait for auth-req from peer - */ -#ifndef UPAP_DEFREQTIME -#define UPAP_DEFREQTIME 30 -#endif -#endif /* PPP_SERVER */ - -/** - * CHAP_DEFTIMEOUT: Timeout (seconds) for retransmitting req - */ -#ifndef CHAP_DEFTIMEOUT -#define CHAP_DEFTIMEOUT 6 -#endif - -/** - * CHAP_DEFTRANSMITS: max # times to send challenge - */ -#ifndef CHAP_DEFTRANSMITS -#define CHAP_DEFTRANSMITS 10 -#endif - -#if PPP_SERVER -/** - * CHAP_DEFRECHALLENGETIME: If this option is > 0, rechallenge the peer every n seconds - */ -#ifndef CHAP_DEFRECHALLENGETIME -#define CHAP_DEFRECHALLENGETIME 0 -#endif -#endif /* PPP_SERVER */ - -/** - * EAP_DEFREQTIME: Time to wait for peer request - */ -#ifndef EAP_DEFREQTIME -#define EAP_DEFREQTIME 6 -#endif - -/** - * EAP_DEFALLOWREQ: max # times to accept requests - */ -#ifndef EAP_DEFALLOWREQ -#define EAP_DEFALLOWREQ 10 -#endif - -#if PPP_SERVER -/** - * EAP_DEFTIMEOUT: Timeout (seconds) for rexmit - */ -#ifndef EAP_DEFTIMEOUT -#define EAP_DEFTIMEOUT 6 -#endif - -/** - * EAP_DEFTRANSMITS: max # times to transmit - */ -#ifndef EAP_DEFTRANSMITS -#define EAP_DEFTRANSMITS 10 -#endif -#endif /* PPP_SERVER */ - -/** - * LCP_DEFLOOPBACKFAIL: Default number of times we receive our magic number from the peer - * before deciding the link is looped-back. - */ -#ifndef LCP_DEFLOOPBACKFAIL -#define LCP_DEFLOOPBACKFAIL 10 -#endif - -/** - * LCP_ECHOINTERVAL: Interval in seconds between keepalive echo requests, 0 to disable. - */ -#ifndef LCP_ECHOINTERVAL -#define LCP_ECHOINTERVAL 0 -#endif - -/** - * LCP_MAXECHOFAILS: Number of unanswered echo requests before failure. - */ -#ifndef LCP_MAXECHOFAILS -#define LCP_MAXECHOFAILS 3 -#endif - -/** - * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char. - */ -#ifndef PPP_MAXIDLEFLAG -#define PPP_MAXIDLEFLAG 100 -#endif - -/** - * PPP Packet sizes - */ - -/** - * PPP_MRU: Default MRU - */ -#ifndef PPP_MRU -#define PPP_MRU 1500 -#endif - -/** - * PPP_DEFMRU: Default MRU to try - */ -#ifndef PPP_DEFMRU -#define PPP_DEFMRU 1500 -#endif - -/** - * PPP_MAXMRU: Normally limit MRU to this (pppd default = 16384) - */ -#ifndef PPP_MAXMRU -#define PPP_MAXMRU 1500 -#endif - -/** - * PPP_MINMRU: No MRUs below this - */ -#ifndef PPP_MINMRU -#define PPP_MINMRU 128 -#endif - -/** - * PPPOL2TP_DEFMRU: Default MTU and MRU for L2TP - * Default = 1500 - PPPoE(6) - PPP Protocol(2) - IPv4 header(20) - UDP Header(8) - * - L2TP Header(6) - HDLC Header(2) - PPP Protocol(2) - MPPE Header(2) - PPP Protocol(2) - */ -#if PPPOL2TP_SUPPORT -#ifndef PPPOL2TP_DEFMRU -#define PPPOL2TP_DEFMRU 1450 -#endif -#endif /* PPPOL2TP_SUPPORT */ - -/** - * MAXNAMELEN: max length of hostname or name for auth - */ -#ifndef MAXNAMELEN -#define MAXNAMELEN 256 -#endif - -/** - * MAXSECRETLEN: max length of password or secret - */ -#ifndef MAXSECRETLEN -#define MAXSECRETLEN 256 -#endif - -/* ------------------------------------------------------------------------- */ - -/* - * Build triggers for embedded PolarSSL - */ -#if !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS - -/* CHAP, EAP, L2TP AUTH and MD5 Random require MD5 support */ -#if CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM -#define LWIP_INCLUDED_POLARSSL_MD5 1 -#endif /* CHAP_SUPPORT || EAP_SUPPORT || PPPOL2TP_AUTH_SUPPORT || PPP_MD5_RANDM */ - -#if MSCHAP_SUPPORT - -/* MSCHAP require MD4 support */ -#define LWIP_INCLUDED_POLARSSL_MD4 1 -/* MSCHAP require SHA1 support */ -#define LWIP_INCLUDED_POLARSSL_SHA1 1 -/* MSCHAP require DES support */ -#define LWIP_INCLUDED_POLARSSL_DES 1 - -/* MS-CHAP support is required for MPPE */ -#if MPPE_SUPPORT -/* MPPE require ARC4 support */ -#define LWIP_INCLUDED_POLARSSL_ARC4 1 -#endif /* MPPE_SUPPORT */ - -#endif /* MSCHAP_SUPPORT */ - -#endif /* !LWIP_USE_EXTERNAL_POLARSSL && !LWIP_USE_EXTERNAL_MBEDTLS */ - -/* Default value if unset */ -#ifndef LWIP_INCLUDED_POLARSSL_MD4 -#define LWIP_INCLUDED_POLARSSL_MD4 0 -#endif /* LWIP_INCLUDED_POLARSSL_MD4 */ -#ifndef LWIP_INCLUDED_POLARSSL_MD5 -#define LWIP_INCLUDED_POLARSSL_MD5 0 -#endif /* LWIP_INCLUDED_POLARSSL_MD5 */ -#ifndef LWIP_INCLUDED_POLARSSL_SHA1 -#define LWIP_INCLUDED_POLARSSL_SHA1 0 -#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ -#ifndef LWIP_INCLUDED_POLARSSL_DES -#define LWIP_INCLUDED_POLARSSL_DES 0 -#endif /* LWIP_INCLUDED_POLARSSL_DES */ -#ifndef LWIP_INCLUDED_POLARSSL_ARC4 -#define LWIP_INCLUDED_POLARSSL_ARC4 0 -#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ - -#endif /* PPP_SUPPORT */ - -#endif /* LWIP_PPP_OPTS_H */ diff --git a/include/netif/ppp/pppapi.h b/include/netif/ppp/pppapi.h deleted file mode 100644 index 8070491..0000000 --- a/include/netif/ppp/pppapi.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#ifndef LWIP_PPPAPI_H -#define LWIP_PPPAPI_H - -#include "netif/ppp/ppp_opts.h" - -#if LWIP_PPP_API /* don't build if not configured for use in lwipopts.h */ - -#include "net/sys.h" -#include "net/netif.h" -#include "net/priv/tcpip_priv.h" -#include "netif/ppp/ppp.h" -#if PPPOS_SUPPORT -#include "netif/ppp/pppos.h" -#endif /* PPPOS_SUPPORT */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct pppapi_msg_msg { - ppp_pcb *ppp; - union { -#if PPP_NOTIFY_PHASE - struct { - ppp_notify_phase_cb_fn notify_phase_cb; - } setnotifyphasecb; -#endif /* PPP_NOTIFY_PHASE */ -#if PPPOS_SUPPORT - struct { - struct netif *pppif; - pppos_output_cb_fn output_cb; - ppp_link_status_cb_fn link_status_cb; - void *ctx_cb; - } serialcreate; -#endif /* PPPOS_SUPPORT */ -#if PPPOE_SUPPORT - struct { - struct netif *pppif; - struct netif *ethif; - const char *service_name; - const char *concentrator_name; - ppp_link_status_cb_fn link_status_cb; - void *ctx_cb; - } ethernetcreate; -#endif /* PPPOE_SUPPORT */ -#if PPPOL2TP_SUPPORT - struct { - struct netif *pppif; - struct netif *netif; - API_MSG_M_DEF_C(ip_addr_t, ipaddr); - u16_t port; -#if PPPOL2TP_AUTH_SUPPORT - const u8_t *secret; - u8_t secret_len; -#endif /* PPPOL2TP_AUTH_SUPPORT */ - ppp_link_status_cb_fn link_status_cb; - void *ctx_cb; - } l2tpcreate; -#endif /* PPPOL2TP_SUPPORT */ - struct { - u16_t holdoff; - } connect; - struct { - u8_t nocarrier; - } close; - struct { - u8_t cmd; - void *arg; - } ioctl; - } msg; -}; - -struct pppapi_msg { - struct tcpip_api_call_data call; - struct pppapi_msg_msg msg; -}; - -/* API for application */ -err_t pppapi_set_default(ppp_pcb *pcb); -#if PPP_NOTIFY_PHASE -err_t pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb); -#endif /* PPP_NOTIFY_PHASE */ -#if PPPOS_SUPPORT -ppp_pcb *pppapi_pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, ppp_link_status_cb_fn link_status_cb, void *ctx_cb); -#endif /* PPPOS_SUPPORT */ -#if PPPOE_SUPPORT -ppp_pcb *pppapi_pppoe_create(struct netif *pppif, struct netif *ethif, const char *service_name, - const char *concentrator_name, ppp_link_status_cb_fn link_status_cb, - void *ctx_cb); -#endif /* PPPOE_SUPPORT */ -#if PPPOL2TP_SUPPORT -ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port, - const u8_t *secret, u8_t secret_len, - ppp_link_status_cb_fn link_status_cb, void *ctx_cb); -#endif /* PPPOL2TP_SUPPORT */ -err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff); -#if PPP_SERVER -err_t pppapi_listen(ppp_pcb *pcb); -#endif /* PPP_SERVER */ -err_t pppapi_close(ppp_pcb *pcb, u8_t nocarrier); -err_t pppapi_free(ppp_pcb *pcb); -err_t pppapi_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_PPP_API */ - -#endif /* LWIP_PPPAPI_H */ diff --git a/include/netif/ppp/pppcrypt.h b/include/netif/ppp/pppcrypt.h deleted file mode 100644 index 400a577..0000000 --- a/include/netif/ppp/pppcrypt.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * pppcrypt.c - PPP/DES linkage for MS-CHAP and EAP SRP-SHA1 - * - * Extracted from chap_ms.c by James Carlson. - * - * Copyright (c) 1995 Eric Rosenquist. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name(s) of the authors of this software must not be used to - * endorse or promote products derived from this software without - * prior written permission. - * - * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY - * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -/* This header file is included in all PPP modules needing hashes and/or ciphers */ - -#ifndef PPPCRYPT_H -#define PPPCRYPT_H - -/* - * If included PolarSSL copy is not used, user is expected to include - * external libraries in arch/cc.h (which is included by lwip/arch.h). - */ -#include "net/arch.h" - -/* - * Map hashes and ciphers functions to PolarSSL - */ -#if !LWIP_USE_EXTERNAL_MBEDTLS - -#include "netif/ppp/polarssl/md4.h" -#define lwip_md4_context md4_context -#define lwip_md4_init(context) -#define lwip_md4_starts md4_starts -#define lwip_md4_update md4_update -#define lwip_md4_finish md4_finish -#define lwip_md4_free(context) - -#include "netif/ppp/polarssl/md5.h" -#define lwip_md5_context md5_context -#define lwip_md5_init(context) -#define lwip_md5_starts md5_starts -#define lwip_md5_update md5_update -#define lwip_md5_finish md5_finish -#define lwip_md5_free(context) - -#include "netif/ppp/polarssl/sha1.h" -#define lwip_sha1_context sha1_context -#define lwip_sha1_init(context) -#define lwip_sha1_starts sha1_starts -#define lwip_sha1_update sha1_update -#define lwip_sha1_finish sha1_finish -#define lwip_sha1_free(context) - -#include "netif/ppp/polarssl/des.h" -#define lwip_des_context des_context -#define lwip_des_init(context) -#define lwip_des_setkey_enc des_setkey_enc -#define lwip_des_crypt_ecb des_crypt_ecb -#define lwip_des_free(context) - -#include "netif/ppp/polarssl/arc4.h" -#define lwip_arc4_context arc4_context -#define lwip_arc4_init(context) -#define lwip_arc4_setup arc4_setup -#define lwip_arc4_crypt arc4_crypt -#define lwip_arc4_free(context) - -#endif /* !LWIP_USE_EXTERNAL_MBEDTLS */ - -/* - * Map hashes and ciphers functions to mbed TLS - */ -#if LWIP_USE_EXTERNAL_MBEDTLS - -#define lwip_md4_context mbedtls_md4_context -#define lwip_md4_init mbedtls_md4_init -#define lwip_md4_starts mbedtls_md4_starts -#define lwip_md4_update mbedtls_md4_update -#define lwip_md4_finish mbedtls_md4_finish -#define lwip_md4_free mbedtls_md4_free - -#define lwip_md5_context mbedtls_md5_context -#define lwip_md5_init mbedtls_md5_init -#define lwip_md5_starts mbedtls_md5_starts -#define lwip_md5_update mbedtls_md5_update -#define lwip_md5_finish mbedtls_md5_finish -#define lwip_md5_free mbedtls_md5_free - -#define lwip_sha1_context mbedtls_sha1_context -#define lwip_sha1_init mbedtls_sha1_init -#define lwip_sha1_starts mbedtls_sha1_starts -#define lwip_sha1_update mbedtls_sha1_update -#define lwip_sha1_finish mbedtls_sha1_finish -#define lwip_sha1_free mbedtls_sha1_free - -#define lwip_des_context mbedtls_des_context -#define lwip_des_init mbedtls_des_init -#define lwip_des_setkey_enc mbedtls_des_setkey_enc -#define lwip_des_crypt_ecb mbedtls_des_crypt_ecb -#define lwip_des_free mbedtls_des_free - -#define lwip_arc4_context mbedtls_arc4_context -#define lwip_arc4_init mbedtls_arc4_init -#define lwip_arc4_setup mbedtls_arc4_setup -#define lwip_arc4_crypt(context, buffer, length) mbedtls_arc4_crypt(context, length, buffer, buffer) -#define lwip_arc4_free mbedtls_arc4_free - -#endif /* LWIP_USE_EXTERNAL_MBEDTLS */ - -void pppcrypt_56_to_64_bit_key(u_char *key, u_char *des_key); - -#endif /* PPPCRYPT_H */ - -#endif /* PPP_SUPPORT */ diff --git a/include/netif/ppp/pppdebug.h b/include/netif/ppp/pppdebug.h deleted file mode 100644 index 7ead045..0000000 --- a/include/netif/ppp/pppdebug.h +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** -* pppdebug.h - System debugging utilities. -* -* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. -* portions Copyright (c) 1998 Global Election Systems Inc. -* portions Copyright (c) 2001 by Cognizant Pty Ltd. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY (please don't use tabs!) -* -* 03-01-01 Marc Boucher -* Ported to lwIP. -* 98-07-29 Guy Lancaster , Global Election Systems Inc. -* Original. -* -***************************************************************************** -*/ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef PPPDEBUG_H -#define PPPDEBUG_H - -/* Trace levels. */ -#define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) -#define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) -#define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) -#define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) -#define LOG_INFO (PPP_DEBUG) -#define LOG_DETAIL (PPP_DEBUG) -#define LOG_DEBUG (PPP_DEBUG) - -#if PPP_DEBUG - -#define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) -#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) - -#else /* PPP_DEBUG */ - -#define MAINDEBUG(a) -#define SYSDEBUG(a) -#define FSMDEBUG(a) -#define LCPDEBUG(a) -#define IPCPDEBUG(a) -#define IPV6CPDEBUG(a) -#define UPAPDEBUG(a) -#define CHAPDEBUG(a) -#define PPPDEBUG(a, b) - -#endif /* PPP_DEBUG */ - -#endif /* PPPDEBUG_H */ - -#endif /* PPP_SUPPORT */ diff --git a/include/netif/ppp/pppoe.h b/include/netif/ppp/pppoe.h deleted file mode 100644 index 9f8f289..0000000 --- a/include/netif/ppp/pppoe.h +++ /dev/null @@ -1,179 +0,0 @@ -/***************************************************************************** -* pppoe.h - PPP Over Ethernet implementation for lwIP. -* -* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 06-01-01 Marc Boucher -* Ported to lwIP. -*****************************************************************************/ - - - -/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef PPP_OE_H -#define PPP_OE_H - -#include "ppp.h" -#include "lwip/etharp.h" - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pppoehdr { - PACK_STRUCT_FLD_8(u8_t vertype); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t session); - PACK_STRUCT_FIELD(u16_t plen); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pppoetag { - PACK_STRUCT_FIELD(u16_t tag); - PACK_STRUCT_FIELD(u16_t len); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - - -#define PPPOE_STATE_INITIAL 0 -#define PPPOE_STATE_PADI_SENT 1 -#define PPPOE_STATE_PADR_SENT 2 -#define PPPOE_STATE_SESSION 3 -/* passive */ -#define PPPOE_STATE_PADO_SENT 1 - -#define PPPOE_HEADERLEN sizeof(struct pppoehdr) -#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ - -#define PPPOE_TAG_EOL 0x0000 /* end of list */ -#define PPPOE_TAG_SNAME 0x0101 /* service name */ -#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ -#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ -#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ -#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ -#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ -#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ -#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ -#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ - -#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ -#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ -#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ -#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ -#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ - -#ifndef PPPOE_MAX_AC_COOKIE_LEN -#define PPPOE_MAX_AC_COOKIE_LEN 64 -#endif - -struct pppoe_softc { - struct pppoe_softc *next; - struct netif *sc_ethif; /* ethernet interface we are using */ - ppp_pcb *pcb; /* PPP PCB */ - - struct eth_addr sc_dest; /* hardware address of concentrator */ - u16_t sc_session; /* PPPoE session id */ - u8_t sc_state; /* discovery phase or session connected */ - -#ifdef PPPOE_TODO - u8_t *sc_service_name; /* if != NULL: requested name of service */ - u8_t *sc_concentrator_name; /* if != NULL: requested concentrator id */ -#endif /* PPPOE_TODO */ - u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */ - u8_t sc_ac_cookie_len; /* length of cookie data */ -#ifdef PPPOE_SERVER - u8_t *sc_hunique; /* content of host unique we must echo back */ - u8_t sc_hunique_len; /* length of host unique */ -#endif - u8_t sc_padi_retried; /* number of PADI retries already done */ - u8_t sc_padr_retried; /* number of PADR retries already done */ -}; - - -#define pppoe_init() /* compatibility define, no initialization needed */ - -ppp_pcb *pppoe_create(struct netif *pppif, - struct netif *ethif, - const char *service_name, const char *concentrator_name, - ppp_link_status_cb_fn link_status_cb, void *ctx_cb); - -/* - * Functions called from lwIP - * DO NOT CALL FROM lwIP USER APPLICATION. - */ -void pppoe_disc_input(struct netif *netif, struct pbuf *p); -void pppoe_data_input(struct netif *netif, struct pbuf *p); - -#endif /* PPP_OE_H */ - -#endif /* PPP_SUPPORT && PPPOE_SUPPORT */ diff --git a/include/netif/ppp/pppol2tp.h b/include/netif/ppp/pppol2tp.h deleted file mode 100644 index f03950e..0000000 --- a/include/netif/ppp/pppol2tp.h +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @file - * Network Point to Point Protocol over Layer 2 Tunneling Protocol header file. - * - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PPPOL2TP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef PPPOL2TP_H -#define PPPOL2TP_H - -#include "ppp.h" - -/* Timeout */ -#define PPPOL2TP_CONTROL_TIMEOUT (5*1000) /* base for quick timeout calculation */ -#define PPPOL2TP_SLOW_RETRY (60*1000) /* persistent retry interval */ - -#define PPPOL2TP_MAXSCCRQ 4 /* retry SCCRQ four times (quickly) */ -#define PPPOL2TP_MAXICRQ 4 /* retry IRCQ four times */ -#define PPPOL2TP_MAXICCN 4 /* retry ICCN four times */ - -/* L2TP header flags */ -#define PPPOL2TP_HEADERFLAG_CONTROL 0x8000 -#define PPPOL2TP_HEADERFLAG_LENGTH 0x4000 -#define PPPOL2TP_HEADERFLAG_SEQUENCE 0x0800 -#define PPPOL2TP_HEADERFLAG_OFFSET 0x0200 -#define PPPOL2TP_HEADERFLAG_PRIORITY 0x0100 -#define PPPOL2TP_HEADERFLAG_VERSION 0x0002 - -/* Mandatory bits for control: Control, Length, Sequence, Version 2 */ -#define PPPOL2TP_HEADERFLAG_CONTROL_MANDATORY (PPPOL2TP_HEADERFLAG_CONTROL|PPPOL2TP_HEADERFLAG_LENGTH|PPPOL2TP_HEADERFLAG_SEQUENCE|PPPOL2TP_HEADERFLAG_VERSION) -/* Forbidden bits for control: Offset, Priority */ -#define PPPOL2TP_HEADERFLAG_CONTROL_FORBIDDEN (PPPOL2TP_HEADERFLAG_OFFSET|PPPOL2TP_HEADERFLAG_PRIORITY) - -/* Mandatory bits for data: Version 2 */ -#define PPPOL2TP_HEADERFLAG_DATA_MANDATORY (PPPOL2TP_HEADERFLAG_VERSION) - -/* AVP (Attribute Value Pair) header */ -#define PPPOL2TP_AVPHEADERFLAG_MANDATORY 0x8000 -#define PPPOL2TP_AVPHEADERFLAG_HIDDEN 0x4000 -#define PPPOL2TP_AVPHEADERFLAG_LENGTHMASK 0x03ff - -/* -- AVP - Message type */ -#define PPPOL2TP_AVPTYPE_MESSAGE 0 /* Message type */ - -/* Control Connection Management */ -#define PPPOL2TP_MESSAGETYPE_SCCRQ 1 /* Start Control Connection Request */ -#define PPPOL2TP_MESSAGETYPE_SCCRP 2 /* Start Control Connection Reply */ -#define PPPOL2TP_MESSAGETYPE_SCCCN 3 /* Start Control Connection Connected */ -#define PPPOL2TP_MESSAGETYPE_STOPCCN 4 /* Stop Control Connection Notification */ -#define PPPOL2TP_MESSAGETYPE_HELLO 6 /* Hello */ -/* Call Management */ -#define PPPOL2TP_MESSAGETYPE_OCRQ 7 /* Outgoing Call Request */ -#define PPPOL2TP_MESSAGETYPE_OCRP 8 /* Outgoing Call Reply */ -#define PPPOL2TP_MESSAGETYPE_OCCN 9 /* Outgoing Call Connected */ -#define PPPOL2TP_MESSAGETYPE_ICRQ 10 /* Incoming Call Request */ -#define PPPOL2TP_MESSAGETYPE_ICRP 11 /* Incoming Call Reply */ -#define PPPOL2TP_MESSAGETYPE_ICCN 12 /* Incoming Call Connected */ -#define PPPOL2TP_MESSAGETYPE_CDN 14 /* Call Disconnect Notify */ -/* Error reporting */ -#define PPPOL2TP_MESSAGETYPE_WEN 15 /* WAN Error Notify */ -/* PPP Session Control */ -#define PPPOL2TP_MESSAGETYPE_SLI 16 /* Set Link Info */ - -/* -- AVP - Result code */ -#define PPPOL2TP_AVPTYPE_RESULTCODE 1 /* Result code */ -#define PPPOL2TP_RESULTCODE 1 /* General request to clear control connection */ - -/* -- AVP - Protocol version (!= L2TP Header version) */ -#define PPPOL2TP_AVPTYPE_VERSION 2 -#define PPPOL2TP_VERSION 0x0100 /* L2TP Protocol version 1, revision 0 */ - -/* -- AVP - Framing capabilities */ -#define PPPOL2TP_AVPTYPE_FRAMINGCAPABILITIES 3 /* Bearer capabilities */ -#define PPPOL2TP_FRAMINGCAPABILITIES 0x00000003 /* Async + Sync framing */ - -/* -- AVP - Bearer capabilities */ -#define PPPOL2TP_AVPTYPE_BEARERCAPABILITIES 4 /* Bearer capabilities */ -#define PPPOL2TP_BEARERCAPABILITIES 0x00000003 /* Analog + Digital Access */ - -/* -- AVP - Tie breaker */ -#define PPPOL2TP_AVPTYPE_TIEBREAKER 5 - -/* -- AVP - Host name */ -#define PPPOL2TP_AVPTYPE_HOSTNAME 7 /* Host name */ -#define PPPOL2TP_HOSTNAME "lwIP" /* FIXME: make it configurable */ - -/* -- AVP - Vendor name */ -#define PPPOL2TP_AVPTYPE_VENDORNAME 8 /* Vendor name */ -#define PPPOL2TP_VENDORNAME "lwIP" /* FIXME: make it configurable */ - -/* -- AVP - Assign tunnel ID */ -#define PPPOL2TP_AVPTYPE_TUNNELID 9 /* Assign Tunnel ID */ - -/* -- AVP - Receive window size */ -#define PPPOL2TP_AVPTYPE_RECEIVEWINDOWSIZE 10 /* Receive window size */ -#define PPPOL2TP_RECEIVEWINDOWSIZE 8 /* FIXME: make it configurable */ - -/* -- AVP - Challenge */ -#define PPPOL2TP_AVPTYPE_CHALLENGE 11 /* Challenge */ - -/* -- AVP - Cause code */ -#define PPPOL2TP_AVPTYPE_CAUSECODE 12 /* Cause code*/ - -/* -- AVP - Challenge response */ -#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE 13 /* Challenge response */ -#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE 16 - -/* -- AVP - Assign session ID */ -#define PPPOL2TP_AVPTYPE_SESSIONID 14 /* Assign Session ID */ - -/* -- AVP - Call serial number */ -#define PPPOL2TP_AVPTYPE_CALLSERIALNUMBER 15 /* Call Serial Number */ - -/* -- AVP - Framing type */ -#define PPPOL2TP_AVPTYPE_FRAMINGTYPE 19 /* Framing Type */ -#define PPPOL2TP_FRAMINGTYPE 0x00000001 /* Sync framing */ - -/* -- AVP - TX Connect Speed */ -#define PPPOL2TP_AVPTYPE_TXCONNECTSPEED 24 /* TX Connect Speed */ -#define PPPOL2TP_TXCONNECTSPEED 100000000 /* Connect speed: 100 Mbits/s */ - -/* L2TP Session state */ -#define PPPOL2TP_STATE_INITIAL 0 -#define PPPOL2TP_STATE_SCCRQ_SENT 1 -#define PPPOL2TP_STATE_ICRQ_SENT 2 -#define PPPOL2TP_STATE_ICCN_SENT 3 -#define PPPOL2TP_STATE_DATA 4 - -#define PPPOL2TP_OUTPUT_DATA_HEADER_LEN 6 /* Our data header len */ - -/* - * PPPoL2TP interface control block. - */ -typedef struct pppol2tp_pcb_s pppol2tp_pcb; -struct pppol2tp_pcb_s { - ppp_pcb *ppp; /* PPP PCB */ - u8_t phase; /* L2TP phase */ - struct udp_pcb *udp; /* UDP L2TP Socket */ - struct netif *netif; /* Output interface, used as a default route */ - ip_addr_t remote_ip; /* LNS IP Address */ - u16_t remote_port; /* LNS port */ -#if PPPOL2TP_AUTH_SUPPORT - const u8_t *secret; /* Secret string */ - u8_t secret_len; /* Secret string length */ - u8_t secret_rv[16]; /* Random vector */ - u8_t challenge_hash[16]; /* Challenge response */ - u8_t send_challenge; /* Boolean whether the next sent packet should contains a challenge response */ -#endif /* PPPOL2TP_AUTH_SUPPORT */ - - u16_t tunnel_port; /* Tunnel port */ - u16_t our_ns; /* NS to peer */ - u16_t peer_nr; /* NR from peer */ - u16_t peer_ns; /* NS from peer */ - u16_t source_tunnel_id; /* Tunnel ID assigned by peer */ - u16_t remote_tunnel_id; /* Tunnel ID assigned to peer */ - u16_t source_session_id; /* Session ID assigned by peer */ - u16_t remote_session_id; /* Session ID assigned to peer */ - - u8_t sccrq_retried; /* number of SCCRQ retries already done */ - u8_t icrq_retried; /* number of ICRQ retries already done */ - u8_t iccn_retried; /* number of ICCN retries already done */ -}; - - -/* Create a new L2TP session. */ -ppp_pcb *pppol2tp_create(struct netif *pppif, - struct netif *netif, const ip_addr_t *ipaddr, u16_t port, - const u8_t *secret, u8_t secret_len, - ppp_link_status_cb_fn link_status_cb, void *ctx_cb); - -#endif /* PPPOL2TP_H */ -#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */ diff --git a/include/netif/ppp/pppos.h b/include/netif/ppp/pppos.h deleted file mode 100644 index 58adedb..0000000 --- a/include/netif/ppp/pppos.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file - * Network Point to Point Protocol over Serial header file. - * - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef PPPOS_H -#define PPPOS_H - -#include "net/sys.h" - -#include "ppp.h" -#include "vj.h" - -/* PPP packet parser states. Current state indicates operation yet to be - * completed. */ -enum { - PDIDLE = 0, /* Idle state - waiting. */ - PDSTART, /* Process start flag. */ - PDADDRESS, /* Process address field. */ - PDCONTROL, /* Process control field. */ - PDPROTOCOL1, /* Process protocol field 1. */ - PDPROTOCOL2, /* Process protocol field 2. */ - PDDATA /* Process data byte. */ -}; - -/* PPPoS serial output callback function prototype */ -typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx); - -/* - * Extended asyncmap - allows any character to be escaped. - */ -typedef u8_t ext_accm[32]; - -/* - * PPPoS interface control block. - */ -typedef struct pppos_pcb_s pppos_pcb; -struct pppos_pcb_s { - /* -- below are data that will NOT be cleared between two sessions */ - ppp_pcb *ppp; /* PPP PCB */ - pppos_output_cb_fn output_cb; /* PPP serial output callback */ - - /* -- below are data that will be cleared between two sessions - * - * last_xmit must be the first member of cleared members, because it is - * used to know which part must not be cleared. - */ - u32_t last_xmit; /* Time of last transmission. */ - ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ - - /* flags */ - unsigned int open :1; /* Set if PPPoS is open */ - unsigned int pcomp :1; /* Does peer accept protocol compression? */ - unsigned int accomp :1; /* Does peer accept addr/ctl compression? */ - - /* PPPoS rx */ - ext_accm in_accm; /* Async-Ctl-Char-Map for input. */ - struct pbuf *in_head, *in_tail; /* The input packet. */ - u16_t in_protocol; /* The input protocol code. */ - u16_t in_fcs; /* Input Frame Check Sequence value. */ - u8_t in_state; /* The input process state. */ - u8_t in_escaped; /* Escape next character. */ -}; - -/* Create a new PPPoS session. */ -ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, - ppp_link_status_cb_fn link_status_cb, void *ctx_cb); - -#if !NO_SYS && !PPP_INPROC_IRQ_SAFE -/* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */ -err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l); -#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ - -/* PPP over Serial: this is the input function to be called for received data. */ -void pppos_input(ppp_pcb *ppp, u8_t* data, int len); - - -/* - * Functions called from lwIP - * DO NOT CALL FROM lwIP USER APPLICATION. - */ -#if !NO_SYS && !PPP_INPROC_IRQ_SAFE -err_t pppos_input_sys(struct pbuf *p, struct netif *inp); -#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ - -#endif /* PPPOS_H */ -#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */ diff --git a/include/netif/ppp/upap.h b/include/netif/ppp/upap.h deleted file mode 100644 index 7da792e..0000000 --- a/include/netif/ppp/upap.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * upap.h - User/Password Authentication Protocol definitions. - * - * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The name "Carnegie Mellon University" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For permission or any legal - * details, please contact - * Office of Technology Transfer - * Carnegie Mellon University - * 5000 Forbes Avenue - * Pittsburgh, PA 15213-3890 - * (412) 268-4387, fax: (412) 268-7395 - * tech-transfer@andrew.cmu.edu - * - * 4. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by Computing Services - * at Carnegie Mellon University (http://www.cmu.edu/computing/)." - * - * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * $Id: upap.h,v 1.8 2002/12/04 23:03:33 paulus Exp $ - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef UPAP_H -#define UPAP_H - -#include "ppp.h" - -/* - * Packet header = Code, id, length. - */ -#define UPAP_HEADERLEN 4 - - -/* - * UPAP codes. - */ -#define UPAP_AUTHREQ 1 /* Authenticate-Request */ -#define UPAP_AUTHACK 2 /* Authenticate-Ack */ -#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ - - -/* - * Client states. - */ -#define UPAPCS_INITIAL 0 /* Connection down */ -#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ -#define UPAPCS_OPEN 4 /* We've received an Ack */ -#define UPAPCS_BADAUTH 5 /* We've received a Nak */ - -/* - * Server states. - */ -#define UPAPSS_INITIAL 0 /* Connection down */ -#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ -#define UPAPSS_OPEN 4 /* We've sent an Ack */ -#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ - - -/* - * Timeouts. - */ -#if 0 /* moved to ppp_opts.h */ -#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ -#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ -#endif /* moved to ppp_opts.h */ - -/* - * Each interface is described by upap structure. - */ -#if PAP_SUPPORT -typedef struct upap_state { - const char *us_user; /* User */ - u8_t us_userlen; /* User length */ - const char *us_passwd; /* Password */ - u8_t us_passwdlen; /* Password length */ - u8_t us_clientstate; /* Client state */ -#if PPP_SERVER - u8_t us_serverstate; /* Server state */ -#endif /* PPP_SERVER */ - u8_t us_id; /* Current id */ - u8_t us_transmits; /* Number of auth-reqs sent */ -} upap_state; -#endif /* PAP_SUPPORT */ - - -void upap_authwithpeer(ppp_pcb *pcb, const char *user, const char *password); -#if PPP_SERVER -void upap_authpeer(ppp_pcb *pcb); -#endif /* PPP_SERVER */ - -extern const struct protent pap_protent; - -#endif /* UPAP_H */ -#endif /* PPP_SUPPORT && PAP_SUPPORT */ diff --git a/include/netif/ppp/vj.h b/include/netif/ppp/vj.h deleted file mode 100644 index 43071ec..0000000 --- a/include/netif/ppp/vj.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Definitions for tcp compression routines. - * - * $Id: vj.h,v 1.7 2010/02/22 17:52:09 goldsimon Exp $ - * - * Copyright (c) 1989 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: - * - Initial distribution. - */ - -#include "netif/ppp/ppp_opts.h" -#if PPP_SUPPORT && VJ_SUPPORT /* don't build if not configured for use in lwipopts.h */ - -#ifndef VJ_H -#define VJ_H - -#include "net/ip.h" -#include "net/priv/tcp_priv.h" - -#define MAX_SLOTS 16 /* must be > 2 and < 256 */ -#define MAX_HDR 128 - -/* - * Compressed packet format: - * - * The first octet contains the packet type (top 3 bits), TCP - * 'push' bit, and flags that indicate which of the 4 TCP sequence - * numbers have changed (bottom 5 bits). The next octet is a - * conversation number that associates a saved IP/TCP header with - * the compressed packet. The next two octets are the TCP checksum - * from the original datagram. The next 0 to 15 octets are - * sequence number changes, one change per bit set in the header - * (there may be no changes and there are two special cases where - * the receiver implicitly knows what changed -- see below). - * - * There are 5 numbers which can change (they are always inserted - * in the following order): TCP urgent pointer, window, - * acknowlegement, sequence number and IP ID. (The urgent pointer - * is different from the others in that its value is sent, not the - * change in value.) Since typical use of SLIP links is biased - * toward small packets (see comments on MTU/MSS below), changes - * use a variable length coding with one octet for numbers in the - * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the - * range 256 - 65535 or 0. (If the change in sequence number or - * ack is more than 65535, an uncompressed packet is sent.) - */ - -/* - * Packet types (must not conflict with IP protocol version) - * - * The top nibble of the first octet is the packet type. There are - * three possible types: IP (not proto TCP or tcp with one of the - * control flags set); uncompressed TCP (a normal IP/TCP packet but - * with the 8-bit protocol field replaced by an 8-bit connection id -- - * this type of packet syncs the sender & receiver); and compressed - * TCP (described above). - * - * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and - * is logically part of the 4-bit "changes" field that follows. Top - * three bits are actual packet type. For backward compatibility - * and in the interest of conserving bits, numbers are chosen so the - * IP protocol version number (4) which normally appears in this nibble - * means "IP packet". - */ - -/* packet types */ -#define TYPE_IP 0x40 -#define TYPE_UNCOMPRESSED_TCP 0x70 -#define TYPE_COMPRESSED_TCP 0x80 -#define TYPE_ERROR 0x00 - -/* Bits in first octet of compressed packet */ -#define NEW_C 0x40 /* flag bits for what changed in a packet */ -#define NEW_I 0x20 -#define NEW_S 0x08 -#define NEW_A 0x04 -#define NEW_W 0x02 -#define NEW_U 0x01 - -/* reserved, special-case values of above */ -#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ -#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ -#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) - -#define TCP_PUSH_BIT 0x10 - - -/* - * "state" data for each active tcp conversation on the wire. This is - * basically a copy of the entire IP/TCP header from the last packet - * we saw from the conversation together with a small identifier - * the transmit & receive ends of the line use to locate saved header. - */ -struct cstate { - struct cstate *cs_next; /* next most recently used state (xmit only) */ - u16_t cs_hlen; /* size of hdr (receive only) */ - u8_t cs_id; /* connection # associated with this state */ - u8_t cs_filler; - union { - char csu_hdr[MAX_HDR]; - struct ip_hdr csu_ip; /* ip/tcp hdr from most recent packet */ - } vjcs_u; -}; -#define cs_ip vjcs_u.csu_ip -#define cs_hdr vjcs_u.csu_hdr - - -struct vjstat { - u32_t vjs_packets; /* outbound packets */ - u32_t vjs_compressed; /* outbound compressed packets */ - u32_t vjs_searches; /* searches for connection state */ - u32_t vjs_misses; /* times couldn't find conn. state */ - u32_t vjs_uncompressedin; /* inbound uncompressed packets */ - u32_t vjs_compressedin; /* inbound compressed packets */ - u32_t vjs_errorin; /* inbound unknown type packets */ - u32_t vjs_tossed; /* inbound packets tossed because of error */ -}; - -/* - * all the state data for one serial line (we need one of these per line). - */ -struct vjcompress { - struct cstate *last_cs; /* most recently used tstate */ - u8_t last_recv; /* last rcvd conn. id */ - u8_t last_xmit; /* last sent conn. id */ - u16_t flags; - u8_t maxSlotIndex; - u8_t compressSlot; /* Flag indicating OK to compress slot ID. */ -#if LINK_STATS - struct vjstat stats; -#endif - struct cstate tstate[MAX_SLOTS]; /* xmit connection states */ - struct cstate rstate[MAX_SLOTS]; /* receive connection states */ -}; - -/* flag values */ -#define VJF_TOSS 1U /* tossing rcvd frames because of input err */ - -extern void vj_compress_init (struct vjcompress *comp); -extern u8_t vj_compress_tcp (struct vjcompress *comp, struct pbuf **pb); -extern void vj_uncompress_err (struct vjcompress *comp); -extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp); -extern int vj_uncompress_tcp (struct pbuf **nb, struct vjcompress *comp); - -#endif /* VJ_H */ - -#endif /* PPP_SUPPORT && VJ_SUPPORT */ diff --git a/include/netif/slipif.h b/include/netif/slipif.h deleted file mode 100644 index 4f15303..0000000 --- a/include/netif/slipif.h +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @file - * - * SLIP netif API - */ - -/* - * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_NETIF_SLIPIF_H -#define LWIP_HDR_NETIF_SLIPIF_H - -#include "net/opt.h" -#include "net/netif.h" - -/** Set this to 1 to start a thread that blocks reading on the serial line - * (using sio_read()). - */ -#ifndef SLIP_USE_RX_THREAD -#define SLIP_USE_RX_THREAD !NO_SYS -#endif - -/** Set this to 1 to enable functions to pass in RX bytes from ISR context. - * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled - * packets on a queue, which is fed into lwIP from slipif_poll(). - * If disabled, slipif_poll() polls the serial line (using sio_tryread()). - */ -#ifndef SLIP_RX_FROM_ISR -#define SLIP_RX_FROM_ISR 0 -#endif - -/** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets - * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. - * If disabled, packets will be dropped if more than one packet is received. - */ -#ifndef SLIP_RX_QUEUE -#define SLIP_RX_QUEUE SLIP_RX_FROM_ISR -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -err_t slipif_init(struct netif * netif); -void slipif_poll(struct netif *netif); -#if SLIP_RX_FROM_ISR -void slipif_process_rxqueue(struct netif *netif); -void slipif_received_byte(struct netif *netif, u8_t data); -void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); -#endif /* SLIP_RX_FROM_ISR */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_NETIF_SLIPIF_H */ - diff --git a/include/pci/hd.h b/include/pci/hd.h deleted file mode 100644 index ea314f5..0000000 --- a/include/pci/hd.h +++ /dev/null @@ -1,487 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _PCI_HD_H_ -#define _PCI_HD_H_ - -#include -#include - -#define hdData 0x0 -#define hdError 0x1 -#define hdSecCount 0x2 -#define hdSecNum 0x3 -#define hdCylLow 0x4 -#define hdCylHi 0x5 -#define hdHead 0x6 -#define hdStat 0x7 -#define hdCmd 0x7 - -/* ATA Uhm? */ -#define ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE 0x0400 -#define ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE 0x0100 - -/* ATA register defines */ -#define ATA_DATA 0 /* (RW) data */ - -#define ATA_FEATURE 1 /* (W) feature */ -#define ATA_F_DMA 0x01 /* enable DMA */ -#define ATA_F_OVL 0x02 /* enable overlap */ - -#define ATA_COUNT 2 /* (W) sector count */ - -#define ATA_SECTOR 3 /* (RW) sector # */ -#define ATA_CYL_LSB 4 /* (RW) cylinder# LSB */ -#define ATA_CYL_MSB 5 /* (RW) cylinder# MSB */ -#define ATA_DRIVE 6 /* (W) Sector/Drive/Head */ -#define ATA_D_LBA 0x40 /* use LBA addressing */ -#define ATA_D_IBM 0xa0 /* 512 byte sectors, ECC */ - -#define ATA_COMMAND 7 /* (W) command */ - -#define ATA_ERROR 8 /* (R) error */ -#define ATA_E_ILI 0x01 /* illegal length */ -#define ATA_E_NM 0x02 /* no media */ -#define ATA_E_ABORT 0x04 /* command aborted */ -#define ATA_E_MCR 0x08 /* media change request */ -#define ATA_E_IDNF 0x10 /* ID not found */ -#define ATA_E_MC 0x20 /* media changed */ -#define ATA_E_UNC 0x40 /* uncorrectable data */ -#define ATA_E_ICRC 0x80 /* UDMA crc error */ -#define ATA_E_ATAPI_SENSE_MASK 0xf0 /* ATAPI sense key mask */ - -#define ATA_IREASON 9 /* (R) interrupt reason */ -#define ATA_I_CMD 0x01 /* cmd (1) | data (0) */ -#define ATA_I_IN 0x02 /* read (1) | write (0) */ -#define ATA_I_RELEASE 0x04 /* released bus (1) */ -#define ATA_I_TAGMASK 0xf8 /* tag mask */ - -#define ATA_STATUS 10 /* (R) status */ -#define ATA_ALTSTAT 11 /* (R) alternate status */ -#define ATA_S_ERROR 0x01 /* error */ -#define ATA_S_INDEX 0x02 /* index */ -#define ATA_S_CORR 0x04 /* data corrected */ -#define ATA_S_DRQ 0x08 /* data request */ -#define ATA_S_DSC 0x10 /* drive seek completed */ -#define ATA_S_SERVICE 0x10 /* drive needs service */ -#define ATA_S_DWF 0x20 /* drive write fault */ -#define ATA_S_DMA 0x20 /* DMA ready */ -#define ATA_S_READY 0x40 /* drive ready */ -#define ATA_S_BUSY 0x80 /* busy */ - -#define ATA_CONTROL 12 /* (W) control */ - -#define ATA_CTLOFFSET 0x206 /* control register offset */ -#define ATA_PCCARD_CTLOFFSET 0x0e /* do for PCCARD devices */ -#define ATA_PC98_CTLOFFSET 0x10c /* do for PC98 devices */ -#define ATA_A_IDS 0x02 /* disable interrupts */ -#define ATA_A_RESET 0x04 /* RESET controller */ -#ifdef ATA_LEGACY_SUPPORT -#define ATA_A_4BIT 0x08 /* 4 head bits: obsolete 1996 */ -#else -#define ATA_A_4BIT 0x00 -#endif -#define ATA_A_HOB 0x80 /* High Order Byte enable */ - -/* ATA Commands */ -#define ATA_IDENTIFY 0xEC -#define ATA_CHECK_POWER_MODE 0xE5 -#define ATA_STANDBY 0xE2 -#define ATA_STANDBY_IMMED 0xE0 -#define ATA_IDLE_IMMED 0xE1 -#define ATA_IDLE 0xE3 -#define ATA_FLUSH_CACHE 0xE7 -#define ATA_FLUSH_CACHE_EXT 0xEA -#define ATA_READ_DMA_EXT 0x25 -#define ATA_READ_DMA 0xC8 -#define ATA_READ_SECTORS_EXT 0x24 -#define ATA_READ_SECTORS 0x20 -#define ATA_WRITE_DMA_EXT 0x35 -#define ATA_WRITE_DMA 0xCA -#define ATA_WRITE_SECTORS_EXT 0x34 -#define ATA_WRITE_SECTORS 0x30 -#define ATA_WRITE_UNCORRECTABLE 0x45 -#define ATA_READ_VERIFY_SECTORS 0x40 -#define ATA_READ_VERIFY_SECTORS_EXT 0x42 -#define ATA_READ_BUFFER 0xE4 -#define ATA_WRITE_BUFFER 0xE8 -#define ATA_EXECUTE_DEVICE_DIAG 0x90 -#define ATA_SET_FEATURES 0xEF -#define ATA_SMART 0xB0 -#define ATA_PACKET_IDENTIFY 0xA1 -#define ATA_PACKET 0xA0 -#define ATA_READ_FPDMA 0x60 -#define ATA_WRITE_FPDMA 0x61 -#define ATA_READ_LOG_EXT 0x2F -#define ATA_NOP 0x00 -#define ATA_DEVICE_RESET 0x08 -#define ATA_MEDIA_EJECT 0xED -#define ATA_SECURITY_UNLOCK 0xF2 -#define ATA_SECURITY_FREEZE_LOCK 0xF5 -#define ATA_DATA_SET_MANAGEMENT 0x06 -#define ATA_DOWNLOAD_MICROCODE 0x92 -#define ATA_WRITE_STREAM_DMA_EXT 0x3A -#define ATA_READ_LOG_DMA_EXT 0x47 -#define ATA_READ_STREAM_DMA_EXT 0x2A -#define ATA_WRITE_DMA_FUA 0x3D -#define ATA_WRITE_LOG_DMA_EXT 0x57 -#define ATA_READ_DMA_QUEUED 0xC7 -#define ATA_READ_DMA_QUEUED_EXT 0x26 -#define ATA_WRITE_DMA_QUEUED 0xCC -#define ATA_WRITE_DMA_QUEUED_EXT 0x36 -#define ATA_WRITE_DMA_QUEUED_FUA_EXT 0x3E -#define ATA_READ_MULTIPLE 0xC4 -#define ATA_READ_MULTIPLE_EXT 0x29 -#define ATA_WRITE_MULTIPLE 0xC5 -#define ATA_WRITE_MULTIPLE_EXT 0x39 -#define ATA_WRITE_MULTIPLE_FUA_EXT 0xCE - -struct driveInfo { - struct driveDiskLabel *diskLabel; - struct ata_identify_data *ata_identify; - uint32_t lba_high; - uint32_t lba_low; - uint32_t sector_size; - char hdEnable; - char hdDev; - char hdFlags; - char hdShift; - long hdMask; - uint32_t hdMulti; - long hdPort; - long hdSize; - long hdCalc; - long parOffset; - int part; - long lba_start; - long lba_end; -}; - -int initHardDisk(); -int hdWrite(struct driveInfo *hdd, void *, uInt32, uInt32); -int hdRead(struct driveInfo *hdd, void *, uInt32, uInt32); -int hdReset(); -int hdIoctl(); -int hdStart(); -int hdStop(); -int hdStandby(); -int hdInit(struct device_node *dev); - -struct dos_partition { - unsigned char dp_flag; /* bootstrap flags */ - unsigned char dp_shd; /* starting head */ - unsigned char dp_ssect; /* starting sector */ - unsigned char dp_scyl; /* starting cylinder */ - unsigned char dp_type; /* partition type */ - unsigned char dp_ehd; /* end head */ - unsigned char dp_esect; /* end sector */ - unsigned char dp_ecyl; /* end cylinder */ - uInt32 dp_start; /* absolute starting sector number */ - uInt32 dp_size; /* partition size in sectors */ -}; - -#define MAXPARTITIONS 8 - -struct bsd_disklabel { - uint32_t d_magic; /* the magic number */ - u_int16_t d_type; /* drive type */ - u_int16_t d_subtype; /* controller/d_type specific */ - char d_typename[16]; /* type name, e.g. "eagle" */ - - char d_packname[16]; /* pack identifier */ - - /* disk geometry: */ - uint32_t d_secsize; /* # of bytes per sector */ - uint32_t d_nsectors; /* # of data sectors per track */ - uint32_t d_ntracks; /* # of tracks per cylinder */ - uint32_t d_ncylinders; /* # of data cylinders per unit */ - uint32_t d_secpercyl; /* # of data sectors per cylinder */ - uint32_t d_secperunit; /* # of data sectors per unit */ - - /* - * Spares (bad sector replacements) below are not counted in - * d_nsectors or d_secpercyl. Spare sectors are assumed to - * be physical sectors which occupy space at the end of each - * track and/or cylinder. - */ - u_int16_t d_sparespertrack; /* # of spare sectors per track */ - u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */ - /* - * Alternate cylinders include maintenance, replacement, configuration - * description areas, etc. - */ - uint32_t d_acylinders; /* # of alt. cylinders per unit */ - - /* hardware characteristics: */ - /* - * d_interleave, d_trackskew and d_cylskew describe perturbations - * in the media format used to compensate for a slow controller. - * Interleave is physical sector interleave, set up by the - * formatter or controller when formatting. When interleaving is - * in use, logically adjacent sectors are not physically - * contiguous, but instead are separated by some number of - * sectors. It is specified as the ratio of physical sectors - * traversed per logical sector. Thus an interleave of 1:1 - * implies contiguous layout, while 2:1 implies that logical - * sector 0 is separated by one sector from logical sector 1. - * d_trackskew is the offset of sector 0 on track N relative to - * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew - * is the offset of sector 0 on cylinder N relative to sector 0 - * on cylinder N-1. - */ - u_int16_t d_rpm; /* rotational speed */ - u_int16_t d_interleave; /* hardware sector interleave */ - u_int16_t d_trackskew; /* sector 0 skew, per track */ - u_int16_t d_cylskew; /* sector 0 skew, per cylinder */ - uint32_t d_headswitch; /* head switch time, usec */ - uint32_t d_trkseek; /* track-to-track seek, usec */ - uint32_t d_flags; /* generic flags */ -#define NDDATA 5 - uint32_t d_drivedata[NDDATA]; /* drive-type specific information */ -#define NSPARE 5 - uint32_t d_spare[NSPARE]; /* reserved for future use */ - uint32_t d_magic2; /* the magic number (again) */ - u_int16_t d_checksum; /* xor of data incl. partitions */ - - /* filesystem and partition information: */ - u_int16_t d_npartitions; /* number of partitions in following */ - uint32_t d_bbsize; /* size of boot area at sn0, bytes */ - uint32_t d_sbsize; /* max size of fs superblock, bytes */ - struct partition { /* the partition table */ - uint32_t p_size; /* number of sectors in partition */ - uint32_t p_offset; /* starting sector */ - uint32_t p_fsize; /* filesystem basic fragment size */ - u_int8_t p_fstype; /* filesystem type, see below */ - u_int8_t p_frag; /* filesystem fragments per block */ - u_int16_t p_cpg; /* filesystem cylinders per group */ - } d_partitions[MAXPARTITIONS]; /* actually may be more */ -}; - -static const char *fstypenames[] = { "unused", "swap", "Version 6", "Version 7", "System V", "4.1BSD", "Eighth Edition", "4.2BSD", "MSDOS", "4.4LFS", "unknown", "HPFS", "ISO9660", "boot", "vinum", "raid", "?", "?", "?", "?", "jfs", NULL }; - -/** - * @name ATA_IDENTIFY_DEVICE_FIELD_LENGTHS - * - * The following constants define the number of bytes contained in various - * fields found in the IDENTIFY DEVICE data structure. - */ -#define ATA_IDENTIFY_SERIAL_NUMBER_LEN 20 -#define ATA_IDENTIFY_MODEL_NUMBER_LEN 40 -#define ATA_IDENTIFY_FW_REVISION_LEN 8 -#define ATA_IDENTIFY_48_LBA_LEN 8 -#define ATA_IDENTIFY_MEDIA_SERIAL_NUMBER_LEN 30 -#define ATA_IDENTIFY_WWN_LEN 8 - -struct ata_identify_data { - u_int16_t general_config_bits; // word 00 - u_int16_t obsolete0; // word 01 (num cylinders) - u_int16_t vendor_specific_config_bits; // word 02 - u_int16_t obsolete1; // word 03 (num heads) - u_int16_t retired1[2]; // words 04-05 - u_int16_t obsolete2; // word 06 (sectors / track) - u_int16_t reserved_for_compact_flash1[2]; // words 07-08 - u_int16_t retired0; // word 09 - u_int8_t serial_number[ATA_IDENTIFY_SERIAL_NUMBER_LEN]; // word 10-19 - u_int16_t retired2[2]; // words 20-21 - u_int16_t obsolete4; // word 22 - u_int8_t firmware_revision[ATA_IDENTIFY_FW_REVISION_LEN]; // words 23-26 - u_int8_t model_number[ATA_IDENTIFY_MODEL_NUMBER_LEN]; // words 27-46 - u_int16_t max_sectors_per_multiple; // word 47 - u_int16_t reserved0; // word 48 - u_int16_t capabilities1; // word 49 - u_int16_t capabilities2; // word 50 - u_int16_t obsolete5[2]; // words 51-52 - u_int16_t validity_bits; // word 53 - u_int16_t obsolete6[5]; // words 54-58 Used to be: - // current cylinders, - // current heads, - // current sectors/Track, - // current capacity - u_int16_t current_max_sectors_per_multiple; // word 59 - u_int8_t total_num_sectors[4]; // words 60-61 - u_int16_t obsolete7; // word 62 - u_int16_t multi_word_dma_mode; // word 63 - u_int16_t pio_modes_supported; // word 64 - u_int16_t min_multiword_dma_transfer_cycle; // word 65 - u_int16_t rec_min_multiword_dma_transfer_cycle; // word 66 - u_int16_t min_pio_transfer_no_flow_ctrl; // word 67 - u_int16_t min_pio_transfer_with_flow_ctrl; // word 68 - u_int16_t additional_supported; // word 69 - u_int16_t reserved1; // word 70 - u_int16_t reserved2[4]; // words 71-74 - u_int16_t queue_depth; // word 75 - u_int16_t serial_ata_capabilities; // word 76 - u_int16_t serial_ata_reserved; // word 77 - u_int16_t serial_ata_features_supported; // word 78 - u_int16_t serial_ata_features_enabled; // word 79 - u_int16_t major_version_number; // word 80 - u_int16_t minor_version_number; // word 81 - u_int16_t command_set_supported0; // word 82 - u_int16_t command_set_supported1; // word 83 - u_int16_t command_set_supported_extention; // word 84 - u_int16_t command_set_enabled0; // word 85 - u_int16_t command_set_enabled1; // word 86 - u_int16_t command_set_default; // word 87 - u_int16_t ultra_dma_mode; // word 88 - u_int16_t security_erase_completion_time; // word 89 - u_int16_t enhanced_security_erase_time; // word 90 - u_int16_t current_power_mgmt_value; // word 91 - u_int16_t master_password_revision; // word 92 - u_int16_t hardware_reset_result; // word 93 - u_int16_t current_acoustic_management_value; // word 94 - u_int16_t stream_min_request_size; // word 95 - u_int16_t stream_transfer_time; // word 96 - u_int16_t stream_access_latency; // word 97 - u_int16_t stream_performance_granularity[2]; // words 98-99 - u_int8_t max_48bit_lba[ATA_IDENTIFY_48_LBA_LEN]; // words 100-103 - u_int16_t streaming_transfer_time; // word 104 - u_int16_t max_lba_range_entry_blocks; // word 105 - u_int16_t physical_logical_sector_info; // word 106 - u_int16_t acoustic_test_interseek_delay; // word 107 - u_int8_t world_wide_name[ATA_IDENTIFY_WWN_LEN]; // words 108-111 - u_int8_t reserved_for_wwn_extention[ATA_IDENTIFY_WWN_LEN]; // words 112-115 - u_int16_t reserved4; // word 116 - u_int8_t words_per_logical_sector[4]; // words 117-118 - u_int16_t command_set_supported2; // word 119 - u_int16_t reserved5[7]; // words 120-126 - u_int16_t removable_media_status; // word 127 - u_int16_t security_status; // word 128 - u_int16_t vendor_specific1[31]; // words 129-159 - u_int16_t cfa_power_mode1; // word 160 - u_int16_t reserved_for_compact_flash2[7]; // words 161-167 - u_int16_t device_nominal_form_factor; // word 168 - u_int16_t data_set_management; // word 169 - u_int16_t reserved_for_compact_flash3[6]; // words 170-175 - u_int16_t current_media_serial_number[ATA_IDENTIFY_MEDIA_SERIAL_NUMBER_LEN]; //words 176-205 - u_int16_t reserved6[3]; // words 206-208 - u_int16_t logical_sector_alignment; // words 209 - u_int16_t reserved7[7]; // words 210-216 - u_int16_t nominal_media_rotation_rate; // word 217 - u_int16_t reserved8[16]; // words 218-233 - u_int16_t min_num_blocks_per_microcode; // word 234 - u_int16_t max_num_blocks_per_microcode; // word 235 - u_int16_t reserved9[19]; // words 236-254 - u_int16_t integrity_word; // word 255 -}; - -/* - * A list of partition types, probably outdated. - */ -static const char * const part_types[256] = { - [0x00] = "unused", - [0x01] = "Primary DOS with 12 bit FAT", - [0x02] = "XENIX / file system", - [0x03] = "XENIX /usr file system", - [0x04] = "Primary DOS with 16 bit FAT (< 32MB)", - [0x05] = "Extended DOS", - [0x06] = "Primary DOS, 16 bit FAT (>= 32MB)", - [0x07] = "NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX", - [0x08] = "AIX file system or SplitDrive", - [0x09] = "AIX boot partition or Coherent", - [0x0A] = "OS/2 Boot Manager, OPUS or Coherent swap", - [0x0B] = "DOS or Windows 95 with 32 bit FAT", - [0x0C] = "DOS or Windows 95 with 32 bit FAT (LBA)", - [0x0E] = "Primary 'big' DOS (>= 32MB, LBA)", - [0x0F] = "Extended DOS (LBA)", - [0x10] = "OPUS", - [0x11] = "OS/2 BM: hidden DOS with 12-bit FAT", - [0x12] = "Compaq diagnostics", - [0x14] = "OS/2 BM: hidden DOS with 16-bit FAT (< 32MB)", - [0x16] = "OS/2 BM: hidden DOS with 16-bit FAT (>= 32MB)", - [0x17] = "OS/2 BM: hidden IFS (e.g. HPFS)", - [0x18] = "AST Windows swapfile", - [0x1b] = "ASUS Recovery partition (NTFS)", - [0x24] = "NEC DOS", - [0x3C] = "PartitionMagic recovery", - [0x39] = "plan9", - [0x40] = "VENIX 286", - [0x41] = "Linux/MINIX (sharing disk with DRDOS)", - [0x42] = "SFS or Linux swap (sharing disk with DRDOS)", - [0x43] = "Linux native (sharing disk with DRDOS)", - [0x4D] = "QNX 4.2 Primary", - [0x4E] = "QNX 4.2 Secondary", - [0x4F] = "QNX 4.2 Tertiary", - [0x50] = "DM (disk manager)", - [0x51] = "DM6 Aux1 (or Novell)", - [0x52] = "CP/M or Microport SysV/AT", - [0x53] = "DM6 Aux3", - [0x54] = "DM6", - [0x55] = "EZ-Drive (disk manager)", - [0x56] = "Golden Bow (disk manager)", - [0x5c] = "Priam Edisk (disk manager)", /* according to S. Widlake */ - [0x61] = "SpeedStor", - [0x63] = "System V/386 (such as ISC UNIX), GNU HURD or Mach", - [0x64] = "Novell Netware/286 2.xx", - [0x65] = "Novell Netware/386 3.xx", - [0x70] = "DiskSecure Multi-Boot", - [0x75] = "PCIX", - [0x77] = "QNX4.x", - [0x78] = "QNX4.x 2nd part", - [0x79] = "QNX4.x 3rd part", - [0x80] = "Minix until 1.4a", - [0x81] = "Minix since 1.4b, early Linux partition or Mitac disk manager", - [0x82] = "Linux swap or Solaris x86", - [0x83] = "Linux native", - [0x84] = "OS/2 hidden C: drive", - [0x85] = "Linux extended", - [0x86] = "NTFS volume set??", - [0x87] = "NTFS volume set??", - [0x93] = "Amoeba file system", - [0x94] = "Amoeba bad block table", - [0x9F] = "BSD/OS", - [0xA0] = "Suspend to Disk", - [0xA5] = "FreeBSD/NetBSD/386BSD", - [0xA6] = "OpenBSD", - [0xA7] = "NeXTSTEP", - [0xA9] = "NetBSD", - [0xAC] = "IBM JFS", - [0xAF] = "HFS+", - [0xB7] = "BSDI BSD/386 file system", - [0xB8] = "BSDI BSD/386 swap", - [0xBE] = "Solaris x86 boot", - [0xBF] = "Solaris x86 (new)", - [0xC1] = "DRDOS/sec with 12-bit FAT", - [0xC4] = "DRDOS/sec with 16-bit FAT (< 32MB)", - [0xC6] = "DRDOS/sec with 16-bit FAT (>= 32MB)", - [0xC7] = "Syrinx", - [0xDB] = "CP/M, Concurrent CP/M, Concurrent DOS or CTOS", - [0xDE] = "DELL Utilities - FAT filesystem", - [0xE1] = "DOS access or SpeedStor with 12-bit FAT extended partition", - [0xE3] = "DOS R/O or SpeedStor", - [0xE4] = "SpeedStor with 16-bit FAT extended partition < 1024 cyl.", - [0xEB] = "BeOS file system", - [0xEE] = "EFI GPT", - [0xEF] = "EFI System Partition", - [0xF1] = "SpeedStor", - [0xF2] = "DOS 3.3+ Secondary", - [0xF4] = "SpeedStor large partition", - [0xFB] = "VMware VMFS", - [0xFE] = "SpeedStor >1024 cyl. or LANstep", - [0xFF] = "Xenix bad blocks table", }; - -#endif diff --git a/include/pci/lnc.h b/include/pci/lnc.h deleted file mode 100644 index aafd2a0..0000000 --- a/include/pci/lnc.h +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _PCI_LNC_H -#define _PCI_LNC_H - -#include - -// TEMP COMMENT FRESH -#define RDP 0x10 // Register Data Port 16Bit -#define RDP32 0x10 // Register Data Port 32Bit -#define RAP 0x12 // Register Address Port 16Bit -#define RAP32 0x14 // Register Address Port 32Bit -#define RESET 0x14 // Reset Port 16Bit -#define RESET32 0x18 // Reset Port 32Bit -#define BDP 0x16 // 16Bit -#define BDP32 0x1C // 32Bit - -// BCR18 -#define BCR18 18 -#define BCR18_DWIO 0x0080 - -// BCR20 -#define BCR20 0x0014 - -// Modes -#define MODE_16 0 -#define MODE_32 1 -#define MODE_INVALID 3 - -// CSR0 -#define CSR0 0x0000 -#define CSR0_STOP 0x0004 - -// CSR15 -#define CSR15 15 -#define CSR15_DXMTFCS 0x0008 -#define CSR15_DRTY 0x0020 -#define CSR15_PROM 0x8000 - -// CSR58 -#define CSR58 0x003A - -struct mds { - uint16_t md0; - uint16_t md1; - short md2; - uint16_t md3; -}; - -struct hostRingEntry_old { - struct mds *md; - union { - //struct mbuf *mbuf; - char *data; - } buff; -}; - -struct hostRingEntry { - uint32_t addr; - uint16_t bcnt; - uint8_t md[6]; - uint32_t reserved; -}; - -struct arpcom { - //struct ifnet ac_if; /* network-visible interface */ - uint8_t ac_enaddr[6]; /* ethernet hardware address */ - int ac_multicnt; /* length of ac_multiaddrs list */ - void *ac_netgraph; /* ng_ether(4) netgraph node info */ -}; - -struct nicInfo { - int ident; /* Type of card */ - int ic; /* Type of ic, Am7990, Am79C960 etc. */ - int memMode; - int iobase; - int mode; /* Mode setting at initialization */ -}; - -struct initBlock16 { - uint16_t mode; // Mode register - uint8_t padr[6]; // Ethernet address - uint8_t ladrf[8]; // Logical address filter (multicast) - uint16_t rdra; // Low order pointer to receive ring - uint16_t rlen; // High order pointer and no. rings - uint16_t tdra; // Low order pointer to transmit ring - uint16_t tlen; // High order pointer and no rings -}; - -struct initBlock32 { - uint16_t mode; - uint8_t rlen; - uint8_t tlen; - uint8_t padr[6]; - uint16_t res; - uint8_t ladrf[8]; - uint32_t rdra; - uint32_t tdra; -}; - -struct lncInfo { - struct arpcom arpcom; - struct nicInfo nic; - struct hostRingEntry *rxRing; - char *rxBuffer; - struct hostRingEntry *txRing; - char *txBuffer; - struct initBlock32 init; - unsigned int ioAddr; - int nrdre; - int ntdre; - int bufferSize; - int txPtr; - int rxPtr; -}; - -/* Functions */ -void lnc_writeCSR(struct lncInfo *, uint16_t, uint16_t); -void lnc_writeCSR32(struct lncInfo *, uint32_t, uint32_t); - -uint16_t lnc_readCSR(struct lncInfo *, uint16_t); -uint32_t lnc_readCSR32(struct lncInfo *, uint32_t); - -void lnc_writeBCR(struct lncInfo *, uint16_t, uint16_t); -void lnc_writeBCR32(struct lncInfo *, uint32_t, uint32_t); - -uint16_t lnc_readBCR(struct lncInfo *, uint16_t); -uint32_t lnc_readBCR32(struct lncInfo *, uint32_t); - -void lnc_reset(struct lncInfo *); -void lnc_reset32(struct lncInfo *); - -int lnc_probe(struct lncInfo *); - -int lnc_switchDWord(struct lncInfo *); - -int lnc_getMode(struct lncInfo *); - -void lnc_isr(); -int lnc_driverOwnsRX(struct lncInfo *); -int lnc_driverOwnsRX(struct lncInfo *); - -void lnc_INT(); -void lnc_rxINT(); -void lnc_txINT(); - -// OLD - -#define NDESC(len2) (1 << len2) -#define NORMAL 0 -#define MEM_SLEW 8 -#define TRANSBUFSIZE 1518 -#define RECVBUFSIZE 1518 -#define NRDRE 3 -#define NTDRE 3 -#define ETHER_ADDR_LEN 6 -#define NE2100_IOSIZE 24 - -#define PCNET_VSW 0x18 -#define NE2100 2 - -/* mem_mode values */ -#define DMA_FIXED 1 -#define DMA_MBUF 2 -#define SHMEM 4 - -/********** Chip Types **********/ -#define UNKNOWN 0 /* Unknown */ -#define LANCE 1 /* Am7990 */ -#define C_LANCE 2 /* Am79C90 */ -#define PCnet_ISA 3 /* Am79C960 */ -#define PCnet_ISAplus 4 /* Am79C961 */ -#define PCnet_ISA_II 5 /* Am79C961A */ -#define PCnet_32 6 /* Am79C965 */ -#define PCnet_PCI 7 /* Am79C970 */ -#define PCnet_PCI_II 8 /* Am79C970A */ -#define PCnet_FAST 9 /* Am79C971 */ -#define PCnet_FASTplus 10 /* Am79C972 */ -#define PCnet_Home 11 /* Am79C978 */ - -/******** AM7990 Specifics **************/ -#define CSR1 1 -#define CSR2 2 -#define CSR3 3 -#define CSR88 88 -#define CSR89 89 - -#define ERR 0x8000 -#define BABL 0x4000 -#define CERR 0x2000 -#define MISS 0x1000 -#define MERR 0x0800 -#define RINT 0x0400 -#define TINT 0x0200 -#define IDON 0x0100 -#define INTR 0x0080 -#define INEA 0x0040 -#define RXON 0x0020 -#define TXON 0x0010 -#define TDMD 0x0008 - -#define STRT 0x0002 -#define INIT 0x0001 - -/* CSR88-89: Chip ID masks */ -#define AMD_MASK 0x003 -#define PART_MASK 0xffff -#define Am79C960 0x0003 -#define Am79C961 0x2260 -#define Am79C961A 0x2261 -#define Am79C965 0x2430 -#define Am79C970 0x0242 -#define Am79C970A 0x2621 -#define Am79C971 0x2623 -#define Am79C972 0x2624 -#define Am79C973 0x2625 -#define Am79C978 0x2626 - -extern struct lncInfo *lnc; - -int initLNC(); -int probe(struct lncInfo *lnc); -int lanceProbe(struct lncInfo *lnc); -int lncAttach(struct lncInfo *lnc, int unit); - -void lncInt(); -void _lncInt(); - -int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uInt8 *dest); - -#endif diff --git a/include/pci/pci.h b/include/pci/pci.h deleted file mode 100644 index 1c8d00d..0000000 --- a/include/pci/pci.h +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _PCI_H -#define _PCI_H - -#include - -struct pciConfig { - uint16_t vendorID; - uint16_t deviceID; - - uint16_t command; - uint16_t status; - - uint8_t revisionID; - uint8_t progIf; - uint8_t subClass; - uint8_t classCode; - - uint8_t cacheLineSize; - uint8_t latencyTimer; - uint8_t headerType; - uint8_t bist; - - uint32_t bar[6]; - - uint32_t cbPointer; - - uint16_t subsysVendorID; - uint16_t subsysID; - - uint32_t epromAddr; - - uint16_t capabilites; - uint16_t res1; - - uint32_t res2; - - uint8_t intLine; - uint8_t intPin; - uint8_t minGrant; - uint8_t maxLatency; - - /* device info */ - //uint8_t bus; - //uint8_t dev; - //uint8_t func; - //uint8_t irq; - //uint8_t irqLine; - /* base registers */ - //uInt32 base[6]; - //uInt32 size[6]; - //uint16_t subsysVendor; - //uint16_t subsys; - /* Device Info */ - //Move this to anotther struct eventually - uint8_t bus; - uint8_t dev; - uint8_t func; - -}; - -struct confadd { - uint8_t reg :8; - uint8_t func :3; - uint8_t dev :5; - uint8_t bus :8; - uint8_t rsvd :7; - uint8_t enable :1; -}; - -#define countof(a) (sizeof(a) / sizeof(a[0])) - -int pci_init(); - -uint32_t pciProbe(int bus, int dev, int func); -uInt32 pciRead(int bus, int dev, int func, int reg, int bytes); -void pciWrite(int bus, int dev, int func, int reg, uInt32 v, int bytes); - -#endif diff --git a/include/sde/ogDisplay_UbixOS.h b/include/sde/ogDisplay_UbixOS.h deleted file mode 100644 index 8726d07..0000000 --- a/include/sde/ogDisplay_UbixOS.h +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef OGDISPLAY_UBIXOS_H -#define OGDISPLAY_UBIXOS_H - -#include -#include - -struct ogModeInfo { - uint16_t modeAttributes __attribute__((packed)); - uint8_t windowAFlags __attribute__((packed)); - uint8_t windowBFlags __attribute__((packed)); - uint16_t granularity __attribute__((packed)); - uint16_t windowSize __attribute__((packed)); - uint16_t windowASeg __attribute__((packed)); - uint16_t windowBSeg __attribute__((packed)); - void* bankSwitch __attribute__((packed)); - uint16_t bytesPerLine __attribute__((packed)); - uint16_t xRes __attribute__((packed)); - uint16_t yRes __attribute__((packed)); - uint8_t charWidth __attribute__((packed)); - uint8_t charHeight __attribute__((packed)); - uint8_t numBitPlanes __attribute__((packed)); - uint8_t bitsPerPixel __attribute__((packed)); - uint8_t numberOfBanks __attribute__((packed)); - uint8_t memoryModel __attribute__((packed)); - uint8_t bankSize __attribute__((packed)); - uint8_t numOfImagePages __attribute__((packed)); - uint8_t reserved __attribute__((packed)); - // Direct colour fields (required for Direct/6 and YUV/7 memory models - uint8_t redMaskSize __attribute__((packed)); - uint8_t redFieldPosition __attribute__((packed)); - uint8_t greenMaskSize __attribute__((packed)); - uint8_t greenFieldPosition __attribute__((packed)); - uint8_t blueMaskSize __attribute__((packed)); - uint8_t blueFieldPosition __attribute__((packed)); - uint8_t alphaMaskSize __attribute__((packed)); - uint8_t alphaFieldPosition __attribute__((packed)); - uint8_t directColourMode __attribute__((packed)); - // VESA 2.0 specific fields - uint32_t physBasePtr __attribute__((packed)); - void* offScreenMemOffset __attribute__((packed)); - uint16_t offScreenMemSize __attribute__((packed)); - uint8_t paddington[461] __attribute__((packed)); -}; - -struct ogVESAInfo { - char VBESignature[4] __attribute__((packed)); - uint8_t minVersion __attribute__((packed)); - uint8_t majVersion __attribute__((packed)); - uint32_t OEMStringPtr __attribute__((packed)); - uint32_t capabilities __attribute__((packed)); - uint32_t videoModePtr __attribute__((packed)); - uint16_t totalMemory __attribute__((packed)); - // VESA 2.0 specific fields - uint16_t OEMSoftwareRev __attribute__((packed)); - uint32_t OEMVendorNamePtr __attribute__((packed)); - uint32_t OEMProductNamePtr __attribute__((packed)); - uint32_t OEMProductRevPtr __attribute__((packed)); - uint8_t paddington[474] __attribute__((packed)); -}; - -class ogDisplay_UbixOS: public ogSurface { - protected: - void * pages[2]; - uint32_t activePage; - uint32_t visualPage; - ogVESAInfo * VESAInfo; - ogModeInfo * modeInfo; - - uint16_t FindMode(uint32_t, uint32_t, uint32_t); - void GetModeInfo(uint16_t); - void GetVESAInfo(void); - void SetMode(uint16_t); - void SetPal(void); - public: - ogDisplay_UbixOS(void); - virtual bool ogAlias(ogSurface&, uint32_t, uint32_t, uint32_t, uint32_t); - virtual bool ogClone(ogSurface&); - virtual void ogCopyPalette(ogSurface&); - virtual bool ogCreate(uint32_t, uint32_t, ogPixelFmt); - virtual bool ogLoadPalette(const char *); - virtual void ogSetPalette(const ogRGBA8[]); - virtual void ogSetPalette(uint8_t, uint8_t, uint8_t, uint8_t); - virtual void ogSetPalette(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); - virtual ~ogDisplay_UbixOS(void); -}; -// ogDisplay_UbixOS - -#endif diff --git a/include/sde/sde.h b/include/sde/sde.h deleted file mode 100644 index 4454434..0000000 --- a/include/sde/sde.h +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _SDE_SDE_H -#define _SDE_SDE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define registerWindow 1 -#define windowReady 2 -#define drawWindow 3 -#define killWindow 4 - -void sdeThread(); - -//void sysSDE(uint32_t cmd, void *ptr); -int sysSDE(struct thread *td, struct sys_sde_args *args); - -struct sdeWindows { - struct sdeWindows *next; - struct sdeWindows *prev; - void *buf; - pidType pid; - uint8_t status; -}; - -extern struct sdeWindows *windows; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/stdarg.h b/include/stdarg.h deleted file mode 100644 index 0555230..0000000 --- a/include/stdarg.h +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _STDARG_H -#define _STDARG_H - -typedef char *va_list; - -/* - #define __va_size(type) (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) - #define va_start(ap, last) ((ap) = (va_list)&(last) + __va_size(last)) - #define va_arg(ap,type) (*(type *)((ap) += __va_size(type), (ap) - __va_size(type))) - #define va_end(ap) ( ap = (va_list)0 ) - */ - -#define va_start(ap, last) \ - __builtin_va_start((ap), (last)) - -#define va_arg(ap, type) \ - __builtin_va_arg((ap), type) - -#define __va_copy(dest, src) \ - __builtin_va_copy((dest), (src)) - -#define va_end(ap) \ - __builtin_va_end(ap) - -int vsprintf(char *buf, const char *fmt, va_list args); - -#endif - -/*** - $Log: stdarg.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:13 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:38 reddawg - no message - - Revision 1.2 2004/05/21 15:22:35 reddawg - Cleaned up - - - END - ***/ diff --git a/include/string.h b/include/string.h index c5d96d1..e375a77 100644 --- a/include/string.h +++ b/include/string.h @@ -41,8 +41,9 @@ * Prototype functions which were historically defined in , but * are required by POSIX to be prototyped in . */ +#if __BSD_VISIBLE #include - +#endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; diff --git a/include/sys/_null.h b/include/sys/_null.h deleted file mode 100644 index 6fb13a7..0000000 --- a/include/sys/_null.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2003 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: releng/11.2/sys/sys/_null.h 331722 2018-03-29 02:50:57Z eadler $ - */ - -#ifndef NULL - -#if !defined(__cplusplus) -#define NULL ((void *)0) -#else -#if __cplusplus >= 201103L -#define NULL nullptr -#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 -#define NULL __null -#else -#if defined(__LP64__) -#define NULL (0L) -#else -#define NULL 0 -#endif /* __LP64__ */ -#endif /* __GNUG__ */ -#endif /* !__cplusplus */ - -#endif diff --git a/include/sys/_sigset.h b/include/sys/_sigset.h deleted file mode 100644 index eb73c5b..0000000 --- a/include/sys/_sigset.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1989, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)signal.h 8.4 (Berkeley) 5/4/95 - * $FreeBSD: releng/11.2/sys/sys/_sigset.h 331722 2018-03-29 02:50:57Z eadler $ - */ - -#ifndef _SYS__SIGSET_H_ -#define _SYS__SIGSET_H_ - -/* - * sigset_t macros. - */ -#define _SIG_WORDS 4 -#define _SIG_MAXSIG 128 -#define _SIG_IDX(sig) ((sig) - 1) -#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) -#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) -#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) - -typedef struct __sigset { - __uint32_t __bits[_SIG_WORDS]; -} __sigset_t; - -#if defined(_KERNEL) && defined(COMPAT_43) -typedef unsigned int osigset_t; -#endif - -#endif /* !_SYS__SIGSET_H_ */ diff --git a/include/sys/_stdint.h b/include/sys/_stdint.h deleted file mode 100644 index d5b8c77..0000000 --- a/include/sys/_stdint.h +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * Copyright (c) 2011 David E. O'Brien - * Copyright (c) 2001 Mike Barcroft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: releng/11.2/sys/sys/_stdint.h 331722 2018-03-29 02:50:57Z eadler $ - */ - -#ifndef _SYS__STDINT_H_ -#define _SYS__STDINT_H_ - -#ifndef _INT8_T_DECLARED -typedef __int8_t int8_t; -#define _INT8_T_DECLARED -#endif - -#ifndef _INT16_T_DECLARED -typedef __int16_t int16_t; -#define _INT16_T_DECLARED -#endif - -#ifndef _INT32_T_DECLARED -typedef __int32_t int32_t; -#define _INT32_T_DECLARED -#endif - -#ifndef _INT64_T_DECLARED -typedef __int64_t int64_t; -#define _INT64_T_DECLARED -#endif - -#ifndef _UINT8_T_DECLARED -typedef __uint8_t uint8_t; -#define _UINT8_T_DECLARED -#endif - -#ifndef _UINT16_T_DECLARED -typedef __uint16_t uint16_t; -#define _UINT16_T_DECLARED -#endif - -#ifndef _UINT32_T_DECLARED -typedef __uint32_t uint32_t; -#define _UINT32_T_DECLARED -#endif - -#ifndef _UINT64_T_DECLARED -typedef __uint64_t uint64_t; -#define _UINT64_T_DECLARED -#endif - -#ifndef _INTPTR_T_DECLARED -typedef __intptr_t intptr_t; -#define _INTPTR_T_DECLARED -#endif -#ifndef _UINTPTR_T_DECLARED -typedef __uintptr_t uintptr_t; -#define _UINTPTR_T_DECLARED -#endif -#ifndef _INTMAX_T_DECLARED -typedef __intmax_t intmax_t; -#define _INTMAX_T_DECLARED -#endif -#ifndef _UINTMAX_T_DECLARED -typedef __uintmax_t uintmax_t; -#define _UINTMAX_T_DECLARED -#endif - -#endif /* !_SYS__STDINT_H_ */ diff --git a/include/sys/_timespec.h b/include/sys/_timespec.h deleted file mode 100644 index fffe786..0000000 --- a/include/sys/_timespec.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _SYS__TIMESPEC_H -#define _SYS__TIMESPEC_H - -#include - -#ifndef _TIME_T_DECLARED -typedef __time_t time_t; -#define _TIME_T_DECLARED -#endif - -struct timespec { - time_t tv_sec; /* seconds */ - long tv_nsec; /* and nanoseconds */ -}; - -#endif /* END _SYS__TIMESPEC_H */ - diff --git a/include/sys/_timeval.h b/include/sys/_timeval.h deleted file mode 100644 index 931f21c..0000000 --- a/include/sys/_timeval.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _SYS__TIMEVAL_H -#define _SYS__TIMEVAL_H - -#include - -#ifndef _SUSECONDS_T_DECLARED -typedef __suseconds_t suseconds_t; -#define _SUSECONDS_T_DECLARED -#endif - -#ifndef _TIME_T_DECLARED -typedef __time_t time_t; -#define _TIME_T_DECLARED -#endif - -// Structure returned by gettimeofday(2) system call, and used in other calls. -struct timeval { - time_t tv_sec; /* seconds */ - suseconds_t tv_usec; /* and microseconds */ -}; - -#endif /* END _SYS__TIMEVAL_H */ diff --git a/include/sys/_types.h b/include/sys/_types.h deleted file mode 100644 index baef253..0000000 --- a/include/sys/_types.h +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS__TYPES_H_ -#define _SYS__TYPES_H_ - -#include -#include - -typedef __uint32_t __ino_t; -typedef __uint32_t __dev_t; /* device number */ -typedef __uint16_t __mode_t; -typedef __uint16_t __nlink_t; /* link count */ -typedef __uint32_t __uid_t; -typedef __uint32_t __gid_t; -typedef __int32_t __time_t; -typedef __int64_t __blkcnt_t; /* file block count */ -typedef __uint32_t __blksize_t; /* file block size */ -typedef __uint32_t __fflags_t; /* file flags */ -typedef int ___wchar_t; - -typedef long __suseconds_t; /* microseconds (signed) */ -typedef __int32_t __pid_t;/* process [group] */ - - -/* - * Unusual type definitions. - */ -/* - * rune_t is declared to be an ``int'' instead of the more natural - * ``unsigned long'' or ``long''. Two things are happening here. It is not - * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, - * it looks like 10646 will be a 31 bit standard. This means that if your - * ints cannot hold 32 bits, you will be in trouble. The reason an int was - * chosen over a long is that the is*() and to*() routines take ints (says - * ANSI C), but they use __ct_rune_t instead of int. - * - * NOTE: rune_t is not covered by ANSI nor other standards, and should not - * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and - * rune_t must be the same type. Also, wint_t should be able to hold all - * members of the largest character set plus one extra value (WEOF), and - * must be at least 16 bits. - */ -typedef int __ct_rune_t; /* arg type for ctype funcs */ -typedef __ct_rune_t __rune_t; /* rune_t (see above) */ -typedef __ct_rune_t __wint_t; /* wint_t (see above) */ - -typedef struct { - long long __max_align1 __aligned(_Alignof(long long)); -#ifndef _STANDALONE - long double __max_align2 __aligned(_Alignof(long double)); -#endif -} __max_align_t; - - -#if !defined(__clang__) || !defined(__cplusplus) -typedef __uint_least16_t __char16_t; -typedef __uint_least32_t __char32_t; -#endif - -#endif /* !_SYS__TYPES_H_ */ diff --git a/include/sys/bootinfo.h b/include/sys/bootinfo.h deleted file mode 100644 index dfb2b78..0000000 --- a/include/sys/bootinfo.h +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define N_BIOS_GEOM 8 - -struct bootinfo { - u_int32_t bi_version; - u_int32_t bi_kernelname; /* represents a char * */ - u_int32_t bi_nfs_diskless; /* struct nfs_diskless * */ - /* End of fields that are always present. */ -#define bi_endcommon bi_n_bios_used - u_int32_t bi_n_bios_used; - u_int32_t bi_bios_geom[N_BIOS_GEOM]; - u_int32_t bi_size; - u_int8_t bi_memsizes_valid; - u_int8_t bi_bios_dev; /* bootdev BIOS unit number */ - u_int8_t bi_pad[2]; - u_int32_t bi_basemem; - u_int32_t bi_extmem; - u_int32_t bi_symtab; /* struct symtab * */ - u_int32_t bi_esymtab; /* struct symtab * */ - /* Items below only from advanced bootloader */ - u_int32_t bi_kernend; /* end of kernel space */ - u_int32_t bi_envp; /* environment */ - u_int32_t bi_modulep; /* preloaded modules */ - uint32_t bi_memdesc_version; /* EFI memory desc version */ - uint64_t bi_memdesc_size; /* sizeof EFI memory desc */ - uint64_t bi_memmap; /* pa of EFI memory map */ - uint64_t bi_memmap_size; /* size of EFI memory map */ - uint64_t bi_hcdp; /* DIG64 HCDP table */ - uint64_t bi_fpswa; /* FPSWA interface */ - uint64_t bi_systab; /* pa of EFI system table */ -}; diff --git a/include/sys/buf.h b/include/sys/buf.h deleted file mode 100644 index f9df8ae..0000000 --- a/include/sys/buf.h +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of - conditions, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Id: buf.h 79 2016-01-11 16:21:27Z reddawg $ - - *****************************************************************************************/ - -#ifndef _BUF_H -#define _BUF_H - -#include -#include - -struct buf { - }; - - -#endif diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h deleted file mode 100644 index 4117232..0000000 --- a/include/sys/cdefs.h +++ /dev/null @@ -1,895 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Berkeley Software Design, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 - * $FreeBSD: releng/11.1/sys/sys/cdefs.h 317342 2017-04-23 20:32:46Z kib $ - */ - -#ifndef _SYS_CDEFS_H_ -#define _SYS_CDEFS_H_ - -/* - * Testing against Clang-specific extensions. - */ -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif -#ifndef __has_extension -#define __has_extension __has_feature -#endif -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#ifndef __has_include -#define __has_include(x) 0 -#endif -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#if defined(__cplusplus) -#define __BEGIN_DECLS extern "C" { -#define __END_DECLS } -#else -#define __BEGIN_DECLS -#define __END_DECLS -#endif - -/* - * This code has been put in place to help reduce the addition of - * compiler specific defines in FreeBSD code. It helps to aid in - * having a compiler-agnostic source tree. - */ - -#if defined(__GNUC__) || defined(__INTEL_COMPILER) - -#if __GNUC__ >= 3 || defined(__INTEL_COMPILER) -#define __GNUCLIKE_ASM 3 -#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS -#else -#define __GNUCLIKE_ASM 2 -#endif -#define __GNUCLIKE___TYPEOF 1 -#define __GNUCLIKE___OFFSETOF 1 -#define __GNUCLIKE___SECTION 1 - -#ifndef __INTEL_COMPILER -#define __GNUCLIKE_CTOR_SECTION_HANDLING 1 -#endif - -#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 -#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \ - __INTEL_COMPILER < 800 -#undef __GNUCLIKE_BUILTIN_CONSTANT_P -#endif - -#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) -#define __GNUCLIKE_BUILTIN_VARARGS 1 -#define __GNUCLIKE_BUILTIN_STDARG 1 -#define __GNUCLIKE_BUILTIN_VAALIST 1 -#endif - -#if defined(__GNUC__) -#define __GNUC_VA_LIST_COMPATIBILITY 1 -#endif - -/* - * Compiler memory barriers, specific to gcc and clang. - */ -#if defined(__GNUC__) -#define __compiler_membar() __asm __volatile(" " : : : "memory") -#endif - -#ifndef __INTEL_COMPILER -#define __GNUCLIKE_BUILTIN_NEXT_ARG 1 -#define __GNUCLIKE_MATH_BUILTIN_RELOPS -#endif - -#define __GNUCLIKE_BUILTIN_MEMCPY 1 - -/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ -#define __CC_SUPPORTS_INLINE 1 -#define __CC_SUPPORTS___INLINE 1 -#define __CC_SUPPORTS___INLINE__ 1 - -#define __CC_SUPPORTS___FUNC__ 1 -#define __CC_SUPPORTS_WARNING 1 - -#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ - -#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 - -#endif /* __GNUC__ || __INTEL_COMPILER */ - -/* - * Macro to test if we're using a specific version of gcc or later. - */ -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) -#define __GNUC_PREREQ__(ma, mi) \ - (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) -#else -#define __GNUC_PREREQ__(ma, mi) 0 -#endif - -/* - * The __CONCAT macro is used to concatenate parts of symbol names, e.g. - * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. - * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI - * mode -- there must be no spaces between its arguments, and for nested - * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also - * concatenate double-quoted strings produced by the __STRING macro, but - * this only works with ANSI C. - * - * __XSTRING is like __STRING, but it expands any macros in its argument - * first. It is only available with ANSI C. - */ -#if defined(__STDC__) || defined(__cplusplus) -#define __P(protos) protos /* full-blown ANSI C */ -#define __CONCAT1(x,y) x ## y -#define __CONCAT(x,y) __CONCAT1(x,y) -#define __STRING(x) #x /* stringify without expanding x */ -#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ - -#define __const const /* define reserved names to standard */ -#define __signed signed -#define __volatile volatile -#if defined(__cplusplus) -#define __inline inline /* convert to C++ keyword */ -#else -#if !(defined(__CC_SUPPORTS___INLINE)) -#define __inline /* delete GCC keyword */ -#endif /* ! __CC_SUPPORTS___INLINE */ -#endif /* !__cplusplus */ - -#else /* !(__STDC__ || __cplusplus) */ -#define __P(protos) () /* traditional C preprocessor */ -#define __CONCAT(x,y) x/**/y -#define __STRING(x) "x" - -#if !defined(__CC_SUPPORTS___INLINE) -#define __const /* delete pseudo-ANSI C keywords */ -#define __inline -#define __signed -#define __volatile -/* - * In non-ANSI C environments, new programs will want ANSI-only C keywords - * deleted from the program and old programs will want them left alone. - * When using a compiler other than gcc, programs using the ANSI C keywords - * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. - * When using "gcc -traditional", we assume that this is the intent; if - * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. - */ -#ifndef NO_ANSI_KEYWORDS -#define const /* delete ANSI C keywords */ -#define inline -#define signed -#define volatile -#endif /* !NO_ANSI_KEYWORDS */ -#endif /* !__CC_SUPPORTS___INLINE */ -#endif /* !(__STDC__ || __cplusplus) */ - -/* - * Compiler-dependent macros to help declare dead (non-returning) and - * pure (no side effects) functions, and unused variables. They are - * null except for versions of gcc that are known to support the features - * properly (old versions of gcc-2 supported the dead and pure features - * in a different (wrong) way). If we do not provide an implementation - * for a given compiler, let the compile fail if it is told to use - * a feature that we cannot live without. - */ -#ifdef lint -#define __dead2 -#define __pure2 -#define __unused -#define __packed -#define __aligned(x) -#define __alloc_align(x) -#define __alloc_size(x) -#define __section(x) -#define __weak_symbol -#else -#define __weak_symbol __attribute__((__weak__)) -#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) -#define __dead2 -#define __pure2 -#define __unused -#endif -#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER) -#define __dead2 __attribute__((__noreturn__)) -#define __pure2 __attribute__((__const__)) -#define __unused -/* XXX Find out what to do for __packed, __aligned and __section */ -#endif -#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER) -#define __dead2 __attribute__((__noreturn__)) -#define __pure2 __attribute__((__const__)) -#define __unused __attribute__((__unused__)) -#define __used __attribute__((__used__)) -#define __packed __attribute__((__packed__)) -#define __aligned(x) __attribute__((__aligned__(x))) -#define __section(x) __attribute__((__section__(x))) -#endif -#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__) -#define __alloc_size(x) __attribute__((__alloc_size__(x))) -#else -#define __alloc_size(x) -#endif -#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__) -#define __alloc_align(x) __attribute__((__alloc_align__(x))) -#else -#define __alloc_align(x) -#endif -#endif /* lint */ - -#if !__GNUC_PREREQ__(2, 95) -#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) -#endif - -/* - * Keywords added in C11. - */ - -#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint) - -#if !__has_extension(c_alignas) -#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ - __has_extension(cxx_alignas) -#define _Alignas(x) alignas(x) -#else -/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */ -#define _Alignas(x) __aligned(x) -#endif -#endif - -#if defined(__cplusplus) && __cplusplus >= 201103L -#define _Alignof(x) alignof(x) -#else -#define _Alignof(x) __alignof(x) -#endif - -#if !defined(__cplusplus) && !__has_extension(c_atomic) && \ - !__has_extension(cxx_atomic) -/* - * No native support for _Atomic(). Place object in structure to prevent - * most forms of direct non-atomic access. - */ -#define _Atomic(T) struct { T volatile __val; } -#endif - -#if defined(__cplusplus) && __cplusplus >= 201103L -#define _Noreturn [[noreturn]] -#else -#define _Noreturn __dead2 -#endif - -#if !__has_extension(c_static_assert) -#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ - __has_extension(cxx_static_assert) -#define _Static_assert(x, y) static_assert(x, y) -#elif __GNUC_PREREQ__(4,6) -/* Nothing, gcc 4.6 and higher has _Static_assert built-in */ -#elif defined(__COUNTER__) -#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) -#define __Static_assert(x, y) ___Static_assert(x, y) -#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \ - __unused -#else -#define _Static_assert(x, y) struct __hack -#endif -#endif - -#if !__has_extension(c_thread_local) -/* - * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode - * without actually supporting the thread_local keyword. Don't check for - * the presence of C++11 when defining _Thread_local. - */ -#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ - __has_extension(cxx_thread_local) -#define _Thread_local thread_local -#else -#define _Thread_local __thread -#endif -#endif - -#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */ - -/* - * Emulation of C11 _Generic(). Unlike the previously defined C11 - * keywords, it is not possible to implement this using exactly the same - * syntax. Therefore implement something similar under the name - * __generic(). Unlike _Generic(), this macro can only distinguish - * between a single type, so it requires nested invocations to - * distinguish multiple cases. - */ - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ - __has_extension(c_generic_selections) -#define __generic(expr, t, yes, no) \ - _Generic(expr, t: yes, default: no) -#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) -#define __generic(expr, t, yes, no) \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(__typeof(expr), t), yes, no) -#endif - -/* - * C99 Static array indices in function parameter declarations. Syntax such as: - * void bar(int myArray[static 10]); - * is allowed in C99 but not in C++. Define __min_size appropriately so - * headers using it can be compiled in either language. Use like this: - * void bar(int myArray[__min_size(10)]); - */ -#if !defined(__cplusplus) && \ - (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \ - (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901)) -#define __min_size(x) static (x) -#else -#define __min_size(x) (x) -#endif - -#if __GNUC_PREREQ__(2, 96) -#define __malloc_like __attribute__((__malloc__)) -#define __pure __attribute__((__pure__)) -#else -#define __malloc_like -#define __pure -#endif - -#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) -#define __always_inline __attribute__((__always_inline__)) -#else -#define __always_inline -#endif - -#if __GNUC_PREREQ__(3, 1) -#define __noinline __attribute__ ((__noinline__)) -#else -#define __noinline -#endif - -#if __GNUC_PREREQ__(3, 3) -#define __nonnull(x) __attribute__((__nonnull__(x))) -#define __nonnull_all __attribute__((__nonnull__)) -#else -#define __nonnull(x) -#define __nonnull_all -#endif - -#if __GNUC_PREREQ__(3, 4) -#define __fastcall __attribute__((__fastcall__)) -#define __result_use_check __attribute__((__warn_unused_result__)) -#else -#define __fastcall -#define __result_use_check -#endif - -#if __GNUC_PREREQ__(4, 1) -#define __returns_twice __attribute__((__returns_twice__)) -#else -#define __returns_twice -#endif - -#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable) -#define __unreachable() __builtin_unreachable() -#else -#define __unreachable() ((void)0) -#endif - -/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ -#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) -#define __func__ NULL -#endif - -#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 -#define __LONG_LONG_SUPPORTED -#endif - -/* C++11 exposes a load of C99 stuff */ -#if defined(__cplusplus) && __cplusplus >= 201103L -#define __LONG_LONG_SUPPORTED -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#ifndef __STDC_CONSTANT_MACROS -#define __STDC_CONSTANT_MACROS -#endif -#endif - -/* - * GCC 2.95 provides `__restrict' as an extension to C90 to support the - * C99-specific `restrict' type qualifier. We happen to use `__restrict' as - * a way to define the `restrict' type qualifier without disturbing older - * software that is unaware of C99 keywords. - */ -#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) -#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint) -#define __restrict -#else -#define __restrict restrict -#endif -#endif - -/* - * GNU C version 2.96 adds explicit branch prediction so that - * the CPU back-end can hint the processor and also so that - * code blocks can be reordered such that the predicted path - * sees a more linear flow, thus improving cache behavior, etc. - * - * The following two macros provide us with a way to utilize this - * compiler feature. Use __predict_true() if you expect the expression - * to evaluate to true, and __predict_false() if you expect the - * expression to evaluate to false. - * - * A few notes about usage: - * - * * Generally, __predict_false() error condition checks (unless - * you have some _strong_ reason to do otherwise, in which case - * document it), and/or __predict_true() `no-error' condition - * checks, assuming you want to optimize for the no-error case. - * - * * Other than that, if you don't know the likelihood of a test - * succeeding from empirical or other `hard' evidence, don't - * make predictions. - * - * * These are meant to be used in places that are run `a lot'. - * It is wasteful to make predictions in code that is run - * seldomly (e.g. at subsystem initialization time) as the - * basic block reordering that this affects can often generate - * larger code. - */ -#if __GNUC_PREREQ__(2, 96) -#define __predict_true(exp) __builtin_expect((exp), 1) -#define __predict_false(exp) __builtin_expect((exp), 0) -#else -#define __predict_true(exp) (exp) -#define __predict_false(exp) (exp) -#endif - -#if __GNUC_PREREQ__(4, 0) -#define __null_sentinel __attribute__((__sentinel__)) -#define __exported __attribute__((__visibility__("default"))) -#define __hidden __attribute__((__visibility__("hidden"))) -#else -#define __null_sentinel -#define __exported -#define __hidden -#endif - -/* - * We define this here since , , and - * require it. - */ -#if __GNUC_PREREQ__(4, 1) -#define __offsetof(type, field) __builtin_offsetof(type, field) -#else -#ifndef __cplusplus -#define __offsetof(type, field) \ - ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) -#else -#define __offsetof(type, field) \ - (__offsetof__ (reinterpret_cast <__size_t> \ - (&reinterpret_cast \ - (static_cast (0)->field)))) -#endif -#endif -#define __rangeof(type, start, end) \ - (__offsetof(type, end) - __offsetof(type, start)) - -/* - * Given the pointer x to the member m of the struct s, return - * a pointer to the containing structure. When using GCC, we first - * assign pointer x to a local variable, to check that its type is - * compatible with member m. - */ -#if __GNUC_PREREQ__(3, 1) -#define __containerof(x, s, m) ({ \ - const volatile __typeof(((s *)0)->m) *__x = (x); \ - __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ -}) -#else -#define __containerof(x, s, m) \ - __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) -#endif - -/* - * Compiler-dependent macros to declare that functions take printf-like - * or scanf-like arguments. They are null except for versions of gcc - * that are known to support the features properly (old versions of gcc-2 - * didn't permit keeping the keywords out of the application namespace). - */ -#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) -#define __printflike(fmtarg, firstvararg) -#define __scanflike(fmtarg, firstvararg) -#define __format_arg(fmtarg) -#define __strfmonlike(fmtarg, firstvararg) -#define __strftimelike(fmtarg, firstvararg) -#else -#define __printflike(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf__, fmtarg, firstvararg))) -#define __scanflike(fmtarg, firstvararg) \ - __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) -#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) -#define __strfmonlike(fmtarg, firstvararg) \ - __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) -#define __strftimelike(fmtarg, firstvararg) \ - __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) -#endif - -/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ -#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ - defined(__GNUC__) && !defined(__INTEL_COMPILER) -#define __printf0like(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) -#else -#define __printf0like(fmtarg, firstvararg) -#endif - -#if defined(__GNUC__) || defined(__INTEL_COMPILER) -#ifndef __INTEL_COMPILER -#define __strong_reference(sym,aliassym) \ - extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) -#endif -#ifdef __STDC__ -#define __weak_reference(sym,alias) \ - __asm__(".weak " #alias); \ - __asm__(".equ " #alias ", " #sym) -#define __warn_references(sym,msg) \ - __asm__(".section .gnu.warning." #sym); \ - __asm__(".asciz \"" msg "\""); \ - __asm__(".previous") -#define __sym_compat(sym,impl,verid) \ - __asm__(".symver " #impl ", " #sym "@" #verid) -#define __sym_default(sym,impl,verid) \ - __asm__(".symver " #impl ", " #sym "@@" #verid) -#else -#define __weak_reference(sym,alias) \ - __asm__(".weak alias"); \ - __asm__(".equ alias, sym") -#define __warn_references(sym,msg) \ - __asm__(".section .gnu.warning.sym"); \ - __asm__(".asciz \"msg\""); \ - __asm__(".previous") -#define __sym_compat(sym,impl,verid) \ - __asm__(".symver impl, sym@verid") -#define __sym_default(impl,sym,verid) \ - __asm__(".symver impl, sym@@verid") -#endif /* __STDC__ */ -#endif /* __GNUC__ || __INTEL_COMPILER */ - -#define __GLOBL1(sym) __asm__(".globl " #sym) -#define __GLOBL(sym) __GLOBL1(sym) - -#if defined(__GNUC__) || defined(__INTEL_COMPILER) -#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"") -#else -/* - * The following definition might not work well if used in header files, - * but it should be better than nothing. If you want a "do nothing" - * version, then it should generate some harmless declaration, such as: - * #define __IDSTRING(name,string) struct __hack - */ -#define __IDSTRING(name,string) static const char name[] __unused = string -#endif - -/* - * Embed the rcs id of a source file in the resulting library. Note that in - * more recent ELF binutils, we use .ident allowing the ID to be stripped. - * Usage: - * __FBSDID("$FreeBSD: releng/11.1/sys/sys/cdefs.h 317342 2017-04-23 20:32:46Z kib $"); - */ -#ifndef __FBSDID -#if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) -#else -#define __FBSDID(s) struct __hack -#endif -#endif - -#ifndef __RCSID -#ifndef NO__RCSID -#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) -#else -#define __RCSID(s) struct __hack -#endif -#endif - -#ifndef __RCSID_SOURCE -#ifndef NO__RCSID_SOURCE -#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s) -#else -#define __RCSID_SOURCE(s) struct __hack -#endif -#endif - -#ifndef __SCCSID -#ifndef NO__SCCSID -#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s) -#else -#define __SCCSID(s) struct __hack -#endif -#endif - -#ifndef __COPYRIGHT -#ifndef NO__COPYRIGHT -#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s) -#else -#define __COPYRIGHT(s) struct __hack -#endif -#endif - -#ifndef __DECONST -#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) -#endif - -#ifndef __DEVOLATILE -#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) -#endif - -#ifndef __DEQUALIFY -#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) -#endif - -/*- - * The following definitions are an extension of the behavior originally - * implemented in , but with a different level of granularity. - * POSIX.1 requires that the macros we test be defined before any standard - * header file is included. - * - * Here's a quick run-down of the versions: - * defined(_POSIX_SOURCE) 1003.1-1988 - * _POSIX_C_SOURCE == 1 1003.1-1990 - * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option - * _POSIX_C_SOURCE == 199309 1003.1b-1993 - * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, - * and the omnibus ISO/IEC 9945-1: 1996 - * _POSIX_C_SOURCE == 200112 1003.1-2001 - * _POSIX_C_SOURCE == 200809 1003.1-2008 - * - * In addition, the X/Open Portability Guide, which is now the Single UNIX - * Specification, defines a feature-test macro which indicates the version of - * that specification, and which subsumes _POSIX_C_SOURCE. - * - * Our macros begin with two underscores to avoid namespace screwage. - */ - -/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 -#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ -#define _POSIX_C_SOURCE 199009 -#endif - -/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 199209 -#endif - -/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ -#ifdef _XOPEN_SOURCE -#if _XOPEN_SOURCE - 0 >= 700 -#define __XSI_VISIBLE 700 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809 -#elif _XOPEN_SOURCE - 0 >= 600 -#define __XSI_VISIBLE 600 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200112 -#elif _XOPEN_SOURCE - 0 >= 500 -#define __XSI_VISIBLE 500 -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 199506 -#endif -#endif - -/* - * Deal with all versions of POSIX. The ordering relative to the tests above is - * important. - */ -#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) -#define _POSIX_C_SOURCE 198808 -#endif -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >= 200809 -#define __POSIX_VISIBLE 200809 -#define __ISO_C_VISIBLE 1999 -#elif _POSIX_C_SOURCE >= 200112 -#define __POSIX_VISIBLE 200112 -#define __ISO_C_VISIBLE 1999 -#elif _POSIX_C_SOURCE >= 199506 -#define __POSIX_VISIBLE 199506 -#define __ISO_C_VISIBLE 1990 -#elif _POSIX_C_SOURCE >= 199309 -#define __POSIX_VISIBLE 199309 -#define __ISO_C_VISIBLE 1990 -#elif _POSIX_C_SOURCE >= 199209 -#define __POSIX_VISIBLE 199209 -#define __ISO_C_VISIBLE 1990 -#elif _POSIX_C_SOURCE >= 199009 -#define __POSIX_VISIBLE 199009 -#define __ISO_C_VISIBLE 1990 -#else -#define __POSIX_VISIBLE 198808 -#define __ISO_C_VISIBLE 0 -#endif /* _POSIX_C_SOURCE */ -#else -/*- - * Deal with _ANSI_SOURCE: - * If it is defined, and no other compilation environment is explicitly - * requested, then define our internal feature-test macros to zero. This - * makes no difference to the preprocessor (undefined symbols in preprocessing - * expressions are defined to have value zero), but makes it more convenient for - * a test program to print out the values. - * - * If a program mistakenly defines _ANSI_SOURCE and some other macro such as - * _POSIX_C_SOURCE, we will assume that it wants the broader compilation - * environment (and in fact we will never get here). - */ -#if defined(_ANSI_SOURCE) /* Hide almost everything. */ -#define __POSIX_VISIBLE 0 -#define __XSI_VISIBLE 0 -#define __BSD_VISIBLE 0 -#define __ISO_C_VISIBLE 1990 -#define __EXT1_VISIBLE 0 -#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ -#define __POSIX_VISIBLE 0 -#define __XSI_VISIBLE 0 -#define __BSD_VISIBLE 0 -#define __ISO_C_VISIBLE 1999 -#define __EXT1_VISIBLE 0 -#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ -#define __POSIX_VISIBLE 0 -#define __XSI_VISIBLE 0 -#define __BSD_VISIBLE 0 -#define __ISO_C_VISIBLE 2011 -#define __EXT1_VISIBLE 0 -#else /* Default environment: show everything. */ -#define __POSIX_VISIBLE 200809 -#define __XSI_VISIBLE 700 -#define __BSD_VISIBLE 1 -#define __ISO_C_VISIBLE 2011 -#define __EXT1_VISIBLE 1 -#endif -#endif - -/* User override __EXT1_VISIBLE */ -#if defined(__STDC_WANT_LIB_EXT1__) -#undef __EXT1_VISIBLE -#if __STDC_WANT_LIB_EXT1__ -#define __EXT1_VISIBLE 1 -#else -#define __EXT1_VISIBLE 0 -#endif -#endif /* __STDC_WANT_LIB_EXT1__ */ - -#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__) -#define __NO_TLS 1 -#endif - -/* - * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h - * translates them to __ARM_ARCH and the modern feature symbols defined by ARM. - */ -#if defined(__arm__) && !defined(__ARM_ARCH) -#include -#endif - -/* - * Nullability qualifiers: currently only supported by Clang. - */ -#if !(defined(__clang__) && __has_feature(nullability)) -#define _Nonnull -#define _Nullable -#define _Null_unspecified -#define __NULLABILITY_PRAGMA_PUSH -#define __NULLABILITY_PRAGMA_POP -#else -#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"") -#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop") -#endif - -/* - * Type Safety Checking - * - * Clang provides additional attributes to enable checking type safety - * properties that cannot be enforced by the C type system. - */ - -#if __has_attribute(__argument_with_type_tag__) && \ - __has_attribute(__type_tag_for_datatype__) && !defined(lint) -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \ - __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx))) -#define __datatype_type_tag(kind, type) \ - __attribute__((__type_tag_for_datatype__(kind, type))) -#else -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) -#define __datatype_type_tag(kind, type) -#endif - -/* - * Lock annotations. - * - * Clang provides support for doing basic thread-safety tests at - * compile-time, by marking which locks will/should be held when - * entering/leaving a functions. - * - * Furthermore, it is also possible to annotate variables and structure - * members to enforce that they are only accessed when certain locks are - * held. - */ - -#if __has_extension(c_thread_safety_attributes) -#define __lock_annotate(x) __attribute__((x)) -#else -#define __lock_annotate(x) -#endif - -/* Structure implements a lock. */ -#define __lockable __lock_annotate(lockable) - -/* Function acquires an exclusive or shared lock. */ -#define __locks_exclusive(...) \ - __lock_annotate(exclusive_lock_function(__VA_ARGS__)) -#define __locks_shared(...) \ - __lock_annotate(shared_lock_function(__VA_ARGS__)) - -/* Function attempts to acquire an exclusive or shared lock. */ -#define __trylocks_exclusive(...) \ - __lock_annotate(exclusive_trylock_function(__VA_ARGS__)) -#define __trylocks_shared(...) \ - __lock_annotate(shared_trylock_function(__VA_ARGS__)) - -/* Function releases a lock. */ -#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__)) - -/* Function asserts that an exclusive or shared lock is held. */ -#define __asserts_exclusive(...) \ - __lock_annotate(assert_exclusive_lock(__VA_ARGS__)) -#define __asserts_shared(...) \ - __lock_annotate(assert_shared_lock(__VA_ARGS__)) - -/* Function requires that an exclusive or shared lock is or is not held. */ -#define __requires_exclusive(...) \ - __lock_annotate(exclusive_locks_required(__VA_ARGS__)) -#define __requires_shared(...) \ - __lock_annotate(shared_locks_required(__VA_ARGS__)) -#define __requires_unlocked(...) \ - __lock_annotate(locks_excluded(__VA_ARGS__)) - -/* Function should not be analyzed. */ -#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis) - -/* Guard variables and structure members by lock. */ -#define __guarded_by(x) __lock_annotate(guarded_by(x)) -#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x)) - -#endif /* !_SYS_CDEFS_H_ */ diff --git a/include/sys/descrip.h b/include/sys/descrip.h deleted file mode 100644 index 67f8e88..0000000 --- a/include/sys/descrip.h +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _KERN_DESCRIP_H -#define _KERN_DESCRIP_H - -#include -#include - -#include -#include - -/* Limits */ -#define MAX_FILES 256 - -typedef __mode_t mode_t; -typedef __nlink_t nlink_t; - -/* command values */ -#define F_DUPFD 0 /* duplicate file descriptor */ -#define F_GETFD 1 /* get file descriptor flags */ -#define F_SETFD 2 /* set file descriptor flags */ -#define F_GETFL 3 /* get file status flags */ -#define F_SETFL 4 /* set file status flags */ -#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ -#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ -#define F_GETLK 7 /* get record locking information */ -#define F_SETLK 8 /* set record locking information */ -#define F_SETLKW 9 /* F_SETLK; wait if blocked */ - -/* Flag Values */ -#define FREAD 0x0001 -#define FWRITE 0x0002 -#define O_NONBLOCK 0x0004 /* no delay */ -#define O_APPEND 0x0008 /* set append mode */ -#define O_SHLOCK 0x0010 /* open with shared file lock */ -#define O_EXLOCK 0x0020 /* open with exclusive file lock */ -#define O_ASYNC 0x0040 /* signal pgrp when data ready */ -#define O_FSYNC 0x0080 /* synchronous writes */ -#define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ -#define O_NOFOLLOW 0x0100 /* don't follow symlinks */ -#define O_CREAT 0x0200 /* create if nonexistent */ -#define O_TRUNC 0x0400 /* truncate to zero length */ -#define O_EXCL 0x0800 /* error if already exists */ -#define O_DIRECT 0x00010000 -#define O_RDONLY 0x0000 /* open for reading only */ -#define O_WRONLY 0x0001 /* open for writing only */ -#define O_RDWR 0x0002 /* open for reading and writing */ -#define O_ACCMODE 0x0003 /* mask for above modes */ - -#define FHASLOCK 0x4000 /* descriptor holds advisory lock */ - -/* F MAPPERS */ -#define FAPPEND O_APPEND /* kernel/compat */ -#define FASYNC O_ASYNC /* kernel/compat */ -#define FFSYNC O_FSYNC /* kernel */ -#define FNONBLOCK O_NONBLOCK /* kernel */ -#define FNDELAY O_NONBLOCK /* compat */ -#define O_NDELAY O_NONBLOCK /* compat */ -#define FPOSIXSHM O_NOFOLLOW - -#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT) - -#define FFLAGS(oflags) ((oflags) + 1) -#define OFLAGS(fflags) ((fflags) - 1) - -struct fileOps; -struct file; -struct uio; //TMP -struct ucred; //TMP - -/* Function Protos */ -typedef int fo_rdwr_t(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td); -typedef int fo_stat_t(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td); -typedef int fo_close_t(struct file *fp, struct thread *td); - -struct ucred { - char pad; -}; - -struct uio { - char pad; -}; - -struct file { - uint32_t f_flag; - uint16_t f_type; - struct fileOps *f_ops; - fileDescriptor_t *fd; - int fd_type; - int socket; -}; - -struct fileOps { - fo_rdwr_t *read; - fo_rdwr_t *write; - fo_stat_t *stat; - fo_close_t *close; -}; - -#ifdef _BALLS -struct stat { - __dev_t st_dev; /* inode's device */ - ino_t st_ino; /* inode's number */ - mode_t st_mode; /* inode protection mode */ - nlink_t st_nlink; /* number of hard links */ - uid_t st_uid; /* user ID of the file's owner */ - gid_t st_gid; /* group ID of the file's group */ - __dev_t st_rdev; /* device type */ -#if __BSD_VISIBLE - struct timespec st_atimespec; /* time of last access */ - struct timespec st_mtimespec; /* time of last data modification */ - struct timespec st_ctimespec; /* time of last file status change */ -#else - time_t st_atime; /* time of last access */ - long __st_atimensec; /* nsec of last access */ - time_t st_mtime; /* time of last data modification */ - long __st_mtimensec; /* nsec of last data modification */ - time_t st_ctime; /* time of last file status change */ - long __st_ctimensec; /* nsec of last file status change */ -#endif - off_t st_size; /* file size, in bytes */ - blkcnt_t st_blocks; /* blocks allocated for file */ - blksize_t st_blksize; /* optimal blocksize for I/O */ - fflags_t st_flags; /* user defined flags for file */ - __uint32_t st_gen; /* file generation number */ - __int32_t st_lspare; -#if __BSD_VISIBLE - struct timespec st_birthtimespec; /* time of file creation */ - /* - * Explicitly pad st_birthtimespec to 16 bytes so that the size of - * struct stat is backwards compatible. We use bitfields instead - * of an array of chars so that this doesn't require a C99 compiler - * to compile if the size of the padding is 0. We use 2 bitfields - * to cover up to 64 bits on 32-bit machines. We assume that - * CHAR_BIT is 8... - */ - unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); - unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); -#else - time_t st_birthtime; /* time of file creation */ - long st_birthtimensec; /* nsec of file creation */ - unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); - unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); -#endif -}; -#endif - -int fcntl(struct thread *, struct fcntl_args *); -int close(struct thread *, struct close_args *); -int falloc(struct thread *, struct file **, int *); -int getdtablesize(struct thread *, struct getdtablesize_args *); -int fstat(struct thread *, struct sys_fstat_args *); -int ioctl(struct thread *, struct ioctl_args *); -int getfd(struct thread *td, struct file **fp, int fd); - -#endif - -/*** - END - ***/ diff --git a/include/sys/device.h b/include/sys/device.h deleted file mode 100644 index 3dc5d70..0000000 --- a/include/sys/device.h +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_DEVICE_H -#define _SYS_DEVICE_H - -#include - -struct device_node { - struct device_node *prev; - struct device_node *next; - struct device_interface *devInfo; - struct device_resource *devRec; - char type; - int minor; -}; - -struct device_resource { - uInt8 irq; -}; - -struct device_interface { - uInt8 initialized; - uInt32 size; - int major; - void *info; - int (*read)(void *, void *, uInt32, uInt32); - int (*write)(void *, void *, uInt32, uInt32); - void (*reset)(void *); - int (*init)(void *); - void (*ioctl)(void *); - void (*stop)(void *); - void (*start)(void *); - void (*standby)(void *); -}; - -int device_add(int, char, struct device_interface *); -struct device_node *device_find(int major, int minor); -int device_remove(struct device_node *); - -#endif /* END _SYS_DEVICE_H */ diff --git a/include/sys/device.old.h b/include/sys/device.old.h deleted file mode 100644 index 27641cd..0000000 --- a/include/sys/device.old.h +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DEVICE_H -#define _DEVICE_H - -#include - -struct device { - struct net *net; - uInt16 ioAddr; - uInt32 irq; - struct ei_device *priv; - uInt32 mtu; - }; - -struct net { - char mac[6]; - char broadcast[6]; - }; - -struct ei_device { - int txStartPage; - int rxStartPage; - int stopPage; - int currentPage; - uInt16 word16; - uInt32 pingPong; - int tx1; - int tx2; - }; - -#endif - -/*** - END - ***/ - diff --git a/include/sys/dma.h b/include/sys/dma.h deleted file mode 100644 index b2ca5ed..0000000 --- a/include/sys/dma.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_DMA_H -#define _SYS_DMA_H - -#include - -void dmaXfer(uInt8 channel, uInt32 address, uInt length, uInt8 read); -void _dmaXfer(uInt8 dmaChannel, uInt8 page, uInt offset, uInt length, uInt8 mode); - -#endif /* END _SYS_DMA_H */ diff --git a/include/sys/driver.h b/include/sys/driver.h deleted file mode 100644 index b0b16ff..0000000 --- a/include/sys/driver.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_DRIVER_H -#define _SYS_DRIVER_H - -#include - -typedef struct devMethodType devMethod; - -struct devMethodType { -}; - -struct driverType { - const char *devName; - devMethod *methods; -} - -#endif /* END _SYS_DRIVER_H */ diff --git a/include/sys/elf.h b/include/sys/elf.h deleted file mode 100644 index ac3a614..0000000 --- a/include/sys/elf.h +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF_H_ -#define _SYS_ELF_H_ 1 - -#define __i386__ 1 - -#include -#include -#include -#include - -typedef struct elf_file { - int preloaded; /* Was file pre-loaded */ - caddr_t address; /* Relocation address */ - Elf_Dyn *dynamic; /* Symbol table etc. */ - Elf_Hashelt nbuckets; /* DT_HASH info */ - Elf_Hashelt nchains; - const Elf_Hashelt *buckets; - const Elf_Hashelt *chains; - caddr_t hash; - caddr_t strtab; /* DT_STRTAB */ - int strsz; /* DT_STRSZ */ - const Elf_Sym *symtab; /* DT_SYMTAB */ - Elf_Addr *got; /* DT_PLTGOT */ - const Elf_Rel *pltrel; /* DT_JMPREL */ - int pltrelsize; /* DT_PLTRELSZ */ - const Elf_Rela *pltrela; /* DT_JMPREL */ - int pltrelasize; /* DT_PLTRELSZ */ - const Elf_Rel *rel; /* DT_REL */ - int relsize; /* DT_RELSZ */ - const Elf_Rela *rela; /* DT_RELA */ - int relasize; /* DT_RELASZ */ - caddr_t modptr; - const Elf_Sym *ddbsymtab; /* The symbol table we are using */ - long ddbsymcnt; /* Number of symbols */ - caddr_t ddbstrtab; /* String table */ - long ddbstrcnt; /* number of bytes in string table */ - caddr_t symbase; /* malloc'ed symbold base */ - caddr_t strbase; /* malloc'ed string base */ - caddr_t ctftab; /* CTF table */ - long ctfcnt; /* number of bytes in CTF table */ - caddr_t ctfoff; /* CTF offset table */ - caddr_t typoff; /* Type offset table */ - long typlen; /* Number of type entries. */ - Elf_Addr pcpu_start; /* Pre-relocation pcpu set start. */ - Elf_Addr pcpu_stop; /* Pre-relocation pcpu set stop. */ - Elf_Addr pcpu_base; /* Relocated pcpu set address. */ -} *elf_file_t; - - -#include - -#define elfExecutable 0x002 -#define elfLibrary 0x003 - -char *elfGetShType( int ); -char *elfGetPhType( int ); -char *elfGetRelType( int ); - -int elf_load_file( kTask_t *p, const char *file, uint32_t *addr, uint32_t *entry ); - -#endif /* END _SYS_ELF_H */ diff --git a/include/sys/elf32.h b/include/sys/elf32.h deleted file mode 100644 index d19803e..0000000 --- a/include/sys/elf32.h +++ /dev/null @@ -1,259 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF32_H_ -#define _SYS_ELF32_H_ 1 - -#include - -/* - * ELF definitions common to all 32-bit architectures. - */ - -typedef uint32_t Elf32_Addr; -typedef uint16_t Elf32_Half; -typedef uint32_t Elf32_Off; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf32_Word; -typedef uint64_t Elf32_Lword; - -typedef Elf32_Word Elf32_Hashelt; - -/* Non-standard class-dependent datatype used for abstraction. */ -typedef Elf32_Word Elf32_Size; -typedef Elf32_Sword Elf32_Ssize; - -/* - * ELF header. - */ - -typedef struct { - unsigned char e_ident[EI_NIDENT]; /* File identification. */ - Elf32_Half e_type; /* File type. */ - Elf32_Half e_machine; /* Machine architecture. */ - Elf32_Word e_version; /* ELF format version. */ - Elf32_Addr e_entry; /* Entry point. */ - Elf32_Off e_phoff; /* Program header file offset. */ - Elf32_Off e_shoff; /* Section header file offset. */ - Elf32_Word e_flags; /* Architecture-specific flags. */ - Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ - Elf32_Half e_phentsize; /* Size of program header entry. */ - Elf32_Half e_phnum; /* Number of program header entries. */ - Elf32_Half e_shentsize; /* Size of section header entry. */ - Elf32_Half e_shnum; /* Number of section header entries. */ - Elf32_Half e_shstrndx; /* Section name strings section. */ -} Elf32_Ehdr; - -/* - * Shared object information, found in SHT_MIPS_LIBLIST. - */ - -typedef struct { - Elf32_Word l_name; /* The name of a shared object. */ - Elf32_Word l_time_stamp; /* 32-bit timestamp. */ - Elf32_Word l_checksum; /* Checksum of visible symbols, sizes. */ - Elf32_Word l_version; /* Interface version string index. */ - Elf32_Word l_flags; /* Flags (LL_*). */ -} Elf32_Lib; - -/* - * Section header. - */ - -typedef struct { - Elf32_Word sh_name; /* Section name (index into the - section header string table). */ - Elf32_Word sh_type; /* Section type. */ - Elf32_Word sh_flags; /* Section flags. */ - Elf32_Addr sh_addr; /* Address in memory image. */ - Elf32_Off sh_offset; /* Offset in file. */ - Elf32_Word sh_size; /* Size in bytes. */ - Elf32_Word sh_link; /* Index of a related section. */ - Elf32_Word sh_info; /* Depends on section type. */ - Elf32_Word sh_addralign; /* Alignment in bytes. */ - Elf32_Word sh_entsize; /* Size of each entry in section. */ -} Elf32_Shdr; - -/* - * Program header. - */ - -typedef struct { - Elf32_Word p_type; /* Entry type. */ - Elf32_Off p_offset; /* File offset of contents. */ - Elf32_Addr p_vaddr; /* Virtual address in memory image. */ - Elf32_Addr p_paddr; /* Physical address (not used). */ - Elf32_Word p_filesz; /* Size of contents in file. */ - Elf32_Word p_memsz; /* Size of contents in memory. */ - Elf32_Word p_flags; /* Access permission flags. */ - Elf32_Word p_align; /* Alignment in memory and file. */ -} Elf32_Phdr; - -/* - * Dynamic structure. The ".dynamic" section contains an array of them. - */ - -typedef struct { - Elf32_Sword d_tag; /* Entry type. */ - union { - Elf32_Word d_val; /* Integer value. */ - Elf32_Addr d_ptr; /* Address value. */ - } d_un; -} Elf32_Dyn; - -/* - * Relocation entries. - */ - -/* Relocations that don't need an addend field. */ -typedef struct { - Elf32_Addr r_offset; /* Location to be relocated. */ - Elf32_Word r_info; /* Relocation type and symbol index. */ -} Elf32_Rel; - -/* Relocations that need an addend field. */ -typedef struct { - Elf32_Addr r_offset; /* Location to be relocated. */ - Elf32_Word r_info; /* Relocation type and symbol index. */ - Elf32_Sword r_addend; /* Addend. */ -} Elf32_Rela; - -/* Macros for accessing the fields of r_info. */ -#define ELF32_R_SYM(info) ((info) >> 8) -#define ELF32_R_TYPE(info) ((unsigned char)(info)) - -/* Macro for constructing r_info from field values. */ -#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) - -/* - * Note entry header - */ -typedef Elf_Note Elf32_Nhdr; - -/* - * Move entry - */ -typedef struct { - Elf32_Lword m_value; /* symbol value */ - Elf32_Word m_info; /* size + index */ - Elf32_Word m_poffset; /* symbol offset */ - Elf32_Half m_repeat; /* repeat count */ - Elf32_Half m_stride; /* stride info */ -} Elf32_Move; - -/* - * The macros compose and decompose values for Move.r_info - * - * sym = ELF32_M_SYM(M.m_info) - * size = ELF32_M_SIZE(M.m_info) - * M.m_info = ELF32_M_INFO(sym, size) - */ -#define ELF32_M_SYM(info) ((info)>>8) -#define ELF32_M_SIZE(info) ((unsigned char)(info)) -#define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) - -/* - * Hardware/Software capabilities entry - */ -typedef struct { - Elf32_Word c_tag; /* how to interpret value */ - union { - Elf32_Word c_val; - Elf32_Addr c_ptr; - } c_un; -} Elf32_Cap; - -/* - * Symbol table entries. - */ - -typedef struct { - Elf32_Word st_name; /* String table index of name. */ - Elf32_Addr st_value; /* Symbol value. */ - Elf32_Word st_size; /* Size of associated object. */ - unsigned char st_info; /* Type and binding information. */ - unsigned char st_other; /* Reserved (not used). */ - Elf32_Half st_shndx; /* Section index of symbol. */ -} Elf32_Sym; - -/* Macros for accessing the fields of st_info. */ -#define ELF32_ST_BIND(info) ((info) >> 4) -#define ELF32_ST_TYPE(info) ((info) & 0xf) - -/* Macro for constructing st_info from field values. */ -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -/* Macro for accessing the fields of st_other. */ -#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3) - -/* Structures used by Sun & GNU symbol versioning. */ -typedef struct { - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} Elf32_Verdef; - -typedef struct { - Elf32_Word vda_name; - Elf32_Word vda_next; -} Elf32_Verdaux; - -typedef struct { - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} Elf32_Verneed; - -typedef struct { - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} Elf32_Vernaux; - -typedef Elf32_Half Elf32_Versym; - -typedef struct { - Elf32_Half si_boundto; /* direct bindings - symbol bound to */ - Elf32_Half si_flags; /* per symbol flags */ -} Elf32_Syminfo; - -typedef struct { - Elf32_Word ch_type; - Elf32_Word ch_size; - Elf32_Word ch_addralign; -} Elf32_Chdr; - -#endif /* END _SYS_ELF32_H */ diff --git a/include/sys/elf64.h b/include/sys/elf64.h deleted file mode 100644 index fe825dc..0000000 --- a/include/sys/elf64.h +++ /dev/null @@ -1,267 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF64_H_ -#define _SYS_ELF64_H_ 1 - -#include - -/* - * ELF definitions common to all 64-bit architectures. - */ - -typedef uint64_t Elf64_Addr; -typedef uint16_t Elf64_Half; -typedef uint64_t Elf64_Off; -typedef int32_t Elf64_Sword; -typedef int64_t Elf64_Sxword; -typedef uint32_t Elf64_Word; -typedef uint64_t Elf64_Lword; -typedef uint64_t Elf64_Xword; - -/* - * Types of dynamic symbol hash table bucket and chain elements. - * - * This is inconsistent among 64 bit architectures, so a machine dependent - * typedef is required. - */ - -typedef Elf64_Word Elf64_Hashelt; - -/* Non-standard class-dependent datatype used for abstraction. */ -typedef Elf64_Xword Elf64_Size; -typedef Elf64_Sxword Elf64_Ssize; - -/* - * ELF header. - */ - -typedef struct { - unsigned char e_ident[EI_NIDENT]; /* File identification. */ - Elf64_Half e_type; /* File type. */ - Elf64_Half e_machine; /* Machine architecture. */ - Elf64_Word e_version; /* ELF format version. */ - Elf64_Addr e_entry; /* Entry point. */ - Elf64_Off e_phoff; /* Program header file offset. */ - Elf64_Off e_shoff; /* Section header file offset. */ - Elf64_Word e_flags; /* Architecture-specific flags. */ - Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ - Elf64_Half e_phentsize; /* Size of program header entry. */ - Elf64_Half e_phnum; /* Number of program header entries. */ - Elf64_Half e_shentsize; /* Size of section header entry. */ - Elf64_Half e_shnum; /* Number of section header entries. */ - Elf64_Half e_shstrndx; /* Section name strings section. */ -} Elf64_Ehdr; - -/* - * Shared object information, found in SHT_MIPS_LIBLIST. - */ - -typedef struct { - Elf64_Word l_name; /* The name of a shared object. */ - Elf64_Word l_time_stamp; /* 64-bit timestamp. */ - Elf64_Word l_checksum; /* Checksum of visible symbols, sizes. */ - Elf64_Word l_version; /* Interface version string index. */ - Elf64_Word l_flags; /* Flags (LL_*). */ -} Elf64_Lib; - -/* - * Section header. - */ - -typedef struct { - Elf64_Word sh_name; /* Section name (index into the - section header string table). */ - Elf64_Word sh_type; /* Section type. */ - Elf64_Xword sh_flags; /* Section flags. */ - Elf64_Addr sh_addr; /* Address in memory image. */ - Elf64_Off sh_offset; /* Offset in file. */ - Elf64_Xword sh_size; /* Size in bytes. */ - Elf64_Word sh_link; /* Index of a related section. */ - Elf64_Word sh_info; /* Depends on section type. */ - Elf64_Xword sh_addralign; /* Alignment in bytes. */ - Elf64_Xword sh_entsize; /* Size of each entry in section. */ -} Elf64_Shdr; - -/* - * Program header. - */ - -typedef struct { - Elf64_Word p_type; /* Entry type. */ - Elf64_Word p_flags; /* Access permission flags. */ - Elf64_Off p_offset; /* File offset of contents. */ - Elf64_Addr p_vaddr; /* Virtual address in memory image. */ - Elf64_Addr p_paddr; /* Physical address (not used). */ - Elf64_Xword p_filesz; /* Size of contents in file. */ - Elf64_Xword p_memsz; /* Size of contents in memory. */ - Elf64_Xword p_align; /* Alignment in memory and file. */ -} Elf64_Phdr; - -/* - * Dynamic structure. The ".dynamic" section contains an array of them. - */ - -typedef struct { - Elf64_Sxword d_tag; /* Entry type. */ - union { - Elf64_Xword d_val; /* Integer value. */ - Elf64_Addr d_ptr; /* Address value. */ - } d_un; -} Elf64_Dyn; - -/* - * Relocation entries. - */ - -/* Relocations that don't need an addend field. */ -typedef struct { - Elf64_Addr r_offset; /* Location to be relocated. */ - Elf64_Xword r_info; /* Relocation type and symbol index. */ -} Elf64_Rel; - -/* Relocations that need an addend field. */ -typedef struct { - Elf64_Addr r_offset; /* Location to be relocated. */ - Elf64_Xword r_info; /* Relocation type and symbol index. */ - Elf64_Sxword r_addend; /* Addend. */ -} Elf64_Rela; - -/* Macros for accessing the fields of r_info. */ -#define ELF64_R_SYM(info) ((info) >> 32) -#define ELF64_R_TYPE(info) ((info) & 0xffffffffL) - -/* Macro for constructing r_info from field values. */ -#define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL)) - -#define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40) -#define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56) -#define ELF64_R_TYPE_INFO(data, type) \ - (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) - -/* - * Note entry header - */ -typedef Elf_Note Elf64_Nhdr; - -/* - * Move entry - */ -typedef struct { - Elf64_Lword m_value; /* symbol value */ - Elf64_Xword m_info; /* size + index */ - Elf64_Xword m_poffset; /* symbol offset */ - Elf64_Half m_repeat; /* repeat count */ - Elf64_Half m_stride; /* stride info */ -} Elf64_Move; - -#define ELF64_M_SYM(info) ((info)>>8) -#define ELF64_M_SIZE(info) ((unsigned char)(info)) -#define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) - -/* - * Hardware/Software capabilities entry - */ -typedef struct { - Elf64_Xword c_tag; /* how to interpret value */ - union { - Elf64_Xword c_val; - Elf64_Addr c_ptr; - } c_un; -} Elf64_Cap; - -/* - * Symbol table entries. - */ - -typedef struct { - Elf64_Word st_name; /* String table index of name. */ - unsigned char st_info; /* Type and binding information. */ - unsigned char st_other; /* Reserved (not used). */ - Elf64_Half st_shndx; /* Section index of symbol. */ - Elf64_Addr st_value; /* Symbol value. */ - Elf64_Xword st_size; /* Size of associated object. */ -} Elf64_Sym; - -/* Macros for accessing the fields of st_info. */ -#define ELF64_ST_BIND(info) ((info) >> 4) -#define ELF64_ST_TYPE(info) ((info) & 0xf) - -/* Macro for constructing st_info from field values. */ -#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -/* Macro for accessing the fields of st_other. */ -#define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3) - -/* Structures used by Sun & GNU-style symbol versioning. */ -typedef struct { - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} Elf64_Verdef; - -typedef struct { - Elf64_Word vda_name; - Elf64_Word vda_next; -} Elf64_Verdaux; - -typedef struct { - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} Elf64_Verneed; - -typedef struct { - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} Elf64_Vernaux; - -typedef Elf64_Half Elf64_Versym; - -typedef struct { - Elf64_Half si_boundto; /* direct bindings - symbol bound to */ - Elf64_Half si_flags; /* per symbol flags */ -} Elf64_Syminfo; - -typedef struct { - Elf64_Word ch_type; - Elf64_Word ch_reserved; - Elf64_Xword ch_size; - Elf64_Xword ch_addralign; -} Elf64_Chdr; - -#endif /* !_SYS_ELF64_H_ */ diff --git a/include/sys/elf_common.h b/include/sys/elf_common.h deleted file mode 100644 index 8f1cc61..0000000 --- a/include/sys/elf_common.h +++ /dev/null @@ -1,1340 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF_COMMON_H_ -#define _SYS_ELF_COMMON_H_ 1 - -/* - * ELF definitions that are independent of architecture or word size. - */ - -/* - * Note header. The ".note" section contains an array of notes. Each - * begins with this header, aligned to a word boundary. Immediately - * following the note header is n_namesz bytes of name, padded to the - * next word boundary. Then comes n_descsz bytes of descriptor, again - * padded to a word boundary. The values of n_namesz and n_descsz do - * not include the padding. - */ - -typedef struct { - uint32_t n_namesz; /* Length of name. */ - uint32_t n_descsz; /* Length of descriptor. */ - uint32_t n_type; /* Type of this note. */ -} Elf_Note; - -/* - * Option kinds. - */ -#define ODK_NULL 0 /* undefined */ -#define ODK_REGINFO 1 /* register usage info */ -#define ODK_EXCEPTIONS 2 /* exception processing info */ -#define ODK_PAD 3 /* section padding */ -#define ODK_HWPATCH 4 /* hardware patch applied */ -#define ODK_FILL 5 /* fill value used by the linker */ -#define ODK_TAGS 6 /* reserved space for tools */ -#define ODK_HWAND 7 /* hardware AND patch applied */ -#define ODK_HWOR 8 /* hardware OR patch applied */ -#define ODK_GP_GROUP 9 /* GP group for text/data sections */ -#define ODK_IDENT 10 /* ID information */ -#define ODK_PAGESIZE 11 /* page size information */ - -/* - * ODK_EXCEPTIONS info field masks. - */ -#define OEX_FPU_MIN 0x0000001f /* min FPU exception required */ -#define OEX_FPU_MAX 0x00001f00 /* max FPU exception allowed */ -#define OEX_PAGE0 0x00010000 /* page zero must be mapped */ -#define OEX_SMM 0x00020000 /* run in sequential memory mode */ -#define OEX_PRECISEFP 0x00040000 /* run in precise FP exception mode */ -#define OEX_DISMISS 0x00080000 /* dismiss invalid address traps */ - -/* - * ODK_PAD info field masks. - */ -#define OPAD_PREFIX 0x0001 -#define OPAD_POSTFIX 0x0002 -#define OPAD_SYMBOL 0x0004 - -/* - * ODK_HWPATCH info field masks. - */ -#define OHW_R4KEOP 0x00000001 /* patch for R4000 branch at end-of-page bug */ -#define OHW_R8KPFETCH 0x00000002 /* R8000 prefetch bug may occur */ -#define OHW_R5KEOP 0x00000004 /* patch for R5000 branch at end-of-page bug */ -#define OHW_R5KCVTL 0x00000008 /* R5000 cvt.[ds].l bug: clean == 1 */ -#define OHW_R10KLDL 0x00000010UL /* need patch for R10000 misaligned load */ - -/* - * ODK_HWAND/ODK_HWOR info field and hwp_flags[12] masks. - */ -#define OHWA0_R4KEOP_CHECKED 0x00000001 /* object checked for R4000 end-of-page bug */ -#define OHWA0_R4KEOP_CLEAN 0x00000002 /* object verified clean for R4000 end-of-page bug */ -#define OHWO0_FIXADE 0x00000001 /* object requires call to fixade */ - -/* - * ODK_IDENT/ODK_GP_GROUP info field masks. - */ -#define OGP_GROUP 0x0000ffff /* GP group number */ -#define OGP_SELF 0x00010000 /* GP group is self-contained */ - -/* - * The header for GNU-style hash sections. - */ - -typedef struct { - uint32_t gh_nbuckets; /* Number of hash buckets. */ - uint32_t gh_symndx; /* First visible symbol in .dynsym. */ - uint32_t gh_maskwords; /* #maskwords used in bloom filter. */ - uint32_t gh_shift2; /* Bloom filter shift count. */ -} Elf_GNU_Hash_Header; - -/* Indexes into the e_ident array. Keep synced with - http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ -#define EI_MAG0 0 /* Magic number, byte 0. */ -#define EI_MAG1 1 /* Magic number, byte 1. */ -#define EI_MAG2 2 /* Magic number, byte 2. */ -#define EI_MAG3 3 /* Magic number, byte 3. */ -#define EI_CLASS 4 /* Class of machine. */ -#define EI_DATA 5 /* Data format. */ -#define EI_VERSION 6 /* ELF format version. */ -#define EI_OSABI 7 /* Operating system / ABI identification */ -#define EI_ABIVERSION 8 /* ABI version */ -#define OLD_EI_BRAND 8 /* Start of architecture identification. */ -#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ -#define EI_NIDENT 16 /* Size of e_ident array. */ - -/* Values for the magic number bytes. */ -#define ELFMAG0 0x7f -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" /* magic string */ -#define SELFMAG 4 /* magic string size */ - -/* Values for e_ident[EI_VERSION] and e_version. */ -#define EV_NONE 0 -#define EV_CURRENT 1 - -/* Values for e_ident[EI_CLASS]. */ -#define ELFCLASSNONE 0 /* Unknown class. */ -#define ELFCLASS32 1 /* 32-bit architecture. */ -#define ELFCLASS64 2 /* 64-bit architecture. */ - -/* Values for e_ident[EI_DATA]. */ -#define ELFDATANONE 0 /* Unknown data format. */ -#define ELFDATA2LSB 1 /* 2's complement little-endian. */ -#define ELFDATA2MSB 2 /* 2's complement big-endian. */ - -/* Values for e_ident[EI_OSABI]. */ -#define ELFOSABI_NONE 0 /* UNIX System V ABI */ -#define ELFOSABI_HPUX 1 /* HP-UX operating system */ -#define ELFOSABI_NETBSD 2 /* NetBSD */ -#define ELFOSABI_LINUX 3 /* GNU/Linux */ -#define ELFOSABI_HURD 4 /* GNU/Hurd */ -#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ -#define ELFOSABI_SOLARIS 6 /* Solaris */ -#define ELFOSABI_AIX 7 /* AIX */ -#define ELFOSABI_IRIX 8 /* IRIX */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD */ -#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD */ -#define ELFOSABI_OPENVMS 13 /* Open VMS */ -#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ -#define ELFOSABI_AROS 15 /* Amiga Research OS */ -#define ELFOSABI_FENIXOS 16 /* FenixOS */ -#define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */ -#define ELFOSABI_UBIXOS 18 /* UbixOS */ -#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ -#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ -#define ELFOSABI_GNU ELFOSABI_LINUX - -/* e_ident */ -#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ - (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ - (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ - (ehdr).e_ident[EI_MAG3] == ELFMAG3) - -/* Values for e_type. */ -#define ET_NONE 0 /* Unknown type. */ -#define ET_REL 1 /* Relocatable. */ -#define ET_EXEC 2 /* Executable. */ -#define ET_DYN 3 /* Shared object. */ -#define ET_CORE 4 /* Core file. */ -#define ET_LOOS 0xfe00 /* First operating system specific. */ -#define ET_HIOS 0xfeff /* Last operating system-specific. */ -#define ET_LOPROC 0xff00 /* First processor-specific. */ -#define ET_HIPROC 0xffff /* Last processor-specific. */ - -/* Values for e_machine. */ -#define EM_NONE 0 /* Unknown machine. */ -#define EM_M32 1 /* AT&T WE32100. */ -#define EM_SPARC 2 /* Sun SPARC. */ -#define EM_386 3 /* Intel i386. */ -#define EM_68K 4 /* Motorola 68000. */ -#define EM_88K 5 /* Motorola 88000. */ -#define EM_IAMCU 6 /* Intel MCU. */ -#define EM_860 7 /* Intel i860. */ -#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ -#define EM_S370 9 /* IBM System/370. */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ -#define EM_PARISC 15 /* HP PA-RISC. */ -#define EM_VPP500 17 /* Fujitsu VPP500. */ -#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ -#define EM_960 19 /* Intel 80960. */ -#define EM_PPC 20 /* PowerPC 32-bit. */ -#define EM_PPC64 21 /* PowerPC 64-bit. */ -#define EM_S390 22 /* IBM System/390. */ -#define EM_V800 36 /* NEC V800. */ -#define EM_FR20 37 /* Fujitsu FR20. */ -#define EM_RH32 38 /* TRW RH-32. */ -#define EM_RCE 39 /* Motorola RCE. */ -#define EM_ARM 40 /* ARM. */ -#define EM_SH 42 /* Hitachi SH. */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ -#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ -#define EM_ARC 45 /* Argonaut RISC Core. */ -#define EM_H8_300 46 /* Hitachi H8/300. */ -#define EM_H8_300H 47 /* Hitachi H8/300H. */ -#define EM_H8S 48 /* Hitachi H8S. */ -#define EM_H8_500 49 /* Hitachi H8/500. */ -#define EM_IA_64 50 /* Intel IA-64 Processor. */ -#define EM_MIPS_X 51 /* Stanford MIPS-X. */ -#define EM_COLDFIRE 52 /* Motorola ColdFire. */ -#define EM_68HC12 53 /* Motorola M68HC12. */ -#define EM_MMA 54 /* Fujitsu MMA. */ -#define EM_PCP 55 /* Siemens PCP. */ -#define EM_NCPU 56 /* Sony nCPU. */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ -#define EM_STARCORE 58 /* Motorola Star*Core processor. */ -#define EM_ME16 59 /* Toyota ME16 processor. */ -#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ -#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ -#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ -#define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ -#define EM_PDSP 63 /* Sony DSP Processor. */ -#define EM_FX66 66 /* Siemens FX66 microcontroller. */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 - microcontroller. */ -#define EM_ST7 68 /* STmicroelectronics ST7 8-bit - microcontroller. */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */ -#define EM_SVX 73 /* Silicon Graphics SVx. */ -#define EM_ST19 74 /* STMicroelectronics ST19 8-bit mc. */ -#define EM_VAX 75 /* Digital VAX. */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded - processor. */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded - processor. */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor. */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc. */ -#define EM_HUANY 81 /* Harvard University machine-independent - object files. */ -#define EM_PRISM 82 /* SiTera Prism. */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */ -#define EM_FR30 84 /* Fujitsu FR30. */ -#define EM_D10V 85 /* Mitsubishi D10V. */ -#define EM_D30V 86 /* Mitsubishi D30V. */ -#define EM_V850 87 /* NEC v850. */ -#define EM_M32R 88 /* Mitsubishi M32R. */ -#define EM_MN10300 89 /* Matsushita MN10300. */ -#define EM_MN10200 90 /* Matsushita MN10200. */ -#define EM_PJ 91 /* picoJava. */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor. */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */ -#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */ -#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose - Processor. */ -#define EM_NS32K 97 /* National Semiconductor 32000 series. */ -#define EM_TPC 98 /* Tenor Network TPC processor. */ -#define EM_SNP1K 99 /* Trebia SNP 1000 processor. */ -#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */ -#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family. */ -#define EM_MAX 102 /* MAX Processor. */ -#define EM_CR 103 /* National Semiconductor CompactRISC - microprocessor. */ -#define EM_F2MC16 104 /* Fujitsu F2MC16. */ -#define EM_MSP430 105 /* Texas Instruments embedded microcontroller - msp430. */ -#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor. */ -#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */ -#define EM_SEP 108 /* Sharp embedded microprocessor. */ -#define EM_ARCA 109 /* Arca RISC Microprocessor. */ -#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. - and MPRC of Peking University */ -#define EM_AARCH64 183 /* AArch64 (64-bit ARM) */ -#define EM_RISCV 243 /* RISC-V */ - -/* Non-standard or deprecated. */ -#define EM_486 6 /* Intel i486. */ -#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ -#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ -#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ - -/** - * e_flags - */ -#define EF_ARM_RELEXEC 0x1 -#define EF_ARM_HASENTRY 0x2 -#define EF_ARM_SYMSARESORTED 0x4 -#define EF_ARM_DYNSYMSUSESEGIDX 0x8 -#define EF_ARM_MAPSYMSFIRST 0x10 -#define EF_ARM_LE8 0x00400000 -#define EF_ARM_BE8 0x00800000 -#define EF_ARM_EABIMASK 0xFF000000 -#define EF_ARM_EABI_UNKNOWN 0x00000000 -#define EF_ARM_EABI_VER1 0x01000000 -#define EF_ARM_EABI_VER2 0x02000000 -#define EF_ARM_EABI_VER3 0x03000000 -#define EF_ARM_EABI_VER4 0x04000000 -#define EF_ARM_EABI_VER5 0x05000000 -#define EF_ARM_INTERWORK 0x00000004 -#define EF_ARM_APCS_26 0x00000008 -#define EF_ARM_APCS_FLOAT 0x00000010 -#define EF_ARM_PIC 0x00000020 -#define EF_ARM_ALIGN8 0x00000040 -#define EF_ARM_NEW_ABI 0x00000080 -#define EF_ARM_OLD_ABI 0x00000100 -#define EF_ARM_SOFT_FLOAT 0x00000200 -#define EF_ARM_VFP_FLOAT 0x00000400 -#define EF_ARM_MAVERICK_FLOAT 0x00000800 - -#define EF_MIPS_NOREORDER 0x00000001 -#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ -#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ -#define EF_MIPS_UCODE 0x00000010 -#define EF_MIPS_ABI2 0x00000020 /* N32 */ -#define EF_MIPS_OPTIONS_FIRST 0x00000080 -#define EF_MIPS_ARCH_ASE 0x0F000000 /* Architectural extensions */ -#define EF_MIPS_ARCH_ASE_MDMX 0x08000000 /* MDMX multimedia extension */ -#define EF_MIPS_ARCH_ASE_M16 0x04000000 /* MIPS-16 ISA extensions */ -#define EF_MIPS_ARCH 0xF0000000 /* Architecture field */ - -#define EF_PPC_EMB 0x80000000 -#define EF_PPC_RELOCATABLE 0x00010000 -#define EF_PPC_RELOCATABLE_LIB 0x00008000 - -#define EF_SPARC_EXT_MASK 0x00ffff00 -#define EF_SPARC_32PLUS 0x00000100 -#define EF_SPARC_SUN_US1 0x00000200 -#define EF_SPARC_HAL_R1 0x00000200 -#define EF_SPARC_SUN_US3 0x00000800 - -#define EF_SPARCV9_MM 0x00000003 -#define EF_SPARCV9_TSO 0x00000000 -#define EF_SPARCV9_PSO 0x00000001 -#define EF_SPARCV9_RMO 0x00000002 - -/* Special section indexes. */ -#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ -#define SHN_LORESERVE 0xff00 /* First of reserved range. */ -#define SHN_LOPROC 0xff00 /* First processor-specific. */ -#define SHN_HIPROC 0xff1f /* Last processor-specific. */ -#define SHN_LOOS 0xff20 /* First operating system-specific. */ -#define SHN_FBSD_CACHED SHN_LOOS /* Transient, for sys/kern/link_elf_obj - linker only: Cached global in local - symtab. */ -#define SHN_HIOS 0xff3f /* Last operating system-specific. */ -#define SHN_ABS 0xfff1 /* Absolute values. */ -#define SHN_COMMON 0xfff2 /* Common data. */ -#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ -#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ - -/* sh_type */ -#define SHT_NULL 0 /* inactive */ -#define SHT_PROGBITS 1 /* program defined information */ -#define SHT_SYMTAB 2 /* symbol table section */ -#define SHT_STRTAB 3 /* string table section */ -#define SHT_RELA 4 /* relocation section with addends */ -#define SHT_HASH 5 /* symbol hash table section */ -#define SHT_DYNAMIC 6 /* dynamic section */ -#define SHT_NOTE 7 /* note section */ -#define SHT_NOBITS 8 /* no space section */ -#define SHT_REL 9 /* relocation section - no addends */ -#define SHT_SHLIB 10 /* reserved - purpose unknown */ -#define SHT_DYNSYM 11 /* dynamic symbol table section */ -#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ -#define SHT_FINI_ARRAY 15 /* Termination function pointers. */ -#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ -#define SHT_GROUP 17 /* Section group. */ -#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ -#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ -#define SHT_LOSUNW 0x6ffffff4 -#define SHT_SUNW_dof 0x6ffffff4 -#define SHT_SUNW_cap 0x6ffffff5 -#define SHT_GNU_ATTRIBUTES 0x6ffffff5 -#define SHT_SUNW_SIGNATURE 0x6ffffff6 -#define SHT_GNU_HASH 0x6ffffff6 -#define SHT_GNU_LIBLIST 0x6ffffff7 -#define SHT_SUNW_ANNOTATE 0x6ffffff7 -#define SHT_SUNW_DEBUGSTR 0x6ffffff8 -#define SHT_SUNW_DEBUG 0x6ffffff9 -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_SUNW_verdef 0x6ffffffd -#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */ -#define SHT_SUNW_verneed 0x6ffffffe -#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */ -#define SHT_SUNW_versym 0x6fffffff -#define SHT_GNU_versym 0x6fffffff /* Symbol version table */ -#define SHT_HISUNW 0x6fffffff -#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ -#define SHT_LOPROC 0x70000000 /* reserved range for processor */ -#define SHT_X86_64_UNWIND 0x70000001 /* unwind information */ -#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND - -#define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */ -#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking - pre-emption map. */ -#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility - attributes. */ -#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */ -#define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */ -#define SHT_MIPS_LIBLIST 0x70000000 -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 -#define SHT_MIPS_GPTAB 0x70000003 -#define SHT_MIPS_UCODE 0x70000004 -#define SHT_MIPS_DEBUG 0x70000005 -#define SHT_MIPS_REGINFO 0x70000006 -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 -#define SHT_MIPS_ABIFLAGS 0x7000002a - -#define SHT_SPARC_GOTDATA 0x70000000 - -#define SHTORDERED -#define SHT_HIPROC 0x7fffffff /* specific section header types */ -#define SHT_LOUSER 0x80000000 /* reserved range for application */ -#define SHT_HIUSER 0xffffffff /* specific indexes */ - -/* Flags for sh_flags. */ -#define SHF_WRITE 0x1 /* Section contains writable data. */ -#define SHF_ALLOC 0x2 /* Section occupies memory. */ -#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ -#define SHF_MERGE 0x10 /* Section may be merged. */ -#define SHF_STRINGS 0x20 /* Section contains strings. */ -#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ -#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ -#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ -#define SHF_GROUP 0x200 /* Member of section group. */ -#define SHF_TLS 0x400 /* Section contains TLS data. */ -#define SHF_COMPRESSED 0x800 /* Section contains compressed data. */ -#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ - -/* Flags for section groups. */ -#define GRP_COMDAT 0x1 /* COMDAT semantics. */ - -/* - * Flags / mask for .gnu.versym sections. - */ -#define VERSYM_VERSION 0x7fff -#define VERSYM_HIDDEN 0x8000 - -/* Values for p_type. */ -#define PT_NULL 0 /* Unused entry. */ -#define PT_LOAD 1 /* Loadable segment. */ -#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ -#define PT_INTERP 3 /* Pathname of interpreter. */ -#define PT_NOTE 4 /* Auxiliary information. */ -#define PT_SHLIB 5 /* Reserved (not used). */ -#define PT_PHDR 6 /* Location of program header itself. */ -#define PT_TLS 7 /* Thread local storage segment */ -#define PT_LOOS 0x60000000 /* First OS-specific. */ -#define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */ -#define PT_GNU_EH_FRAME 0x6474e550 -#define PT_GNU_STACK 0x6474e551 -#define PT_GNU_RELRO 0x6474e552 -#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for kernel dumps - (currently arm). */ -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ -#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ -#define PT_SUNWDTRACE 0x6ffffffc /* private */ -#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff /* Last OS-specific. */ -#define PT_LOPROC 0x70000000 /* First processor-specific type. */ -#define PT_ARM_ARCHEXT 0x70000000 /* ARM arch compat information. */ -#define PT_ARM_EXIDX 0x70000001 /* ARM exception unwind tables. */ -#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ - -/* Values for p_flags. */ -#define PF_X 0x1 /* Executable. */ -#define PF_W 0x2 /* Writable. */ -#define PF_R 0x4 /* Readable. */ -#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific. */ - -/* Extended program header index. */ -#define PN_XNUM 0xffff - -/* Values for d_tag. */ -#define DT_NULL 0 /* Terminating entry. */ -#define DT_NEEDED 1 /* String table offset of a needed shared - library. */ -#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ -#define DT_PLTGOT 3 /* Processor-dependent address. */ -#define DT_HASH 4 /* Address of symbol hash table. */ -#define DT_STRTAB 5 /* Address of string table. */ -#define DT_SYMTAB 6 /* Address of symbol table. */ -#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ -#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ -#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ -#define DT_STRSZ 10 /* Size of string table. */ -#define DT_SYMENT 11 /* Size of each symbol table entry. */ -#define DT_INIT 12 /* Address of initialization function. */ -#define DT_FINI 13 /* Address of finalization function. */ -#define DT_SONAME 14 /* String table offset of shared object - name. */ -#define DT_RPATH 15 /* String table offset of library path. [sup] */ -#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ -#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ -#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ -#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ -#define DT_PLTREL 20 /* Type of relocation used for PLT. */ -#define DT_DEBUG 21 /* Reserved (not used). */ -#define DT_TEXTREL 22 /* Indicates there may be relocations in - non-writable segments. [sup] */ -#define DT_JMPREL 23 /* Address of PLT relocations. */ -#define DT_BIND_NOW 24 /* [sup] */ -#define DT_INIT_ARRAY 25 /* Address of the array of pointers to - initialization functions */ -#define DT_FINI_ARRAY 26 /* Address of the array of pointers to - termination functions */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of - initialization functions. */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of - termination functions. */ -#define DT_RUNPATH 29 /* String table offset of a null-terminated - library search path string. */ -#define DT_FLAGS 30 /* Object specific flag values. */ -#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING - and less than DT_LOOS follow the rules for - the interpretation of the d_un union - as follows: even == 'd_ptr', odd == 'd_val' - or none */ -#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to - pre-initialization functions. */ -#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of - pre-initialization functions. */ -#define DT_MAXPOSTAGS 34 /* number of positive tags */ -#define DT_LOOS 0x6000000d /* First OS-specific */ -#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ -#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ -#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ -#define DT_SUNW_CAP 0x60000010 /* hardware/software */ -#define DT_HIOS 0x6ffff000 /* Last OS-specific */ - -/* - * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - * Dyn.d_un.d_val field of the Elf*_Dyn structure. - */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_GNU_PRELINKED 0x6ffffdf5 /* prelinking timestamp */ -#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* size of conflict section */ -#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* size of library list */ -#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ -#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ -#define DT_MOVEENT 0x6ffffdfa /* move table entry size */ -#define DT_MOVESZ 0x6ffffdfb /* move table size */ -#define DT_FEATURE 0x6ffffdfc /* feature holder */ -#define DT_FEATURE_1 DT_FEATURE -#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ -/* the following DT_* entry. */ -/* See DF_P1_* definitions */ -#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ -#define DT_VALRNGHI 0x6ffffdff - -/* - * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - * - * If any adjustment is made to the ELF object after it has been - * built, these entries will need to be adjusted. - */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ -#define DT_TLSDESC_PLT 0x6ffffef6 /* loc. of PLT for tlsdesc resolver */ -#define DT_TLSDESC_GOT 0x6ffffef7 /* loc. of GOT for tlsdesc resolver */ -#define DT_GNU_CONFLICT 0x6ffffef8 /* address of conflict section */ -#define DT_GNU_LIBLIST 0x6ffffef9 /* address of library list */ -#define DT_CONFIG 0x6ffffefa /* configuration information */ -#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ -#define DT_AUDIT 0x6ffffefc /* object auditing */ -#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ -#define DT_MOVETAB 0x6ffffefe /* move table */ -#define DT_SYMINFO 0x6ffffeff /* syminfo table */ -#define DT_ADDRRNGHI 0x6ffffeff - -#define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ -#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ -#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ -#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ -#define DT_VERDEF 0x6ffffffc /* Address of verdef section. */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */ -#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */ - -#define DT_LOPROC 0x70000000 /* First processor-specific type. */ - -#define DT_ARM_SYMTABSZ 0x70000001 -#define DT_ARM_PREEMPTMAP 0x70000002 - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_DEPRECATED_SPARC_REGISTER 0x7000001 - -#define DT_MIPS_RLD_VERSION 0x70000001 -#define DT_MIPS_TIME_STAMP 0x70000002 -#define DT_MIPS_ICHECKSUM 0x70000003 -#define DT_MIPS_IVERSION 0x70000004 -#define DT_MIPS_FLAGS 0x70000005 -#define DT_MIPS_BASE_ADDRESS 0x70000006 -#define DT_MIPS_CONFLICT 0x70000008 -#define DT_MIPS_LIBLIST 0x70000009 -#define DT_MIPS_LOCAL_GOTNO 0x7000000a -#define DT_MIPS_CONFLICTNO 0x7000000b -#define DT_MIPS_LIBLISTNO 0x70000010 -#define DT_MIPS_SYMTABNO 0x70000011 -#define DT_MIPS_UNREFEXTNO 0x70000012 -#define DT_MIPS_GOTSYM 0x70000013 -#define DT_MIPS_HIPAGENO 0x70000014 -#define DT_MIPS_RLD_MAP 0x70000016 -#define DT_MIPS_DELTA_CLASS 0x70000017 -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 -#define DT_MIPS_DELTA_INSTANCE 0x70000019 -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001A -#define DT_MIPS_DELTA_RELOC 0x7000001B -#define DT_MIPS_DELTA_RELOC_NO 0x7000001C -#define DT_MIPS_DELTA_SYM 0x7000001D -#define DT_MIPS_DELTA_SYM_NO 0x7000001E -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 -#define DT_MIPS_CXX_FLAGS 0x70000022 -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 -#define DT_MIPS_INTERFACE 0x7000002A -#define DT_MIPS_DYNSTR_ALIGN 0x7000002B -#define DT_MIPS_INTERFACE_SIZE 0x7000002C -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002D -#define DT_MIPS_PERF_SUFFIX 0x7000002E -#define DT_MIPS_COMPACT_SIZE 0x7000002F -#define DT_MIPS_GP_VALUE 0x70000030 -#define DT_MIPS_AUX_DYNAMIC 0x70000031 -#define DT_MIPS_PLTGOT 0x70000032 -#define DT_MIPS_RLD_OBJ_UPDATE 0x70000033 -#define DT_MIPS_RWPLT 0x70000034 - -#define DT_PPC_GOT 0x70000000 -#define DT_PPC_TLSOPT 0x70000001 - -#define DT_PPC64_GLINK 0x70000000 -#define DT_PPC64_OPD 0x70000001 -#define DT_PPC64_OPDSZ 0x70000002 -#define DT_PPC64_TLSOPT 0x70000003 - -#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ -#define DT_USED 0x7ffffffe /* ignored - same as needed */ -#define DT_FILTER 0x7fffffff /* shared library filter name */ -#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ - -/* Values for DT_FLAGS */ -#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may - make reference to the $ORIGIN substitution - string */ -#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ -#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in - non-writable segments. */ -#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should - process all relocations for the object - containing this entry before transferring - control to the program. */ -#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or - executable contains code using a static - thread-local storage scheme. */ - -/* Values for DT_FLAGS_1 */ -#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ -#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ -#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ -#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */ -#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ -#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ -#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */ -#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */ - -/* Values for l_flags. */ -#define LL_NONE 0x0 /* no flags */ -#define LL_EXACT_MATCH 0x1 /* require an exact match */ -#define LL_IGNORE_INT_VER 0x2 /* ignore version incompatibilities */ -#define LL_REQUIRE_MINOR 0x4 -#define LL_EXPORTS 0x8 -#define LL_DELAY_LOAD 0x10 -#define LL_DELTA 0x20 - -/* Values for n_type used in executables. */ -#define NT_FREEBSD_ABI_TAG 1 -#define NT_FREEBSD_NOINIT_TAG 2 -#define NT_FREEBSD_ARCH_TAG 3 - -/* Values for n_type. Used in core files. */ -#define NT_PRSTATUS 1 /* Process status. */ -#define NT_FPREGSET 2 /* Floating point registers. */ -#define NT_PRPSINFO 3 /* Process state info. */ -#define NT_THRMISC 7 /* Thread miscellaneous info. */ -#define NT_PROCSTAT_PROC 8 /* Procstat proc data. */ -#define NT_PROCSTAT_FILES 9 /* Procstat files data. */ -#define NT_PROCSTAT_VMMAP 10 /* Procstat vmmap data. */ -#define NT_PROCSTAT_GROUPS 11 /* Procstat groups data. */ -#define NT_PROCSTAT_UMASK 12 /* Procstat umask data. */ -#define NT_PROCSTAT_RLIMIT 13 /* Procstat rlimit data. */ -#define NT_PROCSTAT_OSREL 14 /* Procstat osreldate data. */ -#define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ -#define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ -#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ -#define NT_X86_XSTATE 0x202 /* x86 XSAVE extended state. */ - -/* Symbol Binding - ELFNN_ST_BIND - st_info */ -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* like global - lower precedence */ -#define STB_LOOS 10 /* Start of operating system reserved range. */ -#define STB_GNU_UNIQUE 10 /* Unique symbol (GNU) */ -#define STB_HIOS 12 /* End of operating system reserved range. */ -#define STB_LOPROC 13 /* reserved range for processor */ -#define STB_HIPROC 15 /* specific semantics. */ - -/* Symbol type - ELFNN_ST_TYPE - st_info */ -#define STT_NOTYPE 0 /* Unspecified type. */ -#define STT_OBJECT 1 /* Data object. */ -#define STT_FUNC 2 /* Function. */ -#define STT_SECTION 3 /* Section. */ -#define STT_FILE 4 /* Source file. */ -#define STT_COMMON 5 /* Uninitialized common block. */ -#define STT_TLS 6 /* TLS object. */ -#define STT_NUM 7 -#define STT_LOOS 10 /* Reserved range for operating system */ -#define STT_GNU_IFUNC 10 -#define STT_HIOS 12 /* specific semantics. */ -#define STT_LOPROC 13 /* Start of processor reserved range. */ -#define STT_SPARC_REGISTER 13 /* SPARC register information. */ -#define STT_HIPROC 15 /* End of processor reserved range. */ - -/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ -#define STV_DEFAULT 0x0 /* Default visibility (see binding). */ -#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ -#define STV_HIDDEN 0x2 /* Not visible. */ -#define STV_PROTECTED 0x3 /* Visible but not preemptible. */ -#define STV_EXPORTED 0x4 -#define STV_SINGLETON 0x5 -#define STV_ELIMINATE 0x6 - -/* Special symbol table indexes. */ -#define STN_UNDEF 0 /* Undefined symbol index. */ - -/* Symbol versioning flags. */ -#define VER_DEF_CURRENT 1 -#define VER_DEF_IDX(x) VER_NDX(x) - -#define VER_FLG_BASE 0x01 -#define VER_FLG_WEAK 0x02 - -#define VER_NEED_CURRENT 1 -#define VER_NEED_WEAK (1u << 15) -#define VER_NEED_HIDDEN VER_NDX_HIDDEN -#define VER_NEED_IDX(x) VER_NDX(x) - -#define VER_NDX_LOCAL 0 -#define VER_NDX_GLOBAL 1 -#define VER_NDX_GIVEN 2 - -#define VER_NDX_HIDDEN (1u << 15) -#define VER_NDX(x) ((x) & ~(1u << 15)) - -#define CA_SUNW_NULL 0 -#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ -#define CA_SUNW_SF_1 2 /* first software capabilities entry */ - -/* - * Syminfo flag values - */ -#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ -/* to object containing defn. */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ -#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */ -/* lazily-loaded */ -#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ -/* object containing defn. */ -#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ -/* directly bind to this symbol */ -#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ -#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ - -/* - * Syminfo.si_boundto values. - */ -#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ -#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ -#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ - -/* - * Syminfo version values. - */ -#define SYMINFO_NONE 0 /* Syminfo version */ -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - -/* Values for ch_type (compressed section headers). */ -#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE */ -#define ELFCOMPRESS_LOOS 0x60000000 /* OS-specific */ -#define ELFCOMPRESS_HIOS 0x6fffffff -#define ELFCOMPRESS_LOPROC 0x70000000 /* Processor-specific */ -#define ELFCOMPRESS_HIPROC 0x7fffffff - -/* - * Relocation types. - * - * All machine architectures are defined here to allow tools on one to - * handle others. - */ - -#define R_386_NONE 0 /* No relocation. */ -#define R_386_32 1 /* Add symbol value. */ -#define R_386_PC32 2 /* Add PC-relative symbol value. */ -#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ -#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ -#define R_386_COPY 5 /* Copy data from shared object. */ -#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ -#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ -#define R_386_RELATIVE 8 /* Add load address of shared object. */ -#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ -#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ -#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */ -#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */ -#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */ -#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */ -#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */ -#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */ -#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */ -#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */ -#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */ -#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */ -#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */ -#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */ -#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */ -#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */ -#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */ -#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */ -#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */ -#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */ -#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */ -#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */ -#define R_386_IRELATIVE 42 /* PLT entry resolved indirectly at runtime */ - -#define R_AARCH64_NONE 0 /* No relocation */ -#define R_AARCH64_ABS64 257 /* Absolute offset */ -#define R_AARCH64_ABS32 258 /* Absolute, 32-bit overflow check */ -#define R_AARCH64_ABS16 259 /* Absolute, 16-bit overflow check */ -#define R_AARCH64_PREL64 260 /* PC relative */ -#define R_AARCH64_PREL32 261 /* PC relative, 32-bit overflow check */ -#define R_AARCH64_PREL16 262 /* PC relative, 16-bit overflow check */ -#define R_AARCH64_COPY 1024 /* Copy data from shared object */ -#define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */ -#define R_AARCH64_JUMP_SLOT 1026 /* Set GOT entry to code address */ -#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */ -#define R_AARCH64_TLS_DTPREL64 1028 -#define R_AARCH64_TLS_DTPMOD64 1029 -#define R_AARCH64_TLS_TPREL64 1030 -#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */ -#define R_AARCH64_IRELATIVE 1032 - -#define R_ARM_NONE 0 /* No relocation. */ -#define R_ARM_PC24 1 -#define R_ARM_ABS32 2 -#define R_ARM_REL32 3 -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 -#define R_ARM_ABS12 6 -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 -/* TLS relocations */ -#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ -#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ -#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ -#define R_ARM_COPY 20 /* Copy data from shared object. */ -#define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */ -#define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */ -#define R_ARM_RELATIVE 23 /* Add load address of shared object. */ -#define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */ -#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */ -#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */ -#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */ -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS32 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 - -/* Name Value Field Calculation */ -#define R_IA_64_NONE 0 /* None */ -#define R_IA_64_IMM14 0x21 /* immediate14 S + A */ -#define R_IA_64_IMM22 0x22 /* immediate22 S + A */ -#define R_IA_64_IMM64 0x23 /* immediate64 S + A */ -#define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */ -#define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */ -#define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */ -#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */ -#define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */ -#define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */ -#define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */ -#define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */ -#define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */ -#define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */ -#define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */ -#define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */ -#define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */ -#define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */ -#define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */ -#define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */ -#define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */ -#define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */ -#define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */ -#define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */ -#define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */ -#define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */ -#define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */ -#define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */ -#define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */ -#define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */ -#define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */ -#define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */ -#define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */ -#define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */ -#define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */ -#define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */ -#define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */ -#define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */ -#define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */ -#define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */ -#define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */ -#define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */ -#define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */ -#define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */ -#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */ -#define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */ -#define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */ -#define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */ -#define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */ -#define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */ -#define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ -#define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ -#define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ -#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ -#define R_IA_64_SUB 0x85 /* immediate64 A - S */ -#define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ -#define R_IA_64_LDXMOV 0x87 /* immediate22 special */ -#define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */ -#define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */ -#define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */ -#define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */ -#define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */ -#define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */ -#define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */ -#define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */ -#define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */ -#define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */ -#define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */ -#define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */ -#define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */ -#define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */ -#define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */ -#define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */ -#define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */ - -#define R_MIPS_NONE 0 /* No reloc */ -#define R_MIPS_16 1 /* Direct 16 bit */ -#define R_MIPS_32 2 /* Direct 32 bit */ -#define R_MIPS_REL32 3 /* PC relative 32 bit */ -#define R_MIPS_26 4 /* Direct 26 bit shifted */ -#define R_MIPS_HI16 5 /* High 16 bit */ -#define R_MIPS_LO16 6 /* Low 16 bit */ -#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#define R_MIPS_PC16 10 /* PC relative 16 bit */ -#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ -#define R_MIPS_64 18 /* Direct 64 bit */ -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */ -#define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */ -#define R_MIPS_SUB 24 -#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ -#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ -#define R_MIPS_JALR 37 -#define R_MIPS_TLS_GD 42 - -#define R_PPC_NONE 0 /* No relocation. */ -#define R_PPC_ADDR32 1 -#define R_PPC_ADDR24 2 -#define R_PPC_ADDR16 3 -#define R_PPC_ADDR16_LO 4 -#define R_PPC_ADDR16_HI 5 -#define R_PPC_ADDR16_HA 6 -#define R_PPC_ADDR14 7 -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 -#define R_PPC_REL14 11 -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 - -/* - * 64-bit relocations - */ -#define R_PPC64_ADDR64 38 -#define R_PPC64_ADDR16_HIGHER 39 -#define R_PPC64_ADDR16_HIGHERA 40 -#define R_PPC64_ADDR16_HIGHEST 41 -#define R_PPC64_ADDR16_HIGHESTA 42 -#define R_PPC64_UADDR64 43 -#define R_PPC64_REL64 44 -#define R_PPC64_PLT64 45 -#define R_PPC64_PLTREL64 46 -#define R_PPC64_TOC16 47 -#define R_PPC64_TOC16_LO 48 -#define R_PPC64_TOC16_HI 49 -#define R_PPC64_TOC16_HA 50 -#define R_PPC64_TOC 51 -#define R_PPC64_DTPMOD64 68 -#define R_PPC64_TPREL64 73 -#define R_PPC64_DTPREL64 78 - -/* - * TLS relocations - */ -#define R_PPC_TLS 67 -#define R_PPC_DTPMOD32 68 -#define R_PPC_TPREL16 69 -#define R_PPC_TPREL16_LO 70 -#define R_PPC_TPREL16_HI 71 -#define R_PPC_TPREL16_HA 72 -#define R_PPC_TPREL32 73 -#define R_PPC_DTPREL16 74 -#define R_PPC_DTPREL16_LO 75 -#define R_PPC_DTPREL16_HI 76 -#define R_PPC_DTPREL16_HA 77 -#define R_PPC_DTPREL32 78 -#define R_PPC_GOT_TLSGD16 79 -#define R_PPC_GOT_TLSGD16_LO 80 -#define R_PPC_GOT_TLSGD16_HI 81 -#define R_PPC_GOT_TLSGD16_HA 82 -#define R_PPC_GOT_TLSLD16 83 -#define R_PPC_GOT_TLSLD16_LO 84 -#define R_PPC_GOT_TLSLD16_HI 85 -#define R_PPC_GOT_TLSLD16_HA 86 -#define R_PPC_GOT_TPREL16 87 -#define R_PPC_GOT_TPREL16_LO 88 -#define R_PPC_GOT_TPREL16_HI 89 -#define R_PPC_GOT_TPREL16_HA 90 - -/* - * The remaining relocs are from the Embedded ELF ABI, and are not in the - * SVR4 ELF ABI. - */ - -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 - -/* - * RISC-V relocation types. - */ - -/* Relocation types used by the dynamic linker. */ -#define R_RISCV_NONE 0 -#define R_RISCV_32 1 -#define R_RISCV_64 2 -#define R_RISCV_RELATIVE 3 -#define R_RISCV_COPY 4 -#define R_RISCV_JUMP_SLOT 5 -#define R_RISCV_TLS_DTPMOD32 6 -#define R_RISCV_TLS_DTPMOD64 7 -#define R_RISCV_TLS_DTPREL32 8 -#define R_RISCV_TLS_DTPREL64 9 -#define R_RISCV_TLS_TPREL32 10 -#define R_RISCV_TLS_TPREL64 11 - -/* Relocation types not used by the dynamic linker. */ -#define R_RISCV_BRANCH 16 -#define R_RISCV_JAL 17 -#define R_RISCV_CALL 18 -#define R_RISCV_CALL_PLT 19 -#define R_RISCV_GOT_HI20 20 -#define R_RISCV_TLS_GOT_HI20 21 -#define R_RISCV_TLS_GD_HI20 22 -#define R_RISCV_PCREL_HI20 23 -#define R_RISCV_PCREL_LO12_I 24 -#define R_RISCV_PCREL_LO12_S 25 -#define R_RISCV_HI20 26 -#define R_RISCV_LO12_I 27 -#define R_RISCV_LO12_S 28 -#define R_RISCV_TPREL_HI20 29 -#define R_RISCV_TPREL_LO12_I 30 -#define R_RISCV_TPREL_LO12_S 31 -#define R_RISCV_TPREL_ADD 32 -#define R_RISCV_ADD8 33 -#define R_RISCV_ADD16 34 -#define R_RISCV_ADD32 35 -#define R_RISCV_ADD64 36 -#define R_RISCV_SUB8 37 -#define R_RISCV_SUB16 38 -#define R_RISCV_SUB32 39 -#define R_RISCV_SUB64 40 -#define R_RISCV_GNU_VTINHERIT 41 -#define R_RISCV_GNU_VTENTRY 42 -#define R_RISCV_ALIGN 43 -#define R_RISCV_RVC_BRANCH 44 -#define R_RISCV_RVC_JUMP 45 - -#define R_SPARC_NONE 0 -#define R_SPARC_8 1 -#define R_SPARC_16 2 -#define R_SPARC_32 3 -#define R_SPARC_DISP8 4 -#define R_SPARC_DISP16 5 -#define R_SPARC_DISP32 6 -#define R_SPARC_WDISP30 7 -#define R_SPARC_WDISP22 8 -#define R_SPARC_HI22 9 -#define R_SPARC_22 10 -#define R_SPARC_13 11 -#define R_SPARC_LO10 12 -#define R_SPARC_GOT10 13 -#define R_SPARC_GOT13 14 -#define R_SPARC_GOT22 15 -#define R_SPARC_PC10 16 -#define R_SPARC_PC22 17 -#define R_SPARC_WPLT30 18 -#define R_SPARC_COPY 19 -#define R_SPARC_GLOB_DAT 20 -#define R_SPARC_JMP_SLOT 21 -#define R_SPARC_RELATIVE 22 -#define R_SPARC_UA32 23 -#define R_SPARC_PLT32 24 -#define R_SPARC_HIPLT22 25 -#define R_SPARC_LOPLT10 26 -#define R_SPARC_PCPLT32 27 -#define R_SPARC_PCPLT22 28 -#define R_SPARC_PCPLT10 29 -#define R_SPARC_10 30 -#define R_SPARC_11 31 -#define R_SPARC_64 32 -#define R_SPARC_OLO10 33 -#define R_SPARC_HH22 34 -#define R_SPARC_HM10 35 -#define R_SPARC_LM22 36 -#define R_SPARC_PC_HH22 37 -#define R_SPARC_PC_HM10 38 -#define R_SPARC_PC_LM22 39 -#define R_SPARC_WDISP16 40 -#define R_SPARC_WDISP19 41 -#define R_SPARC_GLOB_JMP 42 -#define R_SPARC_7 43 -#define R_SPARC_5 44 -#define R_SPARC_6 45 -#define R_SPARC_DISP64 46 -#define R_SPARC_PLT64 47 -#define R_SPARC_HIX22 48 -#define R_SPARC_LOX10 49 -#define R_SPARC_H44 50 -#define R_SPARC_M44 51 -#define R_SPARC_L44 52 -#define R_SPARC_REGISTER 53 -#define R_SPARC_UA64 54 -#define R_SPARC_UA16 55 -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 - -#define R_X86_64_NONE 0 /* No relocation. */ -#define R_X86_64_64 1 /* Add 64 bit symbol value. */ -#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */ -#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */ -#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */ -#define R_X86_64_COPY 5 /* Copy data from shared object. */ -#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */ -#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */ -#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */ -#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */ -#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */ -#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */ -#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */ -#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */ -#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */ -#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */ -#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ -#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */ -#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */ -#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */ -#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */ -#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ -#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */ -#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */ -#define R_X86_64_PC64 24 /* PC-relative 64 bit signed sym value. */ -#define R_X86_64_GOTOFF64 25 -#define R_X86_64_GOTPC32 26 -#define R_X86_64_GOT64 27 -#define R_X86_64_GOTPCREL64 28 -#define R_X86_64_GOTPC64 29 -#define R_X86_64_GOTPLT64 30 -#define R_X86_64_PLTOFF64 31 -#define R_X86_64_SIZE32 32 -#define R_X86_64_SIZE64 33 -#define R_X86_64_GOTPC32_TLSDESC 34 -#define R_X86_64_TLSDESC_CALL 35 -#define R_X86_64_TLSDESC 36 -#define R_X86_64_IRELATIVE 37 - -#endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/include/sys/elf_generic.h b/include/sys/elf_generic.h deleted file mode 100644 index 3350856..0000000 --- a/include/sys/elf_generic.h +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF_GENERIC_H_ -#define _SYS_ELF_GENERIC_H_ 1 - -#include - -/* - * Definitions of generic ELF names which relieve applications from - * needing to know the word size. - */ - -#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 -#error "__ELF_WORD_SIZE must be defined as 32 or 64" -#endif - -#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define ELF_DATA ELFDATA2LSB -#elif BYTE_ORDER == BIG_ENDIAN -#define ELF_DATA ELFDATA2MSB -#else -#error "Unknown byte order" -#endif - -#define __elfN(x) __CONCAT(__CONCAT(__CONCAT(elf,__ELF_WORD_SIZE),_),x) -#define __ElfN(x) __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) -#define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) -#define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) - -__ElfType(Addr); -__ElfType(Half); -__ElfType(Off); -__ElfType(Sword); -__ElfType(Word); -__ElfType(Ehdr); -__ElfType(Shdr); -__ElfType(Phdr); -__ElfType(Dyn); -__ElfType(Rel); -__ElfType(Rela); -__ElfType(Sym); -__ElfType(Verdef); -__ElfType(Verdaux); -__ElfType(Verneed); -__ElfType(Vernaux); -__ElfType(Versym); - -/* Non-standard ELF types. */ -__ElfType(Hashelt); -__ElfType(Size); -__ElfType(Ssize); - -#define ELF_R_SYM __ELFN(R_SYM) -#define ELF_R_TYPE __ELFN(R_TYPE) -#define ELF_R_INFO __ELFN(R_INFO) -#define ELF_ST_BIND __ELFN(ST_BIND) -#define ELF_ST_TYPE __ELFN(ST_TYPE) -#define ELF_ST_INFO __ELFN(ST_INFO) -#define ELF_ST_VISIBILITY __ELFN(ST_VISIBILITY) - -#endif /* !_SYS_ELF_GENERIC_H_ */ diff --git a/include/sys/gdt.h b/include/sys/gdt.h deleted file mode 100644 index e6a38c5..0000000 --- a/include/sys/gdt.h +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _GDT_H_ -#define _GDT_H_ - -#define SEL_GET_PL(sel) ((sel)&3) /* Get Priority Level Of Selector */ -#define SEL_GET_LG(sel) ((sel)&4) /* Return Local/Global Descriptor */ -#define SEL_GET_IDX(sel) (((sel)>>3) & 0x1FFF) /* Get Selector Index */ - -#define SEL_PL_KERN 0x0 -#define SEL_PL_USER 0x3 - -/* Descriptor Definitions */ -#define dCall 0x0C00 /* 386 Call Gate */ -#define dCode 0x1800 /* Code Segment */ -#define dData 0x1000 /* Data Segment */ -#define dInt 0x0E00 /* 386 Interrupt Gate */ -#define dLdt 0x200 /* Local Descriptor Table (LDT) */ -#define dTask 0x500 /* Task gate */ -#define dTrap 0x0F00 /* 386 Trap Gate */ -#define dTss 0x900 /* Task State Segment (TSS) */ - -/* Descriptor Options */ -#define dDpl3 0x6000 /* DPL3 or mask for DPL */ -#define dDpl2 0x4000 /* DPL2 or mask for DPL */ -#define dDpl1 0x2000 /* DPL1 or mask for DPL */ -#define dDpl0 0x0000 /* DPL0 or mask for DPL */ -#define dPresent 0x8000 /* Present */ -#define dNpresent 0x8000 /* Not Present */ -#define dAcc 0x100 /* Accessed (Data or Code) */ -#define dWrite 0x200 /* Writable (Data segments only) */ -#define dRead 0x200 /* Readable (Code segments only) */ -#define dBusy 0xB00 /* Busy (TSS only) was 200 */ -#define dEexdown 0x400 /* Expand down (Data segments only) */ -#define dConform 0x400 /* Conforming (Code segments only) */ -#define dBig 0x40 /* Default to 32 bit mode */ -#define dBiglim 0x80 /* Limit is in 4K units */ - -/* GDT Descriptor */ -struct gdtDescriptor { - unsigned short limitLow; /* Limit 0..15 */ - unsigned short baseLow; /* Base 0..15 */ - unsigned char baseMed; /* Base 16..23 */ - unsigned char access; /* Access Byte */ - unsigned int limitHigh :4; /* Limit 16..19 */ - unsigned int granularity :4; /* Granularity */ - unsigned char baseHigh; /* Base 24..31 */ -}__attribute__ ((packed)); - -struct gdtGate { - unsigned short offsetLow; /* Offset 0..15 */ - unsigned short selector; /* Selector */ - unsigned short access; /* Access Flags */ - unsigned short offsetHigh; /* Offset 16..31 */ -}__attribute__ ((packed)); - -union descriptorTableUnion { - struct gdtDescriptor descriptor; /* Normal descriptor */ - struct gdtGate gate; /* Gate descriptor */ - unsigned long dummy; /* Any other info */ -}; - -#define ubixDescriptorTable(name, length) union descriptorTableUnion name[length] = -#define ubixStandardDescriptor(base, limit, control) {.descriptor = {(limit & 0xffff), (base & 0xffff), ((base >> 16) & 0xff), ((control + dPresent) >> 8), (limit >> 16), ((control & 0xff) >> 4), (base >> 24)}} -#define ubixGateDescriptor(offset, selector, control) {.gate = {(offset & 0xffff), selector, (control+dPresent), (offset >> 16) }} - -extern union descriptorTableUnion ubixGDT[11]; - -#endif - -/*** - $Log: gdt.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:15 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:52 reddawg - no message - - Revision 1.5 2004/08/15 16:47:49 reddawg - Fixed - - Revision 1.4 2004/07/22 20:53:07 reddawg - atkbd: fixed problem - - Revision 1.3 2004/05/21 15:12:17 reddawg - Cleaned up - - END - ***/ diff --git a/include/sys/gen_calls.h b/include/sys/gen_calls.h deleted file mode 100644 index 3450aa8..0000000 --- a/include/sys/gen_calls.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _GEN_CALLS_H -#define _GEN_CALLS_H - -#include -#include - -int read(struct thread *td,struct read_args *uap); - -int getpid(struct thread *, struct getpid_args *); -int issetugid(register struct thread *, struct issetugid_args *); -int readlink(struct thread *,struct readlink_args *); -int getuid(struct thread *, struct getuid_args *); -int getgid(struct thread *, struct getgid_args *); -int gettimeofday_new(struct thread *, struct gettimeofday_args *); - -#endif diff --git a/include/sys/i386/asmacros.h b/include/sys/i386/asmacros.h deleted file mode 100644 index 1c48c28..0000000 --- a/include/sys/i386/asmacros.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * asmacros.h - * - * Created on: Jan 12, 2018 - * Author: cwolsen - */ - -#ifndef _I386_ASMACROS_H_ -#define _I386_ASMACROS_H_ - -/* - * CNAME is used to manage the relationship between symbol names in C - * and the equivalent assembly language names. CNAME is given a name as - * it would be used in a C program. It expands to the equivalent assembly - * language name. - */ -#define CNAME(csym) csym -#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ - -#define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ - .type CNAME(name),@function; CNAME(name): - -#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT -#define MCOUNT nop -#define END(name) .size name, . - name - -#endif /* END _I386_ASMACROS_H_ */ diff --git a/include/sys/i386/atkbd.h b/include/sys/i386/atkbd.h deleted file mode 100644 index 59e91de..0000000 --- a/include/sys/i386/atkbd.h +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISA_ATKBD_H -#define _ISA_ATKBD_H - -#define shiftKey 1 -#define controlKey 2 -#define altKey 4 -#define ledNumlock 2 -#define ledScrolllock 1 -#define ledCapslock 4 - -int atkbd_init(); -void atkbd_isr(); - -void keyboardHandler(); -void setLED(); - -#endif - -/*** - $Log: atkbd.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:36 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:39 reddawg - no message - - Revision 1.4 2004/07/29 21:32:16 reddawg - My quick lunchs breaks worth of updates.... - - Revision 1.3 2004/07/09 13:34:51 reddawg - keyboard: keyboardInit to atkbd_init - Adjusted initialization routines - - Revision 1.2 2004/05/21 14:57:16 reddawg - Cleaned up - - END - ***/ diff --git a/include/sys/i386/cpu.h b/include/sys/i386/cpu.h deleted file mode 100644 index 96841d6..0000000 --- a/include/sys/i386/cpu.h +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _CPU_H_ -#define _CPU_H_ - -#include - -/* - * 386 processor status longword. - */ -#define PSL_C 0x00000001 /* carry bit */ -#define PSL_PF 0x00000004 /* parity bit */ -#define PSL_AF 0x00000010 /* bcd carry bit */ -#define PSL_Z 0x00000040 /* zero bit */ -#define PSL_N 0x00000080 /* negative bit */ -#define PSL_T 0x00000100 /* trace enable bit */ -#define PSL_I 0x00000200 /* interrupt enable bit */ -#define PSL_D 0x00000400 /* string instruction direction bit */ -#define PSL_V 0x00000800 /* overflow bit */ -#define PSL_IOPL 0x00003000 /* i/o privilege level */ -#define PSL_NT 0x00004000 /* nested task bit */ -#define PSL_RF 0x00010000 /* resume flag bit */ -#define PSL_VM 0x00020000 /* virtual 8086 mode bit */ -#define PSL_AC 0x00040000 /* alignment checking */ -#define PSL_VIF 0x00080000 /* virtual interrupt enable */ -#define PSL_VIP 0x00100000 /* virtual interrupt pending */ -#define PSL_ID 0x00200000 /* identification bit */ - -/* Read Contents Of CR0 */ -static __inline u_int rcr0(void) { - u_int data; - __asm __volatile("movl %%cr0,%0" : "=r" (data)); - return (data); -} - -/* Write To CR0 */ -static __inline void load_cr0(u_int data) { - __asm __volatile("movl %0,%%cr0" : : "r" (data)); -} - -static __inline u_int rcr2(void) { - u_int data; - - __asm __volatile("movl %%cr2,%0" : "=r" (data)); - return (data); -} - -static __inline u_int rcr3(void) { - u_int data; - - __asm __volatile("movl %%cr3,%0" : "=r" (data)); - return (data); -} - -static __inline void load_cr3(u_int data) { - __asm __volatile("movl %0,%%cr3" : : "r" (data) : "memory"); -} - -static __inline u_int rcr4(void) { - u_int data; - - __asm __volatile("movl %%cr4,%0" : "=r" (data)); - return (data); -} - -static __inline void load_cr4(u_int data) { - __asm __volatile("movl %0,%%cr4" : : "r" (data)); -} - -static __inline void invlpg(u_int addr) { - __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); -} - -#endif - -/*** - END - ***/ diff --git a/include/sys/i386/elf.h b/include/sys/i386/elf.h deleted file mode 100644 index a453017..0000000 --- a/include/sys/i386/elf.h +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _I386_ELF_H_ -#define _I386_ELF_H_ 1 - -#if defined(__i386__) || defined(_MACHINE_ELF_WANT_32BIT) - -/* - * ELF definitions for the i386 architecture. - */ - -#include /* Definitions common to all 32 bit architectures. */ -#if defined(__ELF_WORD_SIZE) && __ELF_WORD_SIZE == 64 -#include /* Definitions common to all 64 bit architectures. */ -#endif - -#ifndef __ELF_WORD_SIZE -#define __ELF_WORD_SIZE 32 /* Used by */ -#endif - -#include - -#define ELF_ARCH EM_386 - -#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486) - -/* - * Auxiliary vector entries for passing information to the interpreter. - * - * The i386 supplement to the SVR4 ABI specification names this "auxv_t", - * but POSIX lays claim to all symbols ending with "_t". - */ - -typedef struct { /* Auxiliary vector entry on initial stack */ - int a_type; /* Entry type. */ - union { - long a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ - }a_un; -}Elf32_Auxinfo; - -#if __ELF_WORD_SIZE == 64 -/* Fake for amd64 loader support */ -typedef struct { - int fake; -}Elf64_Auxinfo; -#endif - -__ElfType(Auxinfo); - -/* Values for a_type. */ -#define AT_NULL 0 /* Terminates the vector. */ -#define AT_IGNORE 1 /* Ignored entry. */ -#define AT_EXECFD 2 /* File descriptor of program to load. */ -#define AT_PHDR 3 /* Program header of program already loaded. */ -#define AT_PHENT 4 /* Size of each program header entry. */ -#define AT_PHNUM 5 /* Number of program header entries. */ -#define AT_PAGESZ 6 /* Page size in bytes. */ -#define AT_BASE 7 /* Interpreter's base address. */ -#define AT_FLAGS 8 /* Flags (unused for i386). */ -#define AT_ENTRY 9 /* Where interpreter should transfer control. */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_EXECPATH 15 /* Path to the executable. */ -#define AT_CANARY 16 /* Canary for SSP. */ -#define AT_CANARYLEN 17 /* Length of the canary. */ -#define AT_OSRELDATE 18 /* OSRELDATE. */ -#define AT_NCPUS 19 /* Number of CPUs. */ -#define AT_PAGESIZES 20 /* Pagesizes. */ -#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ -#define AT_TIMEKEEP 22 /* Pointer to timehands. */ -#define AT_STACKPROT 23 /* Initial stack protection. */ - -#define AT_COUNT 24 /* Count of defined aux entry types. */ - -/* - * Relocation types. - */ - -#define R_386_COUNT 38 /* Count of defined relocation types. */ - -/* Define "machine" characteristics */ -#define ELF_TARG_CLASS ELFCLASS32 -#define ELF_TARG_DATA ELFDATA2LSB -#define ELF_TARG_MACH EM_386 -#define ELF_TARG_VER 1 - -#define ET_DYN_LOAD_ADDR 0x01001000 - -#elif defined(__amd64__) - -/* - * ELF definitions for the AMD64 architecture. - */ - -#ifndef __ELF_WORD_SIZE -#define __ELF_WORD_SIZE 64 /* Used by */ -#endif -#include /* Definitions common to all 32 bit architectures. */ -#include /* Definitions common to all 64 bit architectures. */ -#include - -#define ELF_ARCH EM_X86_64 -#define ELF_ARCH32 EM_386 - -#define ELF_MACHINE_OK(x) ((x) == EM_X86_64) - -/* - * Auxiliary vector entries for passing information to the interpreter. - * - * The i386 supplement to the SVR4 ABI specification names this "auxv_t", - * but POSIX lays claim to all symbols ending with "_t". - */ -typedef struct { /* Auxiliary vector entry on initial stack */ - int a_type; /* Entry type. */ - union { - int a_val; /* Integer value. */ - }a_un; -}Elf32_Auxinfo; - -typedef struct { /* Auxiliary vector entry on initial stack */ - long a_type; /* Entry type. */ - union { - long a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ - }a_un; -}Elf64_Auxinfo; - -__ElfType(Auxinfo); - -/* Values for a_type. */ -#define AT_NULL 0 /* Terminates the vector. */ -#define AT_IGNORE 1 /* Ignored entry. */ -#define AT_EXECFD 2 /* File descriptor of program to load. */ -#define AT_PHDR 3 /* Program header of program already loaded. */ -#define AT_PHENT 4 /* Size of each program header entry. */ -#define AT_PHNUM 5 /* Number of program header entries. */ -#define AT_PAGESZ 6 /* Page size in bytes. */ -#define AT_BASE 7 /* Interpreter's base address. */ -#define AT_FLAGS 8 /* Flags (unused for i386). */ -#define AT_ENTRY 9 /* Where interpreter should transfer control. */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_EXECPATH 15 /* Path to the executable. */ -#define AT_CANARY 16 /* Canary for SSP */ -#define AT_CANARYLEN 17 /* Length of the canary. */ -#define AT_OSRELDATE 18 /* OSRELDATE. */ -#define AT_NCPUS 19 /* Number of CPUs. */ -#define AT_PAGESIZES 20 /* Pagesizes. */ -#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ -#define AT_TIMEKEEP 22 /* Pointer to timehands. */ -#define AT_STACKPROT 23 /* Initial stack protection. */ - -#define AT_COUNT 24 /* Count of defined aux entry types. */ - -/* - * Relocation types. - */ - -#define R_X86_64_COUNT 24 /* Count of defined relocation types. */ - -/* Define "machine" characteristics */ -#if __ELF_WORD_SIZE == 32 -#define ELF_TARG_CLASS ELFCLASS32 -#else -#define ELF_TARG_CLASS ELFCLASS64 -#endif -#define ELF_TARG_DATA ELFDATA2LSB -#define ELF_TARG_MACH EM_X86_64 -#define ELF_TARG_VER 1 - -#if __ELF_WORD_SIZE == 32 -#define ET_DYN_LOAD_ADDR 0x01001000 -#else -#define ET_DYN_LOAD_ADDR 0x01021000 -#endif - -#endif /* __i386__, __amd64__ */ - -#endif diff --git a/include/sys/i386/limits.h b/include/sys/i386/limits.h deleted file mode 100644 index 7910260..0000000 --- a/include/sys/i386/limits.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _I386_LIMITS_H -#define _I386_LIMITS_H - -#define __LONG_BIT 32 - -#endif /* END _I386_LIMITS_H */ diff --git a/include/sys/i386/signal.h b/include/sys/i386/signal.h deleted file mode 100644 index 247663e..0000000 --- a/include/sys/i386/signal.h +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _I386_SIGNAL_H_ -#define _I386_SIGNAL_H_ - -#define _NSIG 32 -#define NSIG _NSIG - -#define SIGHUP 1 -#define SIGINT 2 -#define SIGQUIT 3 -#define SIGILL 4 -#define SIGTRAP 5 -#define SIGABRT 6 -#define SIGIOT 6 -#define SIGBUS 7 -#define SIGFPE 8 -#define SIGKILL 9 -#define SIGUSR1 10 -#define SIGSEGV 11 -#define SIGUSR2 12 -#define SIGPIPE 13 -#define SIGALRM 14 -#define SIGTERM 15 -#define SIGSTKFLT 16 -#define SIGCHLD 17 -#define SIGCONT 18 -#define SIGSTOP 19 -#define SIGTSTP 20 -#define SIGTTIN 21 -#define SIGTTOU 22 -#define SIGURG 23 -#define SIGXCPU 24 -#define SIGXFSZ 25 -#define SIGVTALRM 26 -#define SIGPROF 27 -#define SIGWINCH 28 -#define SIGIO 29 -#define SIGPOLL SIGIO -#define SIGPWR 30 -#define SIGUNUSED 31 - -#endif diff --git a/include/sys/idt.h b/include/sys/idt.h deleted file mode 100644 index e5c114a..0000000 --- a/include/sys/idt.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _IDT_H -#define _IDT_H - -#include -#include - -#define EFLAG_TF 0x100 -#define EFLAG_IF 0x200 -#define EFLAG_IOPL3 0x3000 -#define EFLAG_VM 0x20000 - -int idt_init(); -void setVector(void *handler, unsigned char interrupt, unsigned short controlMajor); -void setTaskVector(uInt8 interrupt, uInt16 controlMajor, uInt8 selector); - - -void timerInt(); - -#endif diff --git a/include/sys/io.h b/include/sys/io.h deleted file mode 100644 index 9d118d7..0000000 --- a/include/sys/io.h +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _IO_H_ -#define _IO_H_ - -unsigned char inportByte(unsigned int); -unsigned short inportWord(unsigned int); -unsigned long inportDWord(unsigned int); - -void outportByte(unsigned int, unsigned char); -void outportByteP(unsigned int port, unsigned char value); -void outportWord(unsigned int, unsigned short); -void outportDWord(unsigned int port, unsigned long value); - -#endif - -/*** - $Log: io.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:15 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:52 reddawg - no message - - Revision 1.3 2004/07/22 20:14:34 reddawg - still working here - - Revision 1.2 2004/05/21 15:12:17 reddawg - Cleaned up - - - END - ***/ diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h deleted file mode 100644 index b3ed165..0000000 --- a/include/sys/ioctl.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Ioctl's have the command encoded in the lower word, and the size of - * any in or out parameters in the upper word. The high 3 bits of the - * upper word are used to encode the in/out status of the parameter. - */ -#define IOCPARM_SHIFT 13 /* number of bits for ioctl size */ -#define IOCPARM_MASK ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */ -#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) -#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16)) -#define IOCGROUP(x) (((x) >> 8) & 0xff) - -#define IOCPARM_MAX (1 << IOCPARM_SHIFT) /* max size of ioctl */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) -#define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN) - -#define _IOC(inout,group,num,len) ((unsigned long) \ - ((inout) | (((len) & IOCPARM_MASK) << 16) | ((group) << 8) | (num))) -#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) -#define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int)) -#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) -#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) -/* this should be _IORW, but stdio got there first */ -#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) - -#define IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x)) - -#define NCCS 20 - -typedef unsigned int tcflag_t; -typedef unsigned char cc_t; -typedef unsigned int speed_t; - -struct termios { - tcflag_t c_iflag; /* input flags */ - tcflag_t c_oflag; /* output flags */ - tcflag_t c_cflag; /* control flags */ - tcflag_t c_lflag; /* local flags */ - cc_t c_cc[NCCS]; /* control chars */ - speed_t c_ispeed; /* input speed */ - speed_t c_ospeed; /* output speed */ -}; - -struct winsize { - unsigned short ws_row; /* rows, in characters */ - unsigned short ws_col; /* columns, in characters */ - unsigned short ws_xpixel; /* horizontal size, pixels */ - unsigned short ws_ypixel; /* vertical size, pixels */ -}; - -#define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */ -#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ diff --git a/include/sys/kern_sig.h b/include/sys/kern_sig.h deleted file mode 100644 index c932413..0000000 --- a/include/sys/kern_sig.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _KERN_SIG_H -#define _KERN_SIG_H - -#include -#include - -int sigaction(struct thread *,struct sigaction_args *); -int sigprocmask(struct thread *, struct sigprocmask_args *); - -#endif /* END _KERN_SIG_H */ diff --git a/include/sys/kern_sysctl.h b/include/sys/kern_sysctl.h deleted file mode 100644 index 9aeb258..0000000 --- a/include/sys/kern_sysctl.h +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_KERN_SYSCTL_H -#define _SYS_KERN_SYSCTL_H - -#include -#include - -#define CTL_MAXNAME 24 /* largest number of components supported */ - -/* - * Top-level identifiers - */ -#define CTL_UNSPEC 0 /* unused */ -#define CTL_KERN 1 /* "high kernel": proc, limits */ -#define CTL_VM 2 /* virtual memory */ -#define CTL_VFS 3 /* filesystem, mount type is next */ -#define CTL_NET 4 /* network, see socket.h */ -#define CTL_DEBUG 5 /* debugging parameters */ -#define CTL_HW 6 /* generic cpu/io */ -#define CTL_MACHDEP 7 /* machine dependent */ -#define CTL_USER 8 /* user-level */ -#define CTL_P1003_1B 9 /* POSIX 1003.1B */ -#define CTL_UBIX 10 /* ubixos */ - -#define CTL_KERN_OPENFILES 1 /* kernel openfiles */ - -#define EINVAL -1 /* */ - -struct sysctl_entry { - struct sysctl_entry *prev; - struct sysctl_entry *next; - struct sysctl_entry *children; - char name[32]; - int id; - void *value; - int val_len; - }; - -int kern_sysctl(int *name,u_int namelen,void *old,size_t *oldlenp,void *new,size_t newlen,size_t *retval,int flags); -int sysctl_add(int *,int,char *,void *,int); -int sysctl_init(); - -extern bool sysctl_enabled; -#endif /* END _SYS_KERN_SYSCTL_H */ diff --git a/include/sys/limits.h b/include/sys/limits.h deleted file mode 100644 index 58ca781..0000000 --- a/include/sys/limits.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_LIMITS_H -#define _SYS_LIMITS_H - -#include - -#define LONG_BIT __LONG_BIT - -#endif /* END _SYS_LIMITS_H */ diff --git a/include/sys/pipe.h b/include/sys/pipe.h deleted file mode 100644 index dff67de..0000000 --- a/include/sys/pipe.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_PIPE_H -#define _SYS_PIPE_H - -#include -#include - -int pipe(struct thread *, struct pipe_args *); - -#endif /* END _SYS_PIPE_H */ diff --git a/include/sys/select.h b/include/sys/select.h deleted file mode 100644 index ce0d6e9..0000000 --- a/include/sys/select.h +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SELECT_H -#define _SYS_SELECT_H - -#include -#include -#include -#include - -#include - -typedef unsigned long __fd_mask; -typedef __fd_mask fd_mask; - -#ifndef _SIGSET_T_DECLARED -#define _SIGSET_T_DECLARED -typedef __sigset_t sigset_t; -#endif - -/* - * Select uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. - */ -#ifndef FD_SETSIZE -#define FD_SETSIZE 1024 -#endif - -#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */ -#define NFDBITS _NFDBITS - -#ifndef _howmany -#define _howmany(x, y) (((x) + ((y) - 1)) / (y)) -#endif - -typedef struct fd_set { - __fd_mask __fds_bits [_howmany(FD_SETSIZE, _NFDBITS)]; -} fd_set; - -#define fds_bits __fds_bits - -#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) -#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) -#define FD_COPY(f, t) (void)(*(t) = *(f)) -#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) -#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) -#define FD_ZERO(p) do { \ - fd_set *_p; \ - __size_t _n; \ - \ - _p = (p); \ - _n = _howmany(FD_SETSIZE, _NFDBITS); \ - while (_n > 0) \ - _p->__fds_bits[--_n] = 0; \ -} while (0) - -#ifndef _KERNEL - -__BEGIN_DECLS -int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict); - -#ifndef _SELECT_DECLARED -#define _SELECT_DECLARED -/* XXX missing restrict type-qualifier */ -int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -#endif -__END_DECLS -#endif /* !_KERNEL */ - - - -#endif /* END _SYS_SELECT_H */ diff --git a/include/sys/signal.h b/include/sys/signal.h deleted file mode 100644 index 33721d0..0000000 --- a/include/sys/signal.h +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SIGNAL_H -#define _SYS_SIGNAL_H - -#include -#include - -typedef __sigset_t sigset_t; - -#define _SIG_WORDS 4 -#define _SIG_MAXSIG 128 -#define _SIG_IDX(sig) ((sig) - 1) -#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) -#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) -#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) - -// Flags for sigprocmask: -#define SIG_BLOCK 1 /* block specified signal set */ -#define SIG_UNBLOCK 2 /* unblock specified signal set */ -#define SIG_SETMASK 3 /* set specified signal set */ - -union sigval { - /* Members as suggested by Annex C of POSIX 1003.1b. */ - int sival_int; - void *sival_ptr; - /* 6.0 compatibility */ - int sigval_int; - void *sigval_ptr; -}; - -typedef struct __siginfo { - int si_signo; /* signal number */ - int si_errno; /* errno association */ - /* - * Cause of signal, one of the SI_ macros or signal-specific - * values, i.e. one of the FPE_... values for SIGFPE. This - * value is equivalent to the second argument to an old-style - * FreeBSD signal handler. - */ - int si_code; /* signal code */ - __pid_t si_pid; /* sending process */ - __uid_t si_uid; /* sender's ruid */ - int si_status; /* exit value */ - void *si_addr; /* faulting instruction */ - union sigval si_value; /* signal value */ - union { - struct { - int _trapno;/* machine specific trap code */ - } _fault; - struct { - int _timerid; - int _overrun; - } _timer; - struct { - int _mqd; - } _mesgq; - struct { - long _band; /* band event for SIGPOLL */ - } _poll; /* was this ever used ? */ - struct { - long __spare1__; - int __spare2__[7]; - } __spare__; - } _reason; -} siginfo_t; - - -// Signal vector "template" used in sigaction call. -struct sigaction { - union { - void (*__sa_handler)(int); - void (*__sa_sigaction)(int, struct __siginfo *, void *); - } __sigaction_u; /* signal handler */ - int sa_flags; /* see signal options below */ - sigset_t sa_mask; /* signal mask to apply */ -}; - -#define sa_handler __sigaction_u.__sa_handler -#define sa_sigaction __sigaction_u.__sa_sigaction - -#endif /* END _SYS_SIGNAL_H */ diff --git a/include/sys/stdatomic.h b/include/sys/stdatomic.h deleted file mode 100644 index 11f09a9..0000000 --- a/include/sys/stdatomic.h +++ /dev/null @@ -1,411 +0,0 @@ -/*- - * Copyright (c) 2011 Ed Schouten - * David Chisnall - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: releng/11.1/sys/sys/stdatomic.h 263998 2014-04-01 14:46:11Z tijl $ - */ - -#ifndef _STDATOMIC_H_ -#define _STDATOMIC_H_ - -#include -#include - -#if __has_extension(c_atomic) || __has_extension(cxx_atomic) -#define __CLANG_ATOMICS -#elif __GNUC_PREREQ__(4, 7) -#define __GNUC_ATOMICS -#elif defined(__GNUC__) -#define __SYNC_ATOMICS -#else -#error "stdatomic.h does not support your compiler" -#endif - -/* - * 7.17.1 Atomic lock-free macros. - */ - -#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE -#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE -#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE -#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE -#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE -#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE -#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_INT_LOCK_FREE -#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_LONG_LOCK_FREE -#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE -#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE -#endif -#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE -#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE -#endif - -/* - * 7.17.2 Initialization. - */ - -#if defined(__CLANG_ATOMICS) -#define ATOMIC_VAR_INIT(value) (value) -#define atomic_init(obj, value) __c11_atomic_init(obj, value) -#else -#define ATOMIC_VAR_INIT(value) { .__val = (value) } -#define atomic_init(obj, value) ((void)((obj)->__val = (value))) -#endif - -/* - * Clang and recent GCC both provide predefined macros for the memory - * orderings. If we are using a compiler that doesn't define them, use the - * clang values - these will be ignored in the fallback path. - */ - -#ifndef __ATOMIC_RELAXED -#define __ATOMIC_RELAXED 0 -#endif -#ifndef __ATOMIC_CONSUME -#define __ATOMIC_CONSUME 1 -#endif -#ifndef __ATOMIC_ACQUIRE -#define __ATOMIC_ACQUIRE 2 -#endif -#ifndef __ATOMIC_RELEASE -#define __ATOMIC_RELEASE 3 -#endif -#ifndef __ATOMIC_ACQ_REL -#define __ATOMIC_ACQ_REL 4 -#endif -#ifndef __ATOMIC_SEQ_CST -#define __ATOMIC_SEQ_CST 5 -#endif - -/* - * 7.17.3 Order and consistency. - * - * The memory_order_* constants that denote the barrier behaviour of the - * atomic operations. - */ - -typedef enum { - memory_order_relaxed = __ATOMIC_RELAXED, - memory_order_consume = __ATOMIC_CONSUME, - memory_order_acquire = __ATOMIC_ACQUIRE, - memory_order_release = __ATOMIC_RELEASE, - memory_order_acq_rel = __ATOMIC_ACQ_REL, - memory_order_seq_cst = __ATOMIC_SEQ_CST -} memory_order; - -/* - * 7.17.4 Fences. - */ - -static __inline void -atomic_thread_fence(memory_order __order __unused) -{ - -#ifdef __CLANG_ATOMICS - __c11_atomic_thread_fence(__order); -#elif defined(__GNUC_ATOMICS) - __atomic_thread_fence(__order); -#else - __sync_synchronize(); -#endif -} - -static __inline void -atomic_signal_fence(memory_order __order __unused) -{ - -#ifdef __CLANG_ATOMICS - __c11_atomic_signal_fence(__order); -#elif defined(__GNUC_ATOMICS) - __atomic_signal_fence(__order); -#else - __asm volatile ("" ::: "memory"); -#endif -} - -/* - * 7.17.5 Lock-free property. - */ - -#if defined(_KERNEL) -/* Atomics in kernelspace are always lock-free. */ -#define atomic_is_lock_free(obj) \ - ((void)(obj), (_Bool)1) -#elif defined(__CLANG_ATOMICS) -#define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof(*(obj)), obj) -#elif defined(__GNUC_ATOMICS) -#define atomic_is_lock_free(obj) \ - __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) -#else -#define atomic_is_lock_free(obj) \ - ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) -#endif - -/* - * 7.17.6 Atomic integer types. - */ - -typedef _Atomic(_Bool) atomic_bool; -typedef _Atomic(char) atomic_char; -typedef _Atomic(signed char) atomic_schar; -typedef _Atomic(unsigned char) atomic_uchar; -typedef _Atomic(short) atomic_short; -typedef _Atomic(unsigned short) atomic_ushort; -typedef _Atomic(int) atomic_int; -typedef _Atomic(unsigned int) atomic_uint; -typedef _Atomic(long) atomic_long; -typedef _Atomic(unsigned long) atomic_ulong; -typedef _Atomic(long long) atomic_llong; -typedef _Atomic(unsigned long long) atomic_ullong; -typedef _Atomic(__char16_t) atomic_char16_t; -typedef _Atomic(__char32_t) atomic_char32_t; -typedef _Atomic(___wchar_t) atomic_wchar_t; -typedef _Atomic(__int_least8_t) atomic_int_least8_t; -typedef _Atomic(__uint_least8_t) atomic_uint_least8_t; -typedef _Atomic(__int_least16_t) atomic_int_least16_t; -typedef _Atomic(__uint_least16_t) atomic_uint_least16_t; -typedef _Atomic(__int_least32_t) atomic_int_least32_t; -typedef _Atomic(__uint_least32_t) atomic_uint_least32_t; -typedef _Atomic(__int_least64_t) atomic_int_least64_t; -typedef _Atomic(__uint_least64_t) atomic_uint_least64_t; -typedef _Atomic(__int_fast8_t) atomic_int_fast8_t; -typedef _Atomic(__uint_fast8_t) atomic_uint_fast8_t; -typedef _Atomic(__int_fast16_t) atomic_int_fast16_t; -typedef _Atomic(__uint_fast16_t) atomic_uint_fast16_t; -typedef _Atomic(__int_fast32_t) atomic_int_fast32_t; -typedef _Atomic(__uint_fast32_t) atomic_uint_fast32_t; -typedef _Atomic(__int_fast64_t) atomic_int_fast64_t; -typedef _Atomic(__uint_fast64_t) atomic_uint_fast64_t; -typedef _Atomic(__intptr_t) atomic_intptr_t; -typedef _Atomic(__uintptr_t) atomic_uintptr_t; -typedef _Atomic(__size_t) atomic_size_t; -typedef _Atomic(__ptrdiff_t) atomic_ptrdiff_t; -typedef _Atomic(__intmax_t) atomic_intmax_t; -typedef _Atomic(__uintmax_t) atomic_uintmax_t; - -/* - * 7.17.7 Operations on atomic types. - */ - -/* - * Compiler-specific operations. - */ - -#if defined(__CLANG_ATOMICS) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) \ - __c11_atomic_compare_exchange_strong(object, expected, desired, \ - success, failure) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - __c11_atomic_compare_exchange_weak(object, expected, desired, \ - success, failure) -#define atomic_exchange_explicit(object, desired, order) \ - __c11_atomic_exchange(object, desired, order) -#define atomic_fetch_add_explicit(object, operand, order) \ - __c11_atomic_fetch_add(object, operand, order) -#define atomic_fetch_and_explicit(object, operand, order) \ - __c11_atomic_fetch_and(object, operand, order) -#define atomic_fetch_or_explicit(object, operand, order) \ - __c11_atomic_fetch_or(object, operand, order) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __c11_atomic_fetch_sub(object, operand, order) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __c11_atomic_fetch_xor(object, operand, order) -#define atomic_load_explicit(object, order) \ - __c11_atomic_load(object, order) -#define atomic_store_explicit(object, desired, order) \ - __c11_atomic_store(object, desired, order) -#elif defined(__GNUC_ATOMICS) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) \ - __atomic_compare_exchange_n(&(object)->__val, expected, \ - desired, 0, success, failure) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - __atomic_compare_exchange_n(&(object)->__val, expected, \ - desired, 1, success, failure) -#define atomic_exchange_explicit(object, desired, order) \ - __atomic_exchange_n(&(object)->__val, desired, order) -#define atomic_fetch_add_explicit(object, operand, order) \ - __atomic_fetch_add(&(object)->__val, operand, order) -#define atomic_fetch_and_explicit(object, operand, order) \ - __atomic_fetch_and(&(object)->__val, operand, order) -#define atomic_fetch_or_explicit(object, operand, order) \ - __atomic_fetch_or(&(object)->__val, operand, order) -#define atomic_fetch_sub_explicit(object, operand, order) \ - __atomic_fetch_sub(&(object)->__val, operand, order) -#define atomic_fetch_xor_explicit(object, operand, order) \ - __atomic_fetch_xor(&(object)->__val, operand, order) -#define atomic_load_explicit(object, order) \ - __atomic_load_n(&(object)->__val, order) -#define atomic_store_explicit(object, desired, order) \ - __atomic_store_n(&(object)->__val, desired, order) -#else -#define __atomic_apply_stride(object, operand) \ - (((__typeof__((object)->__val))0) + (operand)) -#define atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) __extension__ ({ \ - __typeof__(expected) __ep = (expected); \ - __typeof__(*__ep) __e = *__ep; \ - (void)(success); (void)(failure); \ - (_Bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ - __e, desired)) == __e); \ -}) -#define atomic_compare_exchange_weak_explicit(object, expected, \ - desired, success, failure) \ - atomic_compare_exchange_strong_explicit(object, expected, \ - desired, success, failure) -#if __has_builtin(__sync_swap) -/* Clang provides a full-barrier atomic exchange - use it if available. */ -#define atomic_exchange_explicit(object, desired, order) \ - ((void)(order), __sync_swap(&(object)->__val, desired)) -#else -/* - * __sync_lock_test_and_set() is only an acquire barrier in theory (although in - * practice it is usually a full barrier) so we need an explicit barrier before - * it. - */ -#define atomic_exchange_explicit(object, desired, order) \ -__extension__ ({ \ - __typeof__(object) __o = (object); \ - __typeof__(desired) __d = (desired); \ - (void)(order); \ - __sync_synchronize(); \ - __sync_lock_test_and_set(&(__o)->__val, __d); \ -}) -#endif -#define atomic_fetch_add_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_add(&(object)->__val, \ - __atomic_apply_stride(object, operand))) -#define atomic_fetch_and_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) -#define atomic_fetch_or_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) -#define atomic_fetch_sub_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ - __atomic_apply_stride(object, operand))) -#define atomic_fetch_xor_explicit(object, operand, order) \ - ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) -#define atomic_load_explicit(object, order) \ - ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) -#define atomic_store_explicit(object, desired, order) \ - ((void)atomic_exchange_explicit(object, desired, order)) -#endif - -/* - * Convenience functions. - * - * Don't provide these in kernel space. In kernel space, we should be - * disciplined enough to always provide explicit barriers. - */ - -#ifndef _KERNEL -#define atomic_compare_exchange_strong(object, expected, desired) \ - atomic_compare_exchange_strong_explicit(object, expected, \ - desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, \ - desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_exchange(object, desired) \ - atomic_exchange_explicit(object, desired, memory_order_seq_cst) -#define atomic_fetch_add(object, operand) \ - atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_and(object, operand) \ - atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_or(object, operand) \ - atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_sub(object, operand) \ - atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) -#define atomic_fetch_xor(object, operand) \ - atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) -#define atomic_load(object) \ - atomic_load_explicit(object, memory_order_seq_cst) -#define atomic_store(object, desired) \ - atomic_store_explicit(object, desired, memory_order_seq_cst) -#endif /* !_KERNEL */ - -/* - * 7.17.8 Atomic flag type and operations. - * - * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some - * kind of compiler built-in type we could use? - */ - -typedef struct { - atomic_bool __flag; -} atomic_flag; - -#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } - -static __inline _Bool -atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, - memory_order __order) -{ - return (atomic_exchange_explicit(&__object->__flag, 1, __order)); -} - -static __inline void -atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) -{ - - atomic_store_explicit(&__object->__flag, 0, __order); -} - -#ifndef _KERNEL -static __inline _Bool -atomic_flag_test_and_set(volatile atomic_flag *__object) -{ - - return (atomic_flag_test_and_set_explicit(__object, - memory_order_seq_cst)); -} - -static __inline void -atomic_flag_clear(volatile atomic_flag *__object) -{ - - atomic_flag_clear_explicit(__object, memory_order_seq_cst); -} -#endif /* !_KERNEL */ - -#endif /* !_STDATOMIC_H_ */ diff --git a/include/sys/stdint.h b/include/sys/stdint.h deleted file mode 100644 index 489cd4b..0000000 --- a/include/sys/stdint.h +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Copyright (c) 2001 Mike Barcroft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: releng/11.2/sys/sys/stdint.h 331722 2018-03-29 02:50:57Z eadler $ - */ - -#ifndef _SYS_STDINT_H_ -#define _SYS_STDINT_H_ - -#include -#include - -#include -#include - -typedef __int_least8_t int_least8_t; -typedef __int_least16_t int_least16_t; -typedef __int_least32_t int_least32_t; -typedef __int_least64_t int_least64_t; - -typedef __uint_least8_t uint_least8_t; -typedef __uint_least16_t uint_least16_t; -typedef __uint_least32_t uint_least32_t; -typedef __uint_least64_t uint_least64_t; - -typedef __int_fast8_t int_fast8_t; -typedef __int_fast16_t int_fast16_t; -typedef __int_fast32_t int_fast32_t; -typedef __int_fast64_t int_fast64_t; - -typedef __uint_fast8_t uint_fast8_t; -typedef __uint_fast16_t uint_fast16_t; -typedef __uint_fast32_t uint_fast32_t; -typedef __uint_fast64_t uint_fast64_t; - -/* GNU and Darwin define this and people seem to think it's portable */ -#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX) -#define __WORDSIZE 64 -#else -#define __WORDSIZE 32 -#endif - -/* Limits of wchar_t. */ -#define WCHAR_MIN __WCHAR_MIN -#define WCHAR_MAX __WCHAR_MAX - -#if __EXT1_VISIBLE -/* ISO/IEC 9899:2011 K.3.4.4 */ -#ifndef RSIZE_MAX -#define RSIZE_MAX (SIZE_MAX >> 1) -#endif -#endif /* __EXT1_VISIBLE */ - -#endif /* !_SYS_STDINT_H_ */ diff --git a/include/sys/sysproto.h b/include/sys/sysproto.h deleted file mode 100644 index 678756a..0000000 --- a/include/sys/sysproto.h +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SYSPROTO_H -#define _SYS_SYSPROTO_H - -#include - -typedef int register_t; - -#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? 0 : sizeof(register_t) - sizeof(t)) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define PADL_(t) 0 -#define PADR_(t) PAD_(t) -#else -#define PADL_(t) PAD_(t) -#define PADR_(t) 0 -#endif - -//Protos -struct sys_mpiCreateMbox_args { - char name_l_[PADL_(char *)]; - char *name; - char name_r_[PADR_(char *)]; -}; - -struct sys_mpiDestroyMbox_args { - char name_l_[PADL_(char *)]; - char *name; - char name_r_[PADR_(char *)]; -}; - -struct sys_mpiFetchMessage_args { - char name_l_[PADL_(char *)]; - char *name; - char name_r_[PADR_(char *)]; - char msg_l_[PADL_(const void *)]; - const void * msg; - char msg_r_[PADR_(const void *)]; -}; - -struct sys_mpiPostMessage_args { - char name_l_[PADL_(char *)]; - char *name; - char name_r_[PADR_(char *)]; - char type_l_[PADL_(uint32_t)]; - uint32_t type; - char type_r_[PADR_(uint32_t)]; - char msg_l_[PADL_(const void *)]; - const void *msg; - char msg_r_[PADR_(const void *)]; -}; - -struct sys_sde_args { - char cmd_l_[PADL_(uint32_t)]; - uint32_t cmd; - char cmd_r_[PADR_(uint32_t)]; - char ptr_l_[PADL_(uint32_t)]; - uint32_t ptr; - char ptr_r_[PADR_(uint32_t)]; -}; - - -//Func Defs -int sys_invalid(struct thread *, void *); -int sys_mpiCreateMbox(struct thread *, struct sys_mpiCreateMbox_args *); -int sys_mpiDestroyMbox(struct thread *, struct sys_mpiDestroyMbox_args *); -int sys_mpiFetchMessage(struct thread *, struct sys_mpiFetchMessage_args *); -int sys_mpiPostMessage(struct thread *, struct sys_mpiPostMessage_args *); - -#endif diff --git a/include/sys/sysproto_posix.h b/include/sys/sysproto_posix.h deleted file mode 100644 index 2ac3c0b..0000000 --- a/include/sys/sysproto_posix.h +++ /dev/null @@ -1,798 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_SYSPROTO_POSIX_H -#define _SYS_SYSPROTO_POSIX_H - -#include -#include - - -/* TEMP */ -#include - -typedef int register_t; - -#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? 0 : sizeof(register_t) - sizeof(t)) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define PADL_(t) 0 -#define PADR_(t) PAD_(t) -#else -#define PADL_(t) PAD_(t) -#define PADR_(t) 0 -#endif - -//Protos -struct sys_exit_args { - char status_l_[PADL_(int)]; - int status; - char status_r_[PADR_(int)]; -}; - -struct sys_fork_args { - char status_l_[PADL_(int)]; - int status; - char status_r_[PADR_(int)]; -}; - -struct sys_read_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(const void *)]; - const void * buf; - char buf_r_[PADR_(const void *)]; - char nbyte_l_[PADL_(size_t)]; - size_t nbyte; - char nbyte_r_[PADR_(size_t)]; -}; - -struct sys_write_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - - char buf_l_[PADL_(const void *)]; - const void * buf; - char buf_r_[PADR_(const void *)]; - - char nbyte_l_[PADL_(size_t)]; - size_t nbyte; - char nbyte_r_[PADR_(size_t)]; -}; - -struct sys_open_args { - char path_l_[PADL_(char *)]; - char *path; - char path_r_[PADR_(char *)]; - - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; - - char mode_l_[PADL_(int)]; - int mode; - char mode_r_[PADR_(int)]; -}; - -struct sys_close_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; -}; - -struct sys_wait4_args { - char pid_l_[PADL_(int)]; - int pid; - char pid_r_[PADR_(int)]; - - char status_l_[PADL_(int *)]; - int *status; - char status_r_[PADR_(int *)]; - - char options_l_[PADL_(int)]; - int options; - char options_r_[PADR_(int)]; - - char rusage_l_[PADL_(void *)]; - void *rusage; - char rusage_r_[PADR_(void *)]; -}; - -struct sys_chdir_args { - char path_l_[PADL_(char *)]; - char *path; - char path_r_[PADR_(char *)]; -}; - -struct sys_getcwd_args { - char buf_l_[PADL_(const void *)]; - void *buf; - char buf_r_[PADR_(const void *)]; - - char size_l_[PADL_(uint32_t)]; - uint32_t size; - char size_r_[PADR_(uint32_t)]; -}; - -struct sys_setUID_args { - char uid_l_[PADL_(int)]; - int uid; - char uid_r_[PADR_(int)]; -}; - -struct sys_setGID_args { - char gid_l_[PADL_(int)]; - int gid; - char gid_r_[PADR_(int)]; -}; - -struct sys_execve_args { - char fname_l_[PADL_(char *)]; - char *fname; - char fname_r_[PADR_(char *)]; - char argv_l_[PADL_(char **)]; - char **argv; - char argv_r_[PADR_(char **)]; - char envp_l_[PADL_(char **)]; - char **envp; - char envp_r_[PADR_(char **)]; -}; - -struct sys_fopen_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char mode_l_[PADL_(char *)]; - char * mode; - char mode_r_[PADR_(char *)]; - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fread_args { - char ptr_l_[PADL_(void *)]; - void *ptr; - char ptr_r_[PADR_(void *)]; - char size_l_[PADL_(long)]; - long size; - char size_r_[PADR_(long)]; - char nmemb_l_[PADL_(long)]; - long nmemb; - char nmemb_r_[PADR_(long)]; - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fclose_args { - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fgetc_args { - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; -}; - -struct sys_fseek_args { - char FILE_l_[PADL_(userFileDescriptor *)]; - userFileDescriptor *FILE; - char FILE_r_[PADR_(userFileDescriptor *)]; - char offset_l_[PADL_(off_t)]; - off_t offset; - char offset_r_[PADR_(off_t)]; - char whence_l_[PADL_(int)]; - int whence; - char whence_r_[PADR_(int)]; -}; - -struct sys_lseek_args { - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; - char whence_l_[PADL_(int)]; int whence; char whence_r_[PADR_(int)]; -}; - -struct sys_sysctl_args { - char name_l_[PADL_(int *)]; - int *name; - char name_r_[PADR_(int *)]; - char namelen_l_[PADL_(u_int)]; - u_int namelen; - char namelen_r_[PADR_(u_int)]; - char oldp_l_[PADL_(void *)]; - void *oldp; - char oldp_r_[PADR_(void *)]; - char oldlenp_l_[PADL_(size_t *)]; - size_t *oldlenp; - char oldlenp_r_[PADR_(size_t *)]; - char newp_l_[PADL_(void *)]; - void *newp; - char newp_r_[PADR_(void *)]; - char newlenp_l_[PADL_(size_t)]; - size_t newlenp; - char newlenp_r_[PADR_(size_t)]; - -}; - -/* fcntl args */ -struct sys_fcntl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char cmd_l_[PADL_(int)]; - int cmd; - char cmd_r_[PADR_(int)]; - char arg_l_[PADL_(long)]; - long arg; - char arg_r_[PADR_(long)]; -}; - - -/* OLD */ - -struct setitimer_args { - char which_l_[PADL_(u_int)]; - u_int which; - char which_r_[PADR_(u_int)]; - char itv_l_[PADL_(struct itimerval *)]; - struct itimerval * itv; - char itv_r_[PADR_(struct itimerval *)]; - char oitv_l_[PADL_(struct itimerval *)]; - struct itimerval * oitv; - char oitv_r_[PADR_(struct itimerval *)]; -}; - -struct access_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; -}; - -struct sys_fstatfs_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(struct statfs *)]; - struct statfs * buf; - char buf_r_[PADR_(struct statfs *)]; -}; - -struct mprotect_args { - char addr_l_[PADL_(const void *)]; - const void * addr; - char addr_r_[PADR_(const void *)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; - char prot_l_[PADL_(int)]; - int prot; - char prot_r_[PADR_(int)]; -}; - -//Old - -struct sysctl_args { - char name_l_[PADL_(int *)]; - int * name; - char name_r_[PADR_(int *)]; - char namelen_l_[PADL_(u_int)]; - u_int namelen; - char namelen_r_[PADR_(u_int)]; - char old_l_[PADL_(void *)]; - void *oldp; - char old_r_[PADR_(void *)]; - char oldlenp_l_[PADL_(size_t *)]; - size_t * oldlenp; - char oldlenp_r_[PADR_(size_t *)]; - char new_l_[PADL_(void *)]; - void * newp; - char new_r_[PADR_(void *)]; - char newlen_l_[PADL_(size_t)]; - size_t newlen; - char newlen_r_[PADR_(size_t)]; -}; - -struct getpid_args { - register_t dummy; -}; -struct sys_issetugid_args { - register_t dummy; -}; -struct fcntl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char cmd_l_[PADL_(int)]; - int cmd; - char cmd_r_[PADR_(int)]; - char arg_l_[PADL_(long)]; - long arg; - char arg_r_[PADR_(long)]; -}; - -struct pipe_args { - register_t dummy; -}; - -struct readlink_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char buf_l_[PADL_(char *)]; - char * buf; - char buf_r_[PADR_(char *)]; - char count_l_[PADL_(int)]; - int count; - char count_r_[PADR_(int)]; -}; - -struct getuid_args { - register_t dummy; -}; - -struct getgid_args { - register_t dummy; -}; -struct close_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; -}; - -struct sys_mmap_args { - char addr_l_[PADL_(caddr_t)]; - caddr_t addr; - char addr_r_[PADR_(caddr_t)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; - char prot_l_[PADL_(int)]; - int prot; - char prot_r_[PADR_(int)]; - char flags_l_[PADL_(int)]; - int flags; - char flags_r_[PADR_(int)]; - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char pos_l_[PADL_(off_t)]; - off_t pos; - char pos_r_[PADR_(off_t)]; -}; - -struct sys_stat_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char ub_l_[PADL_(struct stat *)]; - struct stat * ub; - char ub_r_[PADR_(struct stat *)]; -}; - -struct sys_lstat_args { - char path_l_[PADL_(char *)]; - char *path; - char path_r_[PADR_(char *)]; - char sb_l_[PADL_(struct stat *)]; - struct stat *sb; - char sb_r_[PADR_(struct stat *)]; -}; - -struct obreak_args { - char nsize_l_[PADL_(char *)]; - char * nsize; - char nsize_r_[PADR_(char *)]; -}; - -struct sigaction_args { - char sig_l_[PADL_(int)]; - int sig; - char sig_r_[PADR_(int)]; - char act_l_[PADL_(const struct sigaction *)]; - const struct sigaction * act; - char act_r_[PADR_(const struct sigaction *)]; - char oact_l_[PADL_(struct sigaction *)]; - struct sigaction * oact; - char oact_r_[PADR_(struct sigaction *)]; -}; - -struct getdtablesize_args { - register_t dummy; -}; - -struct sys_munmap_args { - char addr_l_[PADL_(void *)]; - void * addr; - char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; -}; - -struct sigprocmask_args { - char how_l_[PADL_(int)]; - int how; - char how_r_[PADR_(int)]; - char set_l_[PADL_(const sigset_t *)]; - const sigset_t * set; - char set_r_[PADR_(const sigset_t *)]; - char oset_l_[PADL_(sigset_t *)]; - sigset_t * oset; - char oset_r_[PADR_(sigset_t *)]; -}; -struct gettimeofday_args { - char tp_l_[PADL_(struct timeval *)]; - struct timeval * tp; - char tp_r_[PADR_(struct timeval *)]; - char tzp_l_[PADL_(struct timezone *)]; - struct timezone * tzp; - char tzp_r_[PADR_(struct timezone *)]; -}; -struct sys_fstat_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char sb_l_[PADL_(struct stat *)]; - struct stat * sb; - char sb_r_[PADR_(struct stat *)]; -}; -struct ioctl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char com_l_[PADL_(u_long)]; - u_long com; - char com_r_[PADR_(u_long)]; - char data_l_[PADL_(caddr_t)]; - caddr_t data; - char data_r_[PADR_(caddr_t)]; -}; - -struct read_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(void *)]; - void * buf; - char buf_r_[PADR_(void *)]; - char nbyte_l_[PADL_(size_t)]; - size_t nbyte; - char nbyte_r_[PADR_(size_t)]; -}; - -struct sys_openat_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char flag_l_[PADL_(int)]; - int flag; - char flag_r_[PADR_(int)]; - char mode_l_[PADL_(__mode_t)]; - __mode_t mode; - char mode_r_[PADR_(__mode_t)]; -}; - -struct sys_sysarch_args { - char op_l_[PADL_(int)]; - int op; - char op_r_[PADR_(int)]; - char parms_l_[PADL_(char *)]; - char * parms; - char parms_r_[PADR_(char *)]; -}; - -struct sys_getpid_args { - register_t dummy; -}; - -struct sys_ioctl_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char com_l_[PADL_(u_long)]; - u_long com; - char com_r_[PADR_(u_long)]; - char data_l_[PADL_(caddr_t)]; - caddr_t data; - char data_r_[PADR_(caddr_t)]; -}; - -struct sys_geteuid_args { - register_t dummy; -}; - -struct sys_getppid_args { - register_t dummy; -}; - -struct sys_getegid_args { - register_t dummy; -}; - -struct sys_sigprocmask_args { - char how_l_[PADL_(int)]; - int how; - char how_r_[PADR_(int)]; - char set_l_[PADL_(const sigset_t *)]; - const sigset_t * set; - char set_r_[PADR_(const sigset_t *)]; - char oset_l_[PADL_(sigset_t *)]; - sigset_t * oset; - char oset_r_[PADR_(sigset_t *)]; -}; - -struct sys_sigaction_args { - char sig_l_[PADL_(int)]; - int sig; - char sig_r_[PADR_(int)]; - char act_l_[PADL_(const struct sigaction *)]; - const struct sigaction * act; - char act_r_[PADR_(const struct sigaction *)]; - char oact_l_[PADL_(struct sigaction *)]; - struct sigaction * oact; - char oact_r_[PADR_(struct sigaction *)]; -}; - -struct sys_getpgrp_args { - register_t dummy; -}; -struct sys_setpgid_args { - char pid_l_[PADL_(int)]; - int pid; - char pid_r_[PADR_(int)]; - char pgid_l_[PADL_(int)]; - int pgid; - char pgid_r_[PADR_(int)]; -}; - -struct sys_access_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char amode_l_[PADL_(int)]; - int amode; - char amode_r_[PADR_(int)]; -}; - -struct sys_statfs_args { - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char buf_l_[PADL_(struct statfs *)]; - struct statfs * buf; - char buf_r_[PADR_(struct statfs *)]; -}; - -struct sys_fstatat_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char path_l_[PADL_(char *)]; - char * path; - char path_r_[PADR_(char *)]; - char buf_l_[PADL_(struct stat *)]; - struct stat * buf; - char buf_r_[PADR_(struct stat *)]; - char flag_l_[PADL_(int)]; - int flag; - char flag_r_[PADR_(int)]; -}; - -struct sys_fchdir_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; -}; - -struct sys_getdirentries_args { - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - char buf_l_[PADL_(char *)]; - char * buf; - char buf_r_[PADR_(char *)]; - char count_l_[PADL_(u_int)]; - u_int count; - char count_r_[PADR_(u_int)]; - char basep_l_[PADL_(long *)]; - long * basep; - char basep_r_[PADR_(long *)]; -}; - -struct sys_socket_args { - char domain_l_[PADL_(int)]; - int domain; - char domain_r_[PADR_(int)]; - char type_l_[PADL_(int)]; - int type; - char type_r_[PADR_(int)]; - char protocol_l_[PADL_(int)]; - int protocol; - char protocol_r_[PADR_(int)]; -}; - -struct sys_setsockopt_args { - char s_l_[PADL_(int)]; - int s; - char s_r_[PADR_(int)]; - char level_l_[PADL_(int)]; - int level; - char level_r_[PADR_(int)]; - char name_l_[PADL_(int)]; - int name; - char name_r_[PADR_(int)]; - char val_l_[PADL_(caddr_t)]; - caddr_t val; - char val_r_[PADR_(caddr_t)]; - char valsize_l_[PADL_(int)]; - int valsize; - char valsize_r_[PADR_(int)]; -}; - -struct sys_select_args { - char nd_l_[PADL_(int)]; - int nd; - char nd_r_[PADR_(int)]; - char in_l_[PADL_(fd_set *)]; - fd_set * in; - char in_r_[PADR_(fd_set *)]; - char ou_l_[PADL_(fd_set *)]; - fd_set * ou; - char ou_r_[PADR_(fd_set *)]; - char ex_l_[PADL_(fd_set *)]; - fd_set * ex; - char ex_r_[PADR_(fd_set *)]; - char tv_l_[PADL_(struct timeval *)]; - struct timeval * tv; - char tv_r_[PADR_(struct timeval *)]; -}; - -struct sys_gettimeofday_args { - char tp_l_[PADL_(struct timeval *)]; struct timeval * tp; char tp_r_[PADR_(struct timeval *)]; - char tzp_l_[PADL_(struct timezone *)]; struct timezone * tzp; char tzp_r_[PADR_(struct timezone *)]; -}; - - -struct sys_sendto_args { - char s_l_[PADL_(int)]; int s; char s_r_[PADR_(int)]; - char buf_l_[PADL_(caddr_t)]; caddr_t buf; char buf_r_[PADR_(caddr_t)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; - char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)]; - char to_l_[PADL_(caddr_t)]; caddr_t to; char to_r_[PADR_(caddr_t)]; - char tolen_l_[PADL_(int)]; int tolen; char tolen_r_[PADR_(int)]; -}; - -struct sys_rename_args { - char from_l_[PADL_(char *)]; char * from; char from_r_[PADR_(char *)]; - char to_l_[PADL_(char *)]; char * to; char to_r_[PADR_(char *)]; -}; - -struct sys_pread_args { - char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; - char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; - char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; - char offset_l_[PADL_(off_t)]; off_t offset; char offset_r_[PADR_(off_t)]; -}; - - -//Func Defs -int sys_invalid(struct thread *, void *); -int sys_exit(struct thread *, struct sys_exit_args *); -int sys_fork(struct thread *, struct sys_fork_args *); -int sys_read(struct thread *, struct sys_read_args *); -int sys_write(struct thread *td, struct sys_write_args *); -int sys_open(struct thread *td, struct sys_open_args *); -int sys_close(struct thread *td, struct sys_close_args *); -int sys_wait4(struct thread *td, struct sys_wait4_args *); -int sys_chdir(struct thread *td, struct sys_chdir_args *); - -int sys_setUID(struct thread *td, struct sys_setUID_args *); -int sys_getUID(struct thread *td, void *); -int sys_setGID(struct thread *td, struct sys_setGID_args *); -int sys_getGID(struct thread *td, void *); - -int sys_execve(struct thread *td, struct sys_execve_args *); - -int sys_fopen(struct thread *td, struct sys_fopen_args *); -int sys_fread(struct thread *td, struct sys_fread_args *); -int sys_fclose(struct thread *td, struct sys_fclose_args *); -int sys_fgetc(struct thread *td, struct sys_fgetc_args *); -int sys_fseek(struct thread *td, struct sys_fseek_args *); -int sys_lseek(struct thread *td, struct sys_lseek_args *); - -int sys_sched_yield(struct thread *td, void *); - -int sys_getcwd(struct thread *td, struct sys_getcwd_args *); - -int sys_mmap(struct thread *td, struct sys_mmap_args *); -int sys_munmap(struct thread *td, struct sys_munmap_args *); -int sys_sysctl(struct thread *td, struct sys_sysctl_args *); - -int sys_issetugid(struct thread *td, struct sys_issetugid_args *); - -int setitimer(struct thread *td, struct setitimer_args *uap); -int access(struct thread *td, struct access_args *uap); -int fstatfs(struct thread *td, struct sys_fstatfs_args *uap); -int mprotect(struct thread *td, struct mprotect_args *uap); - -int sys_statfs(struct thread *td, struct sys_statfs_args *args); -int sys_fstatfs(struct thread *td, struct sys_fstatfs_args *); -int sys_stat(struct thread *td, struct sys_stat_args *); -int sys_lstat(struct thread *td, struct sys_lstat_args *); -int sys_fstat(struct thread *td, struct sys_fstat_args *); -int sys_fstatat(struct thread *td, struct sys_fstatat_args *); -int sys_openat(struct thread *td, struct sys_openat_args *); - -int sys_sysarch(struct thread *td, struct sys_sysarch_args *); -int sys_getpid(struct thread *td, struct sys_getpid_args *); -int sys_ioctl(struct thread *td, struct sys_ioctl_args *); - -int sys_geteuid(struct thread *td, struct sys_geteuid_args *); - -int sys_getegid(struct thread *td, struct sys_getegid_args *); - -int sys_getppid(struct thread *td, struct sys_getppid_args *); - -int sys_getpgrp(struct thread *td, struct sys_getpgrp_args *); -int sys_setpgrp(struct thread *td, struct sys_setpgid_args *); - -int sys_sigprocmask(struct thread *td, struct sys_sigprocmask_args *); -int sys_sigaction(struct thread *td, struct sys_sigaction_args *); - -int sys_getpgrp(struct thread *td, struct sys_getpgrp_args *); -int sys_setpgid(struct thread *td, struct sys_setpgid_args *); - -int sys_access(struct thread *td, struct sys_access_args *); -int sys_fchdir(struct thread *td, struct sys_fchdir_args *); - -int sys_getdirentries(struct thread *td, struct sys_getdirentries_args *); - -int sys_socket(struct thread *td, struct sys_socket_args *); -int sys_setsockopt(struct thread *td, struct sys_setsockopt_args *); -int sys_select(struct thread *td, struct sys_select_args *); - -int sys_rename(struct thread *td, struct sys_rename_args *); - -int sys_fcntl(struct thread *td, struct sys_fcntl_args *); - -int sys_gettimeofday(struct thread *td, struct sys_gettimeofday_args *); -int sys_sendto(struct thread *td, struct sys_sendto_args *); - -int sys_pread(struct thread *td, struct sys_pread_args *); -#endif /* END _SYS_SYSPROTO_POSIX_H */ diff --git a/include/sys/thread.h b/include/sys/thread.h deleted file mode 100644 index 23b5d1f..0000000 --- a/include/sys/thread.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_THREAD_H -#define _SYS_THREAD_H - -#include -#include -#include - -#define O_FILES 64 - -struct thread { - int td_retval[2]; - void *o_files[O_FILES]; - u_long vm_daddr; - u_long vm_dsize; - u_long vm_taddr; - u_long vm_tsize; - struct trapframe *frame; - int abi; - sigset_t sigmask; - struct sigaction sigact[128]; -}; - -#endif /* END _SYS_THREAD_H */ diff --git a/include/sys/trap.h b/include/sys/trap.h deleted file mode 100644 index cf7ebc5..0000000 --- a/include/sys/trap.h +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TRAP_H -#define _SYS_TRAP_H - -#include - -struct trapframe { - int tf_gs; - int tf_fs; - int tf_es; - int tf_ds; - int tf_edi; - int tf_esi; - int tf_ebp; - int tf_isp; - int tf_ebx; - int tf_edx; - int tf_ecx; - int tf_eax; - int tf_trapno; - /* below portion defined in 386 hardware */ - int tf_err; - int tf_eip; - int tf_cs; - int tf_eflags; - /* below only when crossing rings (e.g. user to kernel) */ - int tf_esp; - int tf_ss; -}; - -void die_if_kernel(char *str, struct trapframe *regs, long err); -void trap( struct trapframe * ); - -#endif /* END _SYS_TRAP_H */ diff --git a/include/sys/tss.h b/include/sys/tss.h deleted file mode 100644 index c4d7379..0000000 --- a/include/sys/tss.h +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TSS_H -#define _SYS_TSS_H - -#include - -struct tssStruct { - short back_link; - short back_link_reserved; - long esp0; - short ss0; - short ss0_reserved; - long esp1; - short ss1; - short ss1_reserved; - long esp2; - short ss2; - short ss2_reserved; - long cr3; - long eip; - long eflags; - long eax, ecx, edx, ebx; - long esp; - long ebp; - long esi; - long edi; - short es; - short es_reserved; - short cs; - short cs_reserved; - short ss; - short ss_reserved; - short ds; - short ds_reserved; - short fs; - short fs_reserved; - short gs; - short gs_reserved; - short ldt; - short ldt_reserved; - short trace_bitmap; - short io_map; - char io_space[8192]; -}; - -struct i387Struct { - long cwd; - long swd; - long twd; - long fip; - long fcs; - long foo; - long fos; - long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ -}; - -struct i386_frame { - uint32_t gs; - uint32_t fs; - uint32_t es; - uint32_t ds; - uint32_t ss; - uint32_t edi; - uint32_t esi; - uint32_t ebp; - uint32_t esp; - uint32_t ebx; - uint32_t edx; - uint32_t ecx; - uint32_t eax; - /* - uint32_t vector; - uint32_t error_code; - */ - uint32_t eip; - uint32_t cs; - uint32_t flags; - uint32_t user_esp; - uint32_t user_ss; -}; - -#endif /* END _SYS_TSS_H */ diff --git a/include/sys/types.h b/include/sys/types.h deleted file mode 100644 index b78d9aa..0000000 --- a/include/sys/types.h +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TYPES_H_ -#define _SYS_TYPES_H_ - -#include -#include - -#ifndef NULL -#define NULL 0x0 -#endif - -typedef __uintfptr_t uintfptr_t; - -typedef char *caddr_t; - -/* POSIX integrals that should only appear only in */ -#include - -/* unsigned integrals */ -typedef __uint8_t uint8_t; -typedef __uint16_t uint16_t; -typedef __uint32_t uint32_t; -typedef __uint64_t uint64_t; -typedef __uint64_t uquad_t; - -/* unsigned integrals (deprecated) */ -typedef __uint8_t u_int8_t; -typedef __uint16_t u_int16_t; -typedef __uint32_t u_int32_t; -typedef __uint64_t u_int64_t; -typedef __uint64_t u_quad_t; - -typedef __int64_t quad_t; - -typedef __int64_t daddr_t; /* disk address */ -typedef __uint32_t u_daddr_t; /* unsigned disk address */ - -typedef unsigned char uInt8; -typedef unsigned short uInt16; -typedef unsigned int uInt32; -typedef unsigned int uInt; -typedef char Int8; -typedef short Int16; -typedef long Int32; - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; - -typedef int pidType; - -typedef int pid_t; - -#ifndef _SIZE_T_DECLARED -typedef __size_t size_t; -#define _SIZE_T_DECLARED -#endif - - -#ifndef NOBOOL -#ifndef __cplusplus -typedef enum {FALSE=0,TRUE=1}bool; -#endif -#else -#ifndef __cplusplus -#define FALSE 0 -#define TRUE 1 -typedef int bool; -#endif -#endif - -#ifndef _INO_T_DECLARED -typedef __ino_t ino_t; /* inode number */ -#define _INO_T_DECLARED -#endif - -#ifndef _INT8_T_DECLARED -typedef __int8_t int8_t; -#define _INT8_T_DECLARED -#endif - -#ifndef _INT16_T_DECLARED -typedef __int16_t int16_t; -#define _INT16_T_DECLARED -#endif - -#ifndef _INT32_T_DECLARED -typedef __int32_t int32_t; -#define _INT32_T_DECLARED -#endif - -#ifndef _INT64_T_DECLARED -typedef __int64_t int64_t; -#define _INT64_T_DECLARED -#endif - -typedef __ssize_t ssize_t; -typedef char * caddr_t; -typedef __int64_t off_t; -typedef __uint32_t vm_offset_t; - -typedef __uid_t uid_t; /* user id */ -typedef __gid_t gid_t; /* group id */ -typedef __blkcnt_t blkcnt_t; -typedef __blksize_t blksize_t; -typedef __fflags_t fflags_t; - -#ifndef _TIME_T_DECLARED -typedef __time_t time_t; -#define _TIME_T_DECLARED -#endif - -#define __ULONG_MAX 0xffffffffUL -#define __USHRT_MAX 0xffff /* max value for an unsigned short */ - -#define ULONG_MAX __ULONG_MAX -#define USHRT_MAX __USHRT_MAX - -/* select a type for digits in base B: use unsigned short if they fit */ -#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff -typedef unsigned short digit; -#else -typedef u_long digit; -#endif - -#define _QUAD_HIGHWORD 1 -#define _QUAD_LOWWORD 0 - -#define H _QUAD_HIGHWORD -#define L _QUAD_LOWWORD - -#define __CHAR_BIT 8 -#define CHAR_BIT __CHAR_BIT - -#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) -#define LONG_BITS (sizeof(long) * CHAR_BIT) -#define HALF_BITS (sizeof(long) * CHAR_BIT / 2) -#define HHALF(x) ((x) >> HALF_BITS) -#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) -#define LHUP(x) ((x) << HALF_BITS) - -typedef unsigned int qshift_t; - -#define B (1 << HALF_BITS) /* digit base */ - -/* Combine two `digits' to make a single two-digit number. */ -#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b)) - - -#ifndef _MODE_T_DECLARED -typedef __mode_t mode_t; /* permissions */ -#define _MODE_T_DECLARED -#endif - -#endif /* END _SYS_TYPES_H */ diff --git a/include/sys/uuid.h b/include/sys/uuid.h deleted file mode 100644 index 2593d99..0000000 --- a/include/sys/uuid.h +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 2002 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: releng/10.2/sys/sys/uuid.h 253590 2013-07-24 04:24:21Z marcel $ - */ - -#ifndef _SYS_UUID_H_ -#define _SYS_UUID_H_ - -#include -#include - -/* Length of a node address (an IEEE 802 address). */ -#define _UUID_NODE_LEN 6 - -/* - * See also: - * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt - * http://www.opengroup.org/onlinepubs/009629399/apdxa.htm - * - * A DCE 1.1 compatible source representation of UUIDs. - */ -struct uuid { - uint32_t time_low; - uint16_t time_mid; - uint16_t time_hi_and_version; - uint8_t clock_seq_hi_and_reserved; - uint8_t clock_seq_low; - uint8_t node[_UUID_NODE_LEN]; -}; - -#ifdef _KERNEL - -#define UUID_NODE_LEN _UUID_NODE_LEN - -struct sbuf; - -struct uuid *kern_uuidgen(struct uuid *, size_t); - -int uuid_ether_add(const uint8_t *); -int uuid_ether_del(const uint8_t *); - -int snprintf_uuid(char *, size_t, struct uuid *); -int printf_uuid(struct uuid *); -int sbuf_printf_uuid(struct sbuf *, struct uuid *); -int parse_uuid(const char *, struct uuid *); - -void be_uuid_dec(void const *buf, struct uuid *uuid); -void be_uuid_enc(void *buf, struct uuid const *uuid); -void le_uuid_dec(void const *buf, struct uuid *uuid); -void le_uuid_enc(void *buf, struct uuid const *uuid); - -#else /* _KERNEL */ - -/* XXX namespace pollution? */ -typedef struct uuid uuid_t; - -//__BEGIN_DECLS -int uuidgen(struct uuid *, int); -//__END_DECLS - -#endif /* _KERNEL */ - -#endif /* _SYS_UUID_H_ */ diff --git a/include/sys/vfs/file.h b/include/sys/vfs/file.h deleted file mode 100644 index 19f6df7..0000000 --- a/include/sys/vfs/file.h +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VFS_FILE_H_ -#define _VFS_FILE_H_ 1 - -#include - -#include -#include -#include -#include -#include - -/* HACK */ -int getchar(); - -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 - -#define VBLKSHIFT 12 -#define VBLKSIZE (1 << VBLKSHIFT) -#define SBLOCKSIZE 8192 -#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ -#define DEV_BSIZE (1< -#include - -#include -#include -#include - -struct inode { - __dev_t i_dev; - unsigned long i_ino; - __mode_t i_mode; - __nlink_t i_nlink; - uid_t i_uid; - gid_t i_gid; - __dev_t i_rdev; - off_t i_size; - time_t i_atime; - time_t i_mtime; - time_t i_ctime; - unsigned long i_blksize; - unsigned long i_blocks; - struct semaphore i_sem; - struct inode_operations * i_op; - struct super_block * i_sb; - struct wait_queue * i_wait; - struct file_lock * i_flock; - struct vm_area_struct * i_mmap; - struct inode * i_next, *i_prev; - struct inode * i_hash_next, *i_hash_prev; - struct inode * i_bound_to, *i_bound_by; - struct inode * i_mount; - struct socket * i_socket; - unsigned short i_count; - unsigned short i_flags; - unsigned char i_lock; - unsigned char i_dirt; - unsigned char i_pipe; - unsigned char i_seek; - unsigned char i_update; - union { - struct pipe_inode_info pipe_i; - struct msdos_inode_info msdos_i; - struct ufs1_dinode ufs1_i; - struct ufs2_dinode ufs2_i; - } u; -}; - - -#endif diff --git a/include/sys/vfs/mount.h b/include/sys/vfs/mount.h deleted file mode 100644 index a59835d..0000000 --- a/include/sys/vfs/mount.h +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MOUNT_H -#define _MOUNT_H - -#include - -#define MFSNAMELEN 16 /* length of type name including null */ -#define MNAMELEN 88 /* size of on/from name bufs */ - -typedef struct fsid { - int32_t val[2]; -} fsid_t; /* filesystem id type */ - -struct statfs { - uint32_t f_version; /* structure version number */ - uint32_t f_type; /* type of filesystem */ - u_int64_t f_flags; /* copy of mount exported flags */ - u_int64_t f_bsize; /* filesystem fragment size */ - u_int64_t f_iosize; /* optimal transfer block size */ - u_int64_t f_blocks; /* total data blocks in filesystem */ - u_int64_t f_bfree; /* free blocks in filesystem */ - int64_t f_bavail; /* free blocks avail to non-superuser */ - u_int64_t f_files; /* total file nodes in filesystem */ - int64_t f_ffree; /* free nodes avail to non-superuser */ - u_int64_t f_syncwrites; /* count of sync writes since mount */ - u_int64_t f_asyncwrites; /* count of async writes since mount */ - u_int64_t f_syncreads; /* count of sync reads since mount */ - u_int64_t f_asyncreads; /* count of async reads since mount */ - u_int64_t f_spare[10]; /* unused spare */ - uint32_t f_namemax; /* maximum filename length */ - uid_t f_owner; /* user that mounted the filesystem */ - fsid_t f_fsid; /* filesystem id */ - char f_charspare[80]; /* spare string space */ - char f_fstypename[MFSNAMELEN]; /* filesystem type name */ - char f_mntfromname[MNAMELEN]; /* mounted filesystem */ - char f_mntonname[MNAMELEN]; /* directory on which mounted */ -}; - -struct vfs_mountPoint { - struct vfs_mountPoint *prev; - struct vfs_mountPoint *next; - struct fileSystem *fs; - struct device_node *device; - struct ubixDiskLabel *diskLabel; - void *fsInfo; - int partition; - char mountPoint[1024]; - char perms; -}; - -int vfs_mount(int major, int minor, int partition, int fsType, char *mountPoint, char *perms); -int vfs_addMount(struct vfs_mountPoint *mp); -struct vfs_mountPoint *vfs_findMount(char *mountPoint); - -#endif - -/*** - END - ***/ diff --git a/include/sys/vfs/stat.h b/include/sys/vfs/stat.h deleted file mode 100644 index ea5f7a0..0000000 --- a/include/sys/vfs/stat.h +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VFS_STAT_H -#define _VFS_STAT_H - -#include - -#define STAT_LSTAT 0x00000001 - -#define STAT_NO_FOLLOW 0x00000000 -#define STAT_FOLLOW 0x00000001 - -struct __timespec { - __time_t tv_sec; /* seconds */ - long tv_nsec; /* and nanoseconds */ -}; - -struct stat { - __dev_t st_dev; /* inode's device */ - ino_t st_ino; /* inode's number */ - __mode_t st_mode; /* inode protection mode */ - __nlink_t st_nlink; /* number of hard links */ - uid_t st_uid; /* user ID of the file's owner */ - gid_t st_gid; /* group ID of the file's group */ - __dev_t st_rdev; /* device type */ - time_t st_atime; /* time of last access */ - long __st_atimensec; /* nsec of last access */ - time_t st_mtime; /* time of last data modification */ - long __st_mtimensec; /* nsec of last data modification */ - time_t st_ctime; /* time of last file status change */ - long __st_ctimensec; /* nsec of last file status change */ - off_t st_size; /* file size, in bytes */ - blkcnt_t st_blocks; /* blocks allocated for file */ - blksize_t st_blksize; /* optimal blocksize for I/O */ - fflags_t st_flags; /* user defined flags for file */ - __uint32_t st_gen; /* file generation number */ - __int32_t st_lspare; - time_t st_birthtime; /* time of file creation */ - long st_birthtimensec; /* nsec of file creation */ - unsigned int :(8 / 2) * (16 - (int) sizeof(struct __timespec)); - unsigned int :(8 / 2) * (16 - (int) sizeof(struct __timespec)); -}; - -#endif diff --git a/include/sys/vfs/vfs.h b/include/sys/vfs/vfs.h deleted file mode 100644 index 90c76bc..0000000 --- a/include/sys/vfs/vfs.h +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _VFS_VFS_H -#define _VFS_VFS_H - -#include -#include -#include -#include -#include -#include -#include - -#define MAY_EXEC 1 -#define MAY_WRITE 2 -#define MAY_READ 4 - -#define maxFd 32 -#define fdAvail 1 -#define fdOpen 2 -#define fdRead 3 -#define fdEof 4 - -#define fileRead 0x0001 -#define fileWrite 0x0002 -#define fileBinary 0x0004 -#define fileAppend 0x0008 - -/*! - \brief filesSystem Structure - - not sure if we should allow function to point to NULL - */ -struct fileSystem { - struct fileSystem *prev; - struct fileSystem *next; - int (*vfsInitFS)(void *); /*!< pointer to inialization routine */ - int (*vfsRead)(void *, char *, long, long); /*!< pointer to read routine */ - int (*vfsWrite)(void *, char *, long, long); /*!< pointer to write routine */ - int (*vfsOpenFile)(void *, void *); /*!< pointer to openfile routine */ - int (*vfsUnlink)(char *, void *); /*!< pointer to unlink routine */ - int (*vfsMakeDir)(char *, void *); /*!< pointer to makedir routine */ - int (*vfsRemDir)(char *); /*!< pointer to remdir routine */ - int (*vfsSync)(void); /*!< pointer to sync routine */ - int vfsType; /*!< vfs type id */ -}; - -struct inode_operations { - struct file_operations * default_file_ops; - int (*create)(struct inode *, const char *, int, int, struct inode **); - int (*lookup)(struct inode *, const char *, int, struct inode **); - int (*link)(struct inode *, struct inode *, const char *, int); - int (*unlink)(struct inode *, const char *, int); - int (*symlink)(struct inode *, const char *, int, const char *); - int (*mkdir)(struct inode *, const char *, int, int); - int (*rmdir)(struct inode *, const char *, int); - int (*mknod)(struct inode *, const char *, int, int, int); - int (*rename)(struct inode *, const char *, int, struct inode *, const char *, int); - int (*readlink)(struct inode *, char *, int); - int (*follow_link)(struct inode *, struct inode *, int, int, struct inode **); - int (*bmap)(struct inode *, int); - void (*truncate)(struct inode *); - int (*permission)(struct inode *, int); -}; - -/* VFS Functions */ -int vfs_init(); -int vfsRegisterFS(struct fileSystem); -struct fileSystem *vfs_findFS(int); - -struct super_operations { - void (*read_inode)(struct inode *); - int (*notify_change)(int flags, struct inode *); - void (*write_inode)(struct inode *); - void (*put_inode)(struct inode *); - void (*put_super)(struct super_block *); - void (*write_super)(struct super_block *); - void (*statfs)(struct super_block *, struct statfs *); - int (*remount_fs)(struct super_block *, int *, char *); -}; - -struct super_block { - __dev_t s_dev; - unsigned long s_blocksize; - unsigned char s_blocksize_bits; - unsigned char s_lock; - unsigned char s_rd_only; - unsigned char s_dirt; - struct super_operations *s_op; - unsigned long s_flags; - unsigned long s_magic; - unsigned long s_time; - struct inode * s_covered; - struct inode * s_mounted; - struct wait_queue * s_wait; - union { - struct msdos_sb_info msdos_sb; -/* - struct fs ufs1_sb; - struct fs ufs2_sb; -*/ - } u; -}; - -#endif diff --git a/include/sys/video.h b/include/sys/video.h deleted file mode 100644 index 5d940cf..0000000 --- a/include/sys/video.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_VIDEO_H -#define _SYS_VIDEO_H - -#include - -#define defaultColor 0x0F - -extern int printColor; - -void clearScreen(); -void kprint(char *string); -void backSpace(); - -#endif /* END _SYS_VIDEO_H */ diff --git a/include/ubixos/access.h b/include/ubixos/access.h deleted file mode 100644 index 773102a..0000000 --- a/include/ubixos/access.h +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_ACCESS_H -#define _UBIXOS_ACCESS_H - -#include - -struct sys_setUID_args { - uint32_t uid; -}; - -struct sys_setGID_args { - uint32_t gid; -}; - -int sys_getUID(struct thread *, void *); -int sys_getEUID(struct thread *, void *); -int sys_setUID(struct thread *, struct sys_setUID_args *); - -int sys_getGID(struct thread *, void *); -int sys_setGID(struct thread *, struct sys_setGID_args *); - -#endif /* END _UBIXOS_ACCESS_H */ diff --git a/include/ubixos/bcd.h b/include/ubixos/bcd.h deleted file mode 100644 index be97ca9..0000000 --- a/include/ubixos/bcd.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_BCD_H_ -#define _UBIXOS_BCD_H_ - - -/* XXX Putting this here for now as I'm not sure where is the best place for them yet. */ -#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z'))) -#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z'))) - -extern const u_char bcd2bin_data[]; -extern const u_char bin2bcd_data[]; -extern char const hex2ascii_data[]; - -#define bcd2bin(bcd) (bcd2bin_data[bcd]) -#define bin2bcd(bin) (bin2bcd_data[bin]) -#define hex2ascii(hex) (hex2ascii_data[hex]) - -#endif /* !_UBIXOS_BCD_H_ */ diff --git a/include/ubixos/endtask.h b/include/ubixos/endtask.h deleted file mode 100644 index 998623e..0000000 --- a/include/ubixos/endtask.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_ENDTASK_H -#define _UBIXOS_ENDTASK_H - -#include -#include - -void endTask(pidType); - -#endif /* END _UBIXOS_ENDTASK_H */ diff --git a/include/ubixos/errno.h b/include/ubixos/errno.h deleted file mode 100644 index 04aa285..0000000 --- a/include/ubixos/errno.h +++ /dev/null @@ -1,177 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_ERRNO_H -#define _UBIXOS_ERRNO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define ENOERR 0 /* No Error */ -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No child processes */ -#define EAGAIN 11 /* Try again */ -#define ENOMEM 12 /* Out of memory */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device or resource busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math argument out of domain of func */ -#define ERANGE 34 /* Math result not representable */ -#define EDEADLK 35 /* Resource deadlock would occur */ -#define ENAMETOOLONG 36 /* File name too long */ -#define ENOLCK 37 /* No record locks available */ -#define ENOSYS 38 /* Function not implemented */ -#define ENOTEMPTY 39 /* Directory not empty */ -#define ELOOP 40 /* Too many symbolic links encountered */ -#define EWOULDBLOCK EAGAIN /* Operation would block */ -#define ENOMSG 42 /* No message of desired type */ -#define EIDRM 43 /* Identifier removed */ -#define ECHRNG 44 /* Channel number out of range */ -#define EL2NSYNC 45 /* Level 2 not synchronized */ -#define EL3HLT 46 /* Level 3 halted */ -#define EL3RST 47 /* Level 3 reset */ -#define ELNRNG 48 /* Link number out of range */ -#define EUNATCH 49 /* Protocol driver not attached */ -#define ENOCSI 50 /* No CSI structure available */ -#define EL2HLT 51 /* Level 2 halted */ -#define EBADE 52 /* Invalid exchange */ -#define EBADR 53 /* Invalid request descriptor */ -#define EXFULL 54 /* Exchange full */ -#define ENOANO 55 /* No anode */ -#define EBADRQC 56 /* Invalid request code */ -#define EBADSLT 57 /* Invalid slot */ - -#define EDEADLOCK EDEADLK - -#define EBFONT 59 /* Bad font file format */ -#define ENOSTR 60 /* Device not a stream */ -#define ENODATA 61 /* No data available */ -#define ETIME 62 /* Timer expired */ -#define ENOSR 63 /* Out of streams resources */ -#define ENONET 64 /* Machine is not on the network */ -#define ENOPKG 65 /* Package not installed */ -#define EREMOTE 66 /* Object is remote */ -#define ENOLINK 67 /* Link has been severed */ -#define EADV 68 /* Advertise error */ -#define ESRMNT 69 /* Srmount error */ -#define ECOMM 70 /* Communication error on send */ -#define EPROTO 71 /* Protocol error */ -#define EMULTIHOP 72 /* Multihop attempted */ -#define EDOTDOT 73 /* RFS specific error */ -#define EBADMSG 74 /* Not a data message */ -#define EOVERFLOW 75 /* Value too large for defined data type */ -#define ENOTUNIQ 76 /* Name not unique on network */ -#define EBADFD 77 /* File descriptor in bad state */ -#define EREMCHG 78 /* Remote address changed */ -#define ELIBACC 79 /* Can not access a needed shared library */ -#define ELIBBAD 80 /* Accessing a corrupted shared library */ -#define ELIBSCN 81 /* .lib section in a.out corrupted */ -#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ -#define ELIBEXEC 83 /* Cannot exec a shared library directly */ -#define EILSEQ 84 /* Illegal byte sequence */ -#define ERESTART 85 /* Interrupted system call should be restarted */ -#define ESTRPIPE 86 /* Streams pipe error */ -#define EUSERS 87 /* Too many users */ -#define ENOTSOCK 88 /* Socket operation on non-socket */ -#define EDESTADDRREQ 89 /* Destination address required */ -#define EMSGSIZE 90 /* Message too long */ -#define EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 92 /* Protocol not available */ -#define EPROTONOSUPPORT 93 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define EADDRINUSE 98 /* Address already in use */ -#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define ENETDOWN 100 /* Network is down */ -#define ENETUNREACH 101 /* Network is unreachable */ -#define ENETRESET 102 /* Network dropped connection because of reset */ -#define ECONNABORTED 103 /* Software caused connection abort */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EISCONN 106 /* Transport endpoint is already connected */ -#define ENOTCONN 107 /* Transport endpoint is not connected */ -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define ETIMEDOUT 110 /* Connection timed out */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EHOSTDOWN 112 /* Host is down */ -#define EHOSTUNREACH 113 /* No route to host */ -#define EALREADY 114 /* Operation already in progress */ -#define EINPROGRESS 115 /* Operation now in progress */ -#define ESTALE 116 /* Stale NFS file handle */ -#define EUCLEAN 117 /* Structure needs cleaning */ -#define ENOTNAM 118 /* Not a XENIX named type file */ -#define ENAVAIL 119 /* No XENIX semaphores available */ -#define EISNAM 120 /* Is a named type file */ -#define EREMOTEIO 121 /* Remote I/O error */ -#define EDQUOT 122 /* Quota exceeded */ - -#define ENOMEDIUM 123 /* No medium found */ -#define EMEDIUMTYPE 124 /* Wrong medium type */ - -#ifndef errno - extern int errno; -#endif - -#ifndef err_t -typedef int err_t; -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _UBIXOS_ERRNO*/ diff --git a/include/ubixos/exec.h b/include/ubixos/exec.h deleted file mode 100644 index 3731eaf..0000000 --- a/include/ubixos/exec.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_EXEC_H -#define _UBIXOS_EXEC_H - -#include -#include - -uint32_t execThread(void (*tproc)(void), uint32_t, char *); -void execFile(char *file, char **argv, char **envp, int console); - -int sys_exec(struct thread *, char *, char **, char **); - -#endif /* END _UBIXOS_EXEC_H */ diff --git a/include/ubixos/fork.h b/include/ubixos/fork.h deleted file mode 100644 index ad66125..0000000 --- a/include/ubixos/fork.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_FORK_H -#define _UBIXOS_FORK_H - -#include -#include - -//void sysFork(); -int sysFork(struct thread *, void *); - -#endif /* END _UBIXOS_FORK_H */ diff --git a/include/ubixos/init.h b/include/ubixos/init.h deleted file mode 100644 index 5eebbfe..0000000 --- a/include/ubixos/init.h +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_INIT_H -#define _UBIXOS_INIT_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef int (*intFunctionPTR)(void); - -intFunctionPTR init_tasks[] = { static_constructors, i8259_init, idt_init, vitals_init, sysctl_init, vfs_init, sched_init, pit_init, atkbd_init, time_init, pci_init, devfs_init, tty_init, ufs_init, initHardDisk, initLNC, net_init }; - -/* ne2k_init, */ -/* ubixfs_init, */ -/* fdc_init, */ - -int init_tasksTotal = sizeof(init_tasks) / sizeof(intFunctionPTR); - -#endif /* END _UBIXOS_INIT_H */ diff --git a/include/ubixos/kmod.h b/include/ubixos/kmod.h deleted file mode 100644 index 39a3660..0000000 --- a/include/ubixos/kmod.h +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_KMOD_H -#define _UBIXOS_KMOD_H - -#include - -#define LD_START 0x1000000 - -typedef struct kmod_struct { - struct kmod_struct *next; - struct kmod_struct *prev; - uInt16 id; - uInt16 refs; - uInt32 address; - char name[128]; -} kmod_t; - -uInt32 kmod_load(const char *); -uInt32 kmod_add(const char *, const char *name); - -#endif diff --git a/include/ubixos/kpanic.h b/include/ubixos/kpanic.h deleted file mode 100644 index 3adc795..0000000 --- a/include/ubixos/kpanic.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_KPANIC_H -#define _SYS_KPANIC_H - -#define K_PANIC(msg) kpanic("Error: (%s), File: %s, Line: %i\n",msg ,__FILE__,__LINE__); - -void kpanic(const char *fmt, ...); - -#endif /* END _SYS_KPANIC_H */ diff --git a/include/ubixos/ld.h b/include/ubixos/ld.h deleted file mode 100644 index 2790ec4..0000000 --- a/include/ubixos/ld.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_LD_H -#define _UBIXOS_LD_H - -#include - -#define LD_START 0xAAA00000 //0x1000000 - -uInt32 ldEnable(); - -#endif /* END _UBIXOS_LD_H */ diff --git a/include/ubixos/lists.h b/include/ubixos/lists.h deleted file mode 100644 index f730a52..0000000 --- a/include/ubixos/lists.h +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define IN -#define STATUS_FAILURE -1 -#define STATUS_SUCCESS 0 - -typedef struct _item_t Item_t; -typedef struct _list_t List_t; -struct _item_t { - Item_t *Previous; - Item_t *Next; - void *data; -}; - -struct _list_t { - Item_t *First; - Item_t *Last; -}; - -List_t * -InitializeList(); -Item_t * -CreateItem(); -int -InsertItemAtFront( IN List_t * TList, IN Item_t * kItem); -int -InsertItemBetweenItems( IN List_t * TList, IN Item_t * Previous, IN Item_t * Next, IN Item_t * Insert); -int -RemoveItem( IN List_t * TList, IN Item_t * kItem); -int -DestroyItemsInList(IN List_t * ItemList); -int -DestroyItemList(IN List_t * ItemList); -Item_t * -GetFirstItem(IN List_t * kItem); - -Item_t * -GetLastItem(IN List_t * kItem); -List_t * -RemoveItemListBetweenItems( IN Item_t * Previous, IN Item_t * Next); - -void -InsertItemListBetweenItems( IN Item_t * Previous, IN Item_t * Next, IN List_t * Insert); diff --git a/include/ubixos/sched.h b/include/ubixos/sched.h deleted file mode 100644 index 2cb244d..0000000 --- a/include/ubixos/sched.h +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_SCHED_H -#define _UBIXOS_SCHED_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#include -#include - -#define NO_GROUP -1 -#define NR_GROUPS 32 - -typedef enum { - PLACEHOLDER = -2, DEAD = -1, NEW = 0, READY = 1, RUNNING = 2, IDLE = 3, FORK = 4, WAIT = 5, UNINTERRUPTIBLE = 6, INTERRUPTIBLE = 7 -} tState; - -struct osInfo { - uInt8 timer; - uInt8 v86Task; - bool v86If; - uInt32 vmStart; - uInt32 stdinSize; - uInt32 controlKeys; - char *stdin; - char cwd[1024]; /* current working dir */ - uint8_t gpf; -}; - -typedef struct taskStruct { - pidType id; - char name[256]; - struct taskStruct *prev; - struct taskStruct *next; - struct tssStruct tss; - struct i387Struct i387; - struct osInfo oInfo; - //fileDescriptor *imageFd; - fileDescriptor_t *files[MAX_OFILES]; - tState state; - uint32_t uid, gid; - uint16_t euid, suid; - uint16_t egid, sgid; - uInt16 usedMath; - tty_term *term; - struct thread td; - struct { - struct inode *pwd; - struct inode *root; - struct inode *exec; - } inodes; - uint32_t counter; - uint16_t groups[NR_GROUPS]; - pidType ppid; - uint32_t pgrp; - uint32_t children; // Hack for WAIT - uint32_t last_exit; // Hack For WAIT - struct taskStruct *parent; -} kTask_t; - -int sched_init(); -int sched_setStatus(pidType, tState); -int sched_deleteTask(pidType); -int sched_addDelTask(kTask_t *); -kTask_t *sched_getDelTask(); -void sched_yield(); -void sched(); - -void schedEndTask(pidType pid); -kTask_t *schedNewTask(); -kTask_t *schedFindTask(uInt32 id); - -extern kTask_t *_current; -extern kTask_t *_usedMath; - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/include/ubixos/sem.h b/include/ubixos/sem.h deleted file mode 100644 index 7afd3de..0000000 --- a/include/ubixos/sem.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_SEM_H -#define _UBIXOS_SEM_H - -#include -#include -#include - -struct sys_sem { - uint32_t signaled; - ubthread_cond_t cond; - ubthread_mutex_t mutex; -}; - -typedef struct sys_sem sys_sem_t; - -typedef uint32_t semID_t; -struct timespec; - -int sem_close(semID_t id); -int sem_post(semID_t id); -int sem_wait(semID_t id); -int sem_trywait(semID_t id); -int sem_timedwait(semID_t id, const struct timespec *); -int sem_init(sys_sem_t **, uint8_t); -int sem_open(semID_t *id, const char *name, int oflag, mode_t mode, unsigned int value); -int sem_unlink(const char *name); -int sem_getvalue(semID_t id, int *val); -int sem_destroy(sys_sem_t **); - -#endif /* END _UBIXOS_SEM_H */ diff --git a/include/ubixos/smp.h b/include/ubixos/smp.h deleted file mode 100644 index d4a630d..0000000 --- a/include/ubixos/smp.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_SMP_H -#define _UBIXOS_SMP_H - -#include - -struct cpuinfo_t { - uInt8 id; - uInt8 ok; // 1=Ok, 0=Bad - uInt8 apic_id, apic_ver; - uInt32 signature; // Family, Model, Stepping - uInt32 feature; - uInt32 max; - char brand[49]; // Brand name - char ident[17]; -}; - -void smpInit(); -void cpuidDetect(); -uInt8 cpuInfo(); -uInt32 getEflags(); -void setEflags(uInt32); -void cpuid(uInt32, uInt32 *); -void apicMagic(); - -#endif diff --git a/include/ubixos/spinlock.h b/include/ubixos/spinlock.h deleted file mode 100644 index d5eff8c..0000000 --- a/include/ubixos/spinlock.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_SPINLOCK_H_ -#define _UBIXOS_SPINLOCK_H_ - -#include - -#define LOCKED 1 -#define UNLOCKED 0 -#define SPIN_LOCK_INITIALIZER { 0x0, 0x0 } -#define LLOCK_FLAG 1 - -struct spinLock { - struct spinLock *next; - u_int32_t locked; -}; - -typedef struct spinLock *spinLock_t; - -extern struct spinLock Master; - -void spinLockInit(spinLock_t); -void spinUnlock(spinLock_t); -int spinTryLock(spinLock_t); -void spinLock(spinLock_t); - -void spinLock_scheduler(spinLock_t *); /* Only use this spinlock in the sched. */ - -int spinLockLocked(spinLock_t *); - -/* Atomic exchange (of various sizes) */ -static inline u_long xchg_64(volatile uint32_t *ptr, u_long x) { - __asm__ __volatile__("xchgq %1,%0" - :"+r" (x), - "+m" (*ptr)); - - return x; -} - -static inline unsigned xchg_32(volatile uint32_t *ptr, uint32_t x) { - __asm__ __volatile__("xchgl %1,%0" - :"+r" (x), - "+m" (*ptr)); - - return x; -} - -static inline unsigned short xchg_16(volatile uint32_t *ptr, uint16_t x) { - __asm__ __volatile__("xchgw %1,%0" - :"+r" (x), - "+m" (*ptr)); - - return x; -} - -/* Test and set a bit */ -static inline char atomic_bitsetandtest(void *ptr, int x) { - char out; - __asm__ __volatile__("lock; bts %2,%1\n" - "sbb %0,%0\n" - :"=r" (out), "=m" (*(volatile long long *)ptr) - :"Ir" (x) - :"memory"); - - return out; -} - -#endif /* !_UBIXOS_SPINLOCK_H_ */ diff --git a/include/ubixos/static.h b/include/ubixos/static.h deleted file mode 100644 index 59986ca..0000000 --- a/include/ubixos/static.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_STATIC_H -#define _UBIXOS_STATIC_H - -int static_constructors(void); - -#endif diff --git a/include/ubixos/syscall.h b/include/ubixos/syscall.h deleted file mode 100644 index e824415..0000000 --- a/include/ubixos/syscall.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_SYSCALL_H -#define _UBIXOS_SYSCALL_H - -#include - -void _sys_call(); -void sys_call(struct trapframe *frame); -int invalidCall(); -void invalidCallINT(int); - -#endif diff --git a/include/ubixos/syscall_posix.h b/include/ubixos/syscall_posix.h deleted file mode 100644 index 65b2f09..0000000 --- a/include/ubixos/syscall_posix.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_SYSCALL_POSIX_H -#define _UBIXOS_SYSCALL_POSIX_H - -#include - -void _sys_call_posix(); -void sys_call_posix(struct trapframe *frame); - -#endif diff --git a/include/ubixos/syscalls.h b/include/ubixos/syscalls.h deleted file mode 100644 index 426fa88..0000000 --- a/include/ubixos/syscalls.h +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYSCALLS_H -#define _SYSCALLS_H - -#include -#include -#include - -#define SYSCALLS_MAX 1024 - -#define PSL_C 0x00000001 /* carry bit */ -#define EJUSTRETURN (-2) /* don't modify regs, just return */ -#define ERESTART (-1) /* restart syscall */ - -#define ARG_COUNT(name) (sizeof(struct name) / sizeof(register_t)) - -#define SYSCALL_INVALID 0 -#define SYSCALL_VALID 1 -#define SYSCALL_DUMMY 2 -#define SYSCALL_NOTIMP 3 - -typedef int sys_call_t(struct thread *, void *); - -struct syscall_entry { - int sc_args; - char *sc_name; - sys_call_t *sc_entry; - int sc_status; -}; - -/* - * - * Old Style Calls Need Updates - * - */ -int sysAuth(); -int sysPasswd(); -int sysAddModule(); -int sysRmModule(); -int sysGetpid(); -int sysExit(); -int sysExec(); - -int sysCheckPid(); -int sysGetFreePage(); - -int sysFgetc(); -int sysFopen(); -int sysFclose(); -int sysFseek(); -int sysMkDir(); -int sysRmDir(); - -//int sysSDE(); -int sysGetDrives(); -int sysGetCwd(); -int sysChDir(); -int sysGetUptime(); -int sysGetTime(); -int sysStartSDE(); -int sysUnlink(); -int sysMpiCreateMbox(); -int sysMpiDestroyMbox(); -int sysMpiPostMessage(); -int sysMpiFetchMessage(); -int sysMpiSpam(); - -typedef int (*functionPTR)(); - -extern int totalCalls; -extern struct syscall_entry systemCalls[]; - -extern int totalCalls_posix; -extern struct syscall_entry systemCalls_posix[]; - -#endif diff --git a/include/ubixos/syscalls_new.h b/include/ubixos/syscalls_new.h deleted file mode 100644 index 706484e..0000000 --- a/include/ubixos/syscalls_new.h +++ /dev/null @@ -1,531 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYSCALLS_NEW_H -#define _SYSCALLS_NEW_H - -#include - -int sysExit(); -int read(); -int getpid(); -int fcntl(); -int issetugid(); -int __sysctl(); -int pipe(); -int readlink(); -int getuid(); -int getgid(); -int close(); -int mmap(); -int obreak(); -int sigaction(); -int getdtablesize(); -int munmap(); -int sigprocmask(); -int gettimeofday_new(); -int fstat(); -int ioctl(); - -#define invalid_call 0x0 -#define PSL_C 0x00000001 /* carry bit */ -#define EJUSTRETURN (-2) /* don't modify regs, just return */ -#define ERESTART (-1) /* restart syscall */ - -typedef int (*functionPTR)(); - -/*! - * \brief Mast System Call List - */ -functionPTR systemCalls_new[] = { -invalid_call, /** 0 **/ -sysExit, /** 1 **/ -invalid_call, /** 2 **/ -read, /** 3 **/ -sys_write, /** 4 **/ -sys_open, /** 5 **/ -close, /** 6 **/ -invalid_call, /** 7 **/ -invalid_call, /** 8 **/ -invalid_call, /** 9 **/ -invalid_call, /** 10 **/ -invalid_call, /** 11 **/ -invalid_call, /** 12 **/ -invalid_call, /** 13 **/ -invalid_call, /** 14 **/ -invalid_call, /** 15 **/ -invalid_call, /** 16 **/ -obreak, /** 17 **/ -invalid_call, /** 18 **/ -invalid_call, /** 19 **/ -getpid, /** 20 **/ -invalid_call, /** 21 **/ -invalid_call, /** 22 **/ -invalid_call, /** 23 **/ -getuid, /** 24 **/ -invalid_call, /** 25 **/ -invalid_call, /** 26 **/ -invalid_call, /** 27 **/ -invalid_call, /** 28 **/ -invalid_call, /** 29 **/ -invalid_call, /** 30 **/ -invalid_call, /** 31 **/ -invalid_call, /** 32 **/ -access, /** 33 **/ -invalid_call, /** 34 **/ -invalid_call, /** 35 **/ -invalid_call, /** 36 **/ -invalid_call, /** 37 **/ -invalid_call, /** 38 **/ -invalid_call, /** 39 **/ -invalid_call, /** 40 **/ -invalid_call, /** 41 **/ -pipe, /** 42 **/ -invalid_call, /** 43 **/ -invalid_call, /** 44 **/ -invalid_call, /** 45 **/ -invalid_call, /** 46 **/ -getgid, /** 47 **/ -invalid_call, /** 48 **/ -invalid_call, /** 49 **/ -invalid_call, /** 50 **/ -invalid_call, /** 51 **/ -invalid_call, /** 52 **/ -invalid_call, /** 53 **/ -ioctl, /** 54 **/ -invalid_call, /** 55 **/ -invalid_call, /** 56 **/ -invalid_call, /** 57 **/ -readlink, /** 58 **/ -invalid_call, /** 59 **/ -invalid_call, /** 60 **/ -invalid_call, /** 61 **/ -invalid_call, /** 62 **/ -invalid_call, /** 63 **/ -invalid_call, /** 64 **/ -invalid_call, /** 65 **/ -invalid_call, /** 66 **/ -invalid_call, /** 67 **/ -invalid_call, /** 68 **/ -invalid_call, /** 69 **/ -invalid_call, /** 70 **/ -invalid_call, /** 71 **/ -invalid_call, /** 72 **/ -munmap, /** 73 **/ -mprotect, /** 74 **/ -invalid_call, /** 75 **/ -invalid_call, /** 76 **/ -invalid_call, /** 77 **/ -invalid_call, /** 78 **/ -invalid_call, /** 79 **/ -invalid_call, /** 80 **/ -invalid_call, /** 81 **/ -invalid_call, /** 82 **/ -setitimer, /** 83 **/ -invalid_call, /** 84 **/ -invalid_call, /** 85 **/ -invalid_call, /** 86 **/ -invalid_call, /** 87 **/ -invalid_call, /** 88 **/ -getdtablesize, /** 89 **/ -invalid_call, /** 90 **/ -invalid_call, /** 91 **/ -fcntl, /** 92 **/ -invalid_call, /** 93 **/ -invalid_call, /** 94 **/ -invalid_call, /** 95 **/ -invalid_call, /** 96 **/ -invalid_call, /** 97 **/ -invalid_call, /** 98 **/ -invalid_call, /** 99 **/ -invalid_call, /** 100 **/ -invalid_call, /** 101 **/ -invalid_call, /** 102 **/ -invalid_call, /** 103 **/ -invalid_call, /** 104 **/ -invalid_call, /** 105 **/ -invalid_call, /** 106 **/ -invalid_call, /** 107 **/ -invalid_call, /** 108 **/ -invalid_call, /** 109 **/ -invalid_call, /** 110 **/ -invalid_call, /** 111 **/ -invalid_call, /** 112 **/ -invalid_call, /** 113 **/ -invalid_call, /** 114 **/ -invalid_call, /** 115 **/ -gettimeofday_new, /** 116 **/ -invalid_call, /** 117 **/ -invalid_call, /** 118 **/ -invalid_call, /** 119 **/ -invalid_call, /** 120 **/ -invalid_call, /** 121 **/ -invalid_call, /** 122 **/ -invalid_call, /** 123 **/ -invalid_call, /** 124 **/ -invalid_call, /** 125 **/ -invalid_call, /** 126 **/ -invalid_call, /** 127 **/ -invalid_call, /** 128 **/ -invalid_call, /** 129 **/ -invalid_call, /** 130 **/ -invalid_call, /** 131 **/ -invalid_call, /** 132 **/ -invalid_call, /** 133 **/ -invalid_call, /** 134 **/ -invalid_call, /** 135 **/ -invalid_call, /** 136 **/ -invalid_call, /** 137 **/ -invalid_call, /** 138 **/ -invalid_call, /** 139 **/ -invalid_call, /** 140 **/ -invalid_call, /** 141 **/ -invalid_call, /** 142 **/ -invalid_call, /** 143 **/ -invalid_call, /** 144 **/ -invalid_call, /** 145 **/ -invalid_call, /** 146 **/ -invalid_call, /** 147 **/ -invalid_call, /** 148 **/ -invalid_call, /** 149 **/ -invalid_call, /** 150 **/ -invalid_call, /** 151 **/ -invalid_call, /** 152 **/ -invalid_call, /** 153 **/ -invalid_call, /** 154 **/ -invalid_call, /** 155 **/ -invalid_call, /** 156 **/ -invalid_call, /** 157 **/ -invalid_call, /** 158 **/ -invalid_call, /** 159 **/ -invalid_call, /** 160 **/ -invalid_call, /** 161 **/ -invalid_call, /** 162 **/ -invalid_call, /** 163 **/ -invalid_call, /** 164 **/ -invalid_call, /** 165 **/ -invalid_call, /** 166 **/ -invalid_call, /** 167 **/ -invalid_call, /** 168 **/ -invalid_call, /** 169 **/ -invalid_call, /** 170 **/ -invalid_call, /** 171 **/ -invalid_call, /** 172 **/ -invalid_call, /** 173 **/ -invalid_call, /** 174 **/ -invalid_call, /** 175 **/ -invalid_call, /** 176 **/ -invalid_call, /** 177 **/ -invalid_call, /** 178 **/ -invalid_call, /** 179 **/ -invalid_call, /** 180 **/ -invalid_call, /** 181 **/ -invalid_call, /** 182 **/ -invalid_call, /** 183 **/ -invalid_call, /** 184 **/ -invalid_call, /** 185 **/ -invalid_call, /** 186 **/ -invalid_call, /** 187 **/ -invalid_call, /** 188 **/ -fstat, /** 189 **/ -invalid_call, /** 190 **/ -invalid_call, /** 191 **/ -invalid_call, /** 192 **/ -invalid_call, /** 193 **/ -invalid_call, /** 194 **/ -invalid_call, /** 195 **/ -invalid_call, /** 196 **/ -mmap, /** 197 **/ -invalid_call, /** 198 **/ -invalid_call, /** 199 **/ -invalid_call, /** 200 **/ -invalid_call, /** 201 **/ -__sysctl, /** 202 **/ -invalid_call, /** 203 **/ -invalid_call, /** 204 **/ -invalid_call, /** 205 **/ -invalid_call, /** 206 **/ -invalid_call, /** 207 **/ -invalid_call, /** 208 **/ -invalid_call, /** 209 **/ -invalid_call, /** 210 **/ -invalid_call, /** 211 **/ -invalid_call, /** 212 **/ -invalid_call, /** 213 **/ -invalid_call, /** 214 **/ -invalid_call, /** 215 **/ -invalid_call, /** 216 **/ -invalid_call, /** 217 **/ -invalid_call, /** 218 **/ -invalid_call, /** 219 **/ -invalid_call, /** 220 **/ -invalid_call, /** 221 **/ -invalid_call, /** 222 **/ -invalid_call, /** 223 **/ -invalid_call, /** 224 **/ -invalid_call, /** 225 **/ -invalid_call, /** 226 **/ -invalid_call, /** 227 **/ -invalid_call, /** 228 **/ -invalid_call, /** 229 **/ -invalid_call, /** 230 **/ -invalid_call, /** 231 **/ -invalid_call, /** 232 **/ -invalid_call, /** 233 **/ -invalid_call, /** 234 **/ -invalid_call, /** 235 **/ -invalid_call, /** 236 **/ -invalid_call, /** 237 **/ -invalid_call, /** 238 **/ -invalid_call, /** 239 **/ -invalid_call, /** 240 **/ -invalid_call, /** 241 **/ -invalid_call, /** 242 **/ -invalid_call, /** 243 **/ -invalid_call, /** 244 **/ -invalid_call, /** 245 **/ -invalid_call, /** 246 **/ -invalid_call, /** 247 **/ -invalid_call, /** 248 **/ -invalid_call, /** 249 **/ -invalid_call, /** 250 **/ -invalid_call, /** 251 **/ -invalid_call, /** 252 **/ -issetugid, /** 253 **/ -invalid_call, /** 254 **/ -invalid_call, /** 255 **/ -invalid_call, /** 256 **/ -invalid_call, /** 257 **/ -invalid_call, /** 258 **/ -invalid_call, /** 259 **/ -invalid_call, /** 260 **/ -invalid_call, /** 261 **/ -invalid_call, /** 262 **/ -invalid_call, /** 263 **/ -invalid_call, /** 264 **/ -invalid_call, /** 265 **/ -invalid_call, /** 266 **/ -invalid_call, /** 267 **/ -invalid_call, /** 268 **/ -invalid_call, /** 269 **/ -invalid_call, /** 270 **/ -invalid_call, /** 271 **/ -invalid_call, /** 272 **/ -invalid_call, /** 273 **/ -invalid_call, /** 274 **/ -invalid_call, /** 275 **/ -invalid_call, /** 276 **/ -invalid_call, /** 277 **/ -invalid_call, /** 278 **/ -invalid_call, /** 279 **/ -invalid_call, /** 280 **/ -invalid_call, /** 281 **/ -invalid_call, /** 282 **/ -invalid_call, /** 283 **/ -invalid_call, /** 284 **/ -invalid_call, /** 285 **/ -invalid_call, /** 286 **/ -invalid_call, /** 287 **/ -invalid_call, /** 288 **/ -invalid_call, /** 289 **/ -invalid_call, /** 290 **/ -invalid_call, /** 291 **/ -invalid_call, /** 292 **/ -invalid_call, /** 293 **/ -invalid_call, /** 294 **/ -invalid_call, /** 295 **/ -invalid_call, /** 296 **/ -invalid_call, /** 297 **/ -invalid_call, /** 298 **/ -invalid_call, /** 299 **/ -invalid_call, /** 300 **/ -invalid_call, /** 301 **/ -invalid_call, /** 302 **/ -invalid_call, /** 303 **/ -invalid_call, /** 304 **/ -invalid_call, /** 305 **/ -invalid_call, /** 306 **/ -invalid_call, /** 307 **/ -invalid_call, /** 308 **/ -invalid_call, /** 309 **/ -invalid_call, /** 310 **/ -invalid_call, /** 311 **/ -invalid_call, /** 312 **/ -invalid_call, /** 313 **/ -invalid_call, /** 314 **/ -invalid_call, /** 315 **/ -invalid_call, /** 316 **/ -invalid_call, /** 317 **/ -invalid_call, /** 318 **/ -invalid_call, /** 319 **/ -invalid_call, /** 320 **/ -invalid_call, /** 321 **/ -invalid_call, /** 322 **/ -invalid_call, /** 323 **/ -invalid_call, /** 324 **/ -invalid_call, /** 325 **/ -invalid_call, /** 326 **/ -invalid_call, /** 327 **/ -invalid_call, /** 328 **/ -invalid_call, /** 329 **/ -invalid_call, /** 330 **/ -invalid_call, /** 331 **/ -invalid_call, /** 332 **/ -invalid_call, /** 333 **/ -invalid_call, /** 334 **/ -invalid_call, /** 335 **/ -invalid_call, /** 336 **/ -invalid_call, /** 337 **/ -invalid_call, /** 338 **/ -invalid_call, /** 339 **/ -sigprocmask, /** 340 **/ -invalid_call, /** 341 **/ -invalid_call, /** 342 **/ -invalid_call, /** 343 **/ -invalid_call, /** 344 **/ -invalid_call, /** 345 **/ -invalid_call, /** 346 **/ -invalid_call, /** 347 **/ -invalid_call, /** 348 **/ -invalid_call, /** 349 **/ -invalid_call, /** 350 **/ -invalid_call, /** 351 **/ -invalid_call, /** 352 **/ -invalid_call, /** 353 **/ -invalid_call, /** 354 **/ -invalid_call, /** 355 **/ -invalid_call, /** 356 **/ -invalid_call, /** 357 **/ -invalid_call, /** 358 **/ -invalid_call, /** 359 **/ -invalid_call, /** 360 **/ -invalid_call, /** 361 **/ -invalid_call, /** 362 **/ -invalid_call, /** 363 **/ -invalid_call, /** 364 **/ -invalid_call, /** 365 **/ -invalid_call, /** 366 **/ -invalid_call, /** 367 **/ -invalid_call, /** 368 **/ -invalid_call, /** 369 **/ -invalid_call, /** 370 **/ -invalid_call, /** 371 **/ -invalid_call, /** 372 **/ -invalid_call, /** 373 **/ -invalid_call, /** 374 **/ -invalid_call, /** 375 **/ -invalid_call, /** 376 **/ -invalid_call, /** 377 **/ -invalid_call, /** 378 **/ -invalid_call, /** 379 **/ -invalid_call, /** 380 **/ -invalid_call, /** 381 **/ -invalid_call, /** 382 **/ -invalid_call, /** 383 **/ -invalid_call, /** 384 **/ -invalid_call, /** 385 **/ -invalid_call, /** 386 **/ -invalid_call, /** 387 **/ -invalid_call, /** 388 **/ -invalid_call, /** 389 **/ -invalid_call, /** 390 **/ -invalid_call, /** 391 **/ -invalid_call, /** 392 **/ -invalid_call, /** 393 **/ -invalid_call, /** 394 **/ -invalid_call, /** 395 **/ -invalid_call, /** 396 **/ -fstatfs, /** 397 **/ -invalid_call, /** 398 **/ -invalid_call, /** 399 **/ -invalid_call, /** 400 **/ -invalid_call, /** 401 **/ -invalid_call, /** 402 **/ -invalid_call, /** 403 **/ -invalid_call, /** 404 **/ -invalid_call, /** 405 **/ -invalid_call, /** 406 **/ -invalid_call, /** 407 **/ -invalid_call, /** 408 **/ -invalid_call, /** 409 **/ -invalid_call, /** 410 **/ -invalid_call, /** 411 **/ -invalid_call, /** 412 **/ -invalid_call, /** 413 **/ -invalid_call, /** 414 **/ -invalid_call, /** 415 **/ -sigaction, /** 416 **/ -invalid_call, /** 417 **/ -invalid_call, /** 418 **/ -invalid_call, /** 419 **/ -invalid_call, /** 420 **/ -invalid_call, /** 421 **/ -invalid_call, /** 422 **/ -invalid_call, /** 423 **/ -invalid_call, /** 424 **/ -invalid_call, /** 425 **/ -invalid_call, /** 426 **/ -invalid_call, /** 427 **/ -invalid_call, /** 428 **/ -invalid_call, /** 429 **/ -invalid_call, /** 430 **/ -invalid_call, /** 431 **/ -invalid_call, /** 432 **/ -invalid_call, /** 433 **/ -invalid_call, /** 434 **/ -invalid_call, /** 435 **/ -invalid_call, /** 436 **/ -invalid_call, /** 437 **/ -invalid_call, /** 438 **/ -invalid_call, /** 439 **/ -invalid_call, /** 440 **/ -invalid_call, /** 441 **/ -invalid_call, /** 442 **/ -invalid_call, /** 443 **/ -invalid_call, /** 444 **/ -invalid_call, /** 445 **/ -invalid_call, /** 446 **/ -invalid_call, /** 447 **/ -invalid_call, /** 448 **/ -invalid_call, /** 449 **/ -invalid_call, /** 450 **/ -invalid_call, /** 451 **/ -invalid_call, /** 452 **/ -invalid_call, /** 453 **/ -invalid_call, /** 454 **/ -invalid_call, /** 455 **/ -}; - -int totalCalls_new = sizeof(systemCalls_new) / sizeof(functionPTR); - -#endif - -/*** - END - ***/ - diff --git a/include/ubixos/systemtask.h b/include/ubixos/systemtask.h deleted file mode 100644 index 22589b1..0000000 --- a/include/ubixos/systemtask.h +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYSTEMTASK_H -#define _SYSTEMTASK_H - -#include - -void systemTask(); - -#endif - -/*** - $Log: systemtask.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:56 reddawg - no message - - Revision 1.2 2004/06/04 17:49:32 reddawg - Wont work with out the makefile updated - - Revision 1.1 2004/06/04 17:33:33 reddawg - Changed idle task to system task - - Revision 1.2 2004/05/21 15:20:00 reddawg - Cleaned up - - - END - ***/ diff --git a/include/ubixos/time.h b/include/ubixos/time.h deleted file mode 100644 index d9ab30d..0000000 --- a/include/ubixos/time.h +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_TIME_H -#define _UBIXOS_TIME_H - -#include -#include -#include - -typedef long suseconds_t; - -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) - -#define MINUTE 60 -#define HOUR (60*MINUTE) -#define DAY (24*HOUR) -#define YEAR (365*DAY) - - -struct timeStruct { - int sec; - int min; - int hour; - int day; - int mon; - int year; -}; - -struct timezone { - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -int gettimeofday(struct timeval *tp, struct timezone *tzp); - -int time_init(); -uInt32 timeMake(struct timeStruct *time); - -#endif - -/*** - $Log: time.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:56 reddawg - no message - - Revision 1.4 2004/07/09 13:37:30 reddawg - time: timeInit to time_init - Adjusted initialization routines - - Revision 1.3 2004/06/29 11:41:44 reddawg - Fixed some global variables - - Revision 1.2 2004/05/21 15:20:00 reddawg - Cleaned up - - END - ***/ diff --git a/include/ubixos/times.h b/include/ubixos/times.h deleted file mode 100644 index eb575b1..0000000 --- a/include/ubixos/times.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _TIMES_H -#define _TIMES_H - -#include - -#ifndef _CLOCK_T_DECLARED -typedef __clock_t clock_t; -#define _CLOCK_T_DECLARED -#endif - -struct tms { - clock_t tms_utime; /* User CPU time */ - clock_t tms_stime; /* System CPU time */ - clock_t tms_cutime; /* User CPU time of terminated child procs */ - clock_t tms_cstime; /* System CPU time of terminated child procs */ -}; - -#endif - -/*** - $Log: times.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:57 reddawg - no message - - Revision 1.2 2004/05/21 15:20:00 reddawg - Cleaned up - - - END - ***/ diff --git a/include/ubixos/tty.h b/include/ubixos/tty.h deleted file mode 100644 index 4389db6..0000000 --- a/include/ubixos/tty.h +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_TTY_H -#define _UBIXOS_TTY_H - -#include - -#define TTY_MAX_TERMS 5 - -typedef struct tty_termNode { - char *tty_buffer; - char *tty_pointer; - uint8_t tty_colour; - uint16_t tty_x; - uint16_t tty_y; - pidType owner; - char stdin[512]; - int stdinSize; -} tty_term; - -int tty_init(); -int tty_change(uInt16); -tty_term *tty_find(uInt16); -int tty_print(char *, tty_term *); - -extern tty_term *tty_foreground; - -#endif diff --git a/include/ubixos/ubthread.h b/include/ubixos/ubthread.h deleted file mode 100644 index 26a07f4..0000000 --- a/include/ubixos/ubthread.h +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBTHREAD_H -#define _UBTHREAD_H - -#include -#include -#include - -#define LOCKED 1 -#define UNLOCKED 0 - -typedef struct ubthread *ubthread_t; -typedef struct ubthread_cond *ubthread_cond_t; -typedef struct ubthread_mutex *ubthread_mutex_t; - -struct ubthread { - struct taskStruct *task; -}; - -struct ubthread_cond { - int id; - bool lock; -}; - -struct ubthread_mutex { - int id; - bool lock; - pidType pid; -}; - -struct ubthread_list { - struct ubthread_list *next; - ubthread_t thread; -}; - -struct ubthread_cond_list { - struct ubthread_cond_list *next; - ubthread_cond_t *cond; -}; - -struct ubthread_mutex_list { - struct ubthread_mutex_list *next; - ubthread_mutex_t *mutex; -}; - -struct taskStruct *ubthread_self(); -int ubthread_cond_init(ubthread_cond_t *cond, const uInt32 attr); -int ubthread_mutex_init(ubthread_mutex_t *mutex, const uInt32 attr); -int ubthread_cond_destroy(ubthread_cond_t *cond); -int ubthread_mutex_destroy(ubthread_mutex_t *mutex); -int ubthread_create(struct taskStruct **thread, const uInt32 *attr, void (*tproc)(void), void *arg); -int ubthread_mutex_lock(ubthread_mutex_t *mutex); -int ubthread_mutex_unlock(ubthread_mutex_t *mutex); -int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime); -int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex); -int ubthread_cond_signal(ubthread_cond_t *cond); -int ubthread_cond_broadcast(ubthread_cond_t *cond); - -#endif diff --git a/include/ubixos/uthread.h b/include/ubixos/uthread.h deleted file mode 100644 index ac8b160..0000000 --- a/include/ubixos/uthread.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_UTHREAD_H -#define _UBIXOS_UTHREAD_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - struct uthread { - struct uthread *uthread_pointer; - size_t uthread_size; - unsigned long uthread_flags; - void *tls_master_mmap; - size_t tls_master_size; - size_t tls_master_align; - void *tls_mmap; - size_t stack_size; - void *arg_mmap; - size_t arg_size; - size_t __uthread_reserved[4]; - }; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/ubixos/vitals.h b/include/ubixos/vitals.h deleted file mode 100644 index 8c3ab88..0000000 --- a/include/ubixos/vitals.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_VITALS_H -#define _UBIXOS_VITALS_H - -#include -#include -#include - -typedef struct vitalsStruct { - uint32_t sysTicks; // 0 - Do Not Change Order - uint32_t sysUptime; // 4 - Do Not Change Order - uint32_t quantum; // 8 - Do Not Change Order - uint32_t dQuantum; // 12 - Do Not Change Order - uint32_t openFiles; - uint32_t lastFD; - uint32_t freePages; - struct fileSystem *fileSystems; - struct vfs_mountPoint *mountPoints; - uint32_t timeStart; - void *screen; - void *font; - char *packet; - uint32_t packetLength; -} vitalsNode; - -extern vitalsNode *systemVitals; -extern spinLock_t vitals_lock; - -int vitals_init(); - -#endif diff --git a/include/ubixos/wait.h b/include/ubixos/wait.h deleted file mode 100644 index 9c9f703..0000000 --- a/include/ubixos/wait.h +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _UBIXOS_WAIT_H -#define _UBIXOS_WAIT_H - -struct taskStruct; - -struct wait_queue { - struct taskStruct *task; - struct wait_queue *next; -}; - -struct semaphore { - int sount; - struct wait_queue *wait; -}; - -#define sti() __asm__ __volatile__ ("sti": : :"memory") -#define cli() __asm__ __volatile__ ("cli": : :"memory") -#define nop() __asm__ __volatile__ ("nop") - -#define save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=r" (x): /* no input */ :"memory") - -#define restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"r" (x):"memory") - -#endif diff --git a/include/vmm/paging.h b/include/vmm/paging.h deleted file mode 100644 index 6186705..0000000 --- a/include/vmm/paging.h +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VMM_PAGING_H_ -#define _VMM_PAGING_H_ - -#include -#include -#include - -#define PAGE_SHIFT 12 // Page Shift -#define PAGE_SIZE 0x1000 // Page Size -#define PAGE_MASK (PAGE_SIZE-1) // Page Mask - -#define PD_INDEX(v_addr) (v_addr >> 22) // Calc Page Directory Index -#define PD_OFFSET(v_addr) (v_addr >> 0xA) // Calc Page Directory OFfset -#define PT_INDEX(v_addr) ((v_addr >> 12) & 0x03FF) // Calc Page Table Offset -#define PD_BASE_ADDR2 ((PAGE_SIZE << 0xA) + VMM_KERN_START) // Find Out What This Was For - -#define PD_BASE_ADDR 0xC0400000 // Page Directory Addressable Base Address -#define PT_BASE_ADDR 0xC0000000 // Page Table Addressable Base Address - -#define PD_ENTRIES (PAGE_SIZE/4) //Return Page Directory Entries -#define PT_ENTRIES (PAGE_SIZE/4) //Return Page Table Entries - -#define VM_THRD 0 // Thread -#define VM_TASK 1 // Task - -// Page Flags -#define PAGE_PRESENT 0x00000001 -#define PAGE_WRITE 0x00000002 -#define PAGE_USER 0x00000004 -#define PAGE_WRITE_THROUGH 0x00000008 -#define PAGE_CACHE_DISABLED 0x00000010 -#define PAGE_ACCESSED 0x00000020 -#define PAGE_DIRTY 0x00000040 -#define PAGE_GLOBAL 0x00000080 -#define PAGE_ 0x00000100 -#define PAGE_COW 0x00000200 -#define PAGE_STACK 0x00000400 -#define PAGE_WIRED 0x00000800 - -#define PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE|PAGE_USER) -#define KERNEL_PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE) - -#define trunc_page(x) ((x) & ~PAGE_MASK) -#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) - -#define ctob(x) ((x)<>PAGE_SHIFT) - -int vmmClearVirtualPage(uint32_t pageAddr); - -void *vmm_mapFromTask(pidType, void *, uint32_t); -void *vmm_copyVirtualSpace(pidType); -void *vmm_getFreePage(pidType); -void *vmm_getFreeKernelPage(pidType pid, uint16_t count); -void *vmm_createVirtualSpace(pidType); -void *vmm_getFreeVirtualPage(pidType, int, int); - -uint32_t vmm_getPhysicalAddr(uint32_t); -uint32_t vmm_getRealAddr(uint32_t); -int vmm_setPageAttributes(uint32_t, uint16_t); -int vmm_remapPage(uint32_t, uint32_t, uint16_t, pidType, int haveLock); -int vmm_pagingInit(); -void *vmm_getFreeMallocPage(uint16_t count); -//void vmm_pageFault( uint32_t, uint32_t, uint32_t ); -void vmm_pageFault(struct trapframe *, uint32_t); -void _vmm_pageFault(); -int mmap(struct thread *, struct sys_mmap_args *); -int obreak(struct thread *, struct obreak_args *); -int munmap(struct thread *, struct sys_munmap_args *); - -int vmm_cleanVirtualSpace(uint32_t); -void *vmm_getFreeVirtualPage(pidType pid, int count, int type); - -extern uint32_t *kernelPageDirectory; - -#endif diff --git a/include/vmm/vmm.h b/include/vmm/vmm.h deleted file mode 100644 index bb769b1..0000000 --- a/include/vmm/vmm.h +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VMM_VMM_H -#define _VMM_VMM_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define STACK_ADDR 0xBFFFFFFF//0xC800000 // Default App Stack Address - -#define memAvail 1 -#define memNotavail 2 -#define vmmID -3 - - /* - #define vmmMemoryMapAddr 0xE6667000 - #define VMM_MMAP_ADDR_PMODE2 0xE6667000 - */ - -#define VMM_MMAP_ADDR_PMODE VMM_KERN_START /* (PD_BASE_ADDR + PAGE_SIZE) */ -#define VMM_MMAP_ADDR_RMODE 0x101000 - -#define VMM_KERN_CODE_START 0x00000000 -#define VMM_KERN_CODE_END 0x007FEFFF - -#define VMM_USER_LDT 0x007FF000 - -#define VMM_USER_START 0x00800000 -#define VMM_USER_END 0xBFFFFFFF - -#define VMM_PAGE_DIRS 0xC0000000 -#define VMM_PAGE_DIR 0xC0400000 - -#define VMM_KERN_START 0xC0800000 //TMP ADDED 1000 -#define VMM_KERN_END 0xFDFFFFFF - -#define VMM_KERN_STACK_START 0xFE000000 -#define VMM_KERN_STACK_END 0xFFFFFFFF - - extern struct spinLock pdSpinLock; - - - struct freebsd6_mmap_args { - char addr_l_[PADL_(caddr_t)]; - caddr_t addr; - char addr_r_[PADR_(caddr_t)]; - - char len_l_[PADL_(size_t)]; - size_t len; - char len_r_[PADR_(size_t)]; - - char prot_l_[PADL_(int)]; - int prot; - char prot_r_[PADR_(int)]; - char flags_l_[PADL_(int)]; - - int flags; - char flags_r_[PADR_(int)]; - char fd_l_[PADL_(int)]; - int fd; - char fd_r_[PADR_(int)]; - - char pad_l_[PADL_(int)]; - int pad; - char pad_r_[PADR_(int)]; - - char pos_l_[PADL_(off_t)]; - off_t pos; - char pos_r_[PADR_(off_t)]; - }; - - typedef struct { - uint32_t pageAddr; - u_int16_t status; - u_int16_t reserved; - pid_t pid; - int cowCounter; - } mMap; - - typedef enum { - VMM_FREE = 0, VMM_KEEP = 1 - } unmapFlags_t; - - extern int numPages; - extern mMap *vmmMemoryMap; - - int vmm_init(); - int vmm_memMapInit(); - int countMemory(); - uint32_t vmm_findFreePage(pidType pid); - int freePage(uint32_t pageAddr); - int adjustCowCounter(uint32_t baseAddr, int adjustment); - void vmm_freeProcessPages(pidType pid); - - int vmm_allocPageTable(uint32_t, pidType); - void vmm_unmapPage(uint32_t, unmapFlags_t); - void vmm_unmapPages(void *, uint32_t, unmapFlags_t); - -#ifdef __cplusplus -} -#endif - -#endif // _VMM_VMM_H diff --git a/include_old/machine/_types.h b/include_old/machine/_types.h index 84c2324..d57eb23 100644 --- a/include_old/machine/_types.h +++ b/include_old/machine/_types.h @@ -1,46 +1,72 @@ /*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. + * Copyright (c) 2002 Mike Barcroft + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. * - * This was developed by Christopher W. Olsen for the UbixOS Project. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 + * From: @(#)types.h 8.3 (Berkeley) 1/5/94 + * $FreeBSD: src/sys/i386/include/_types.h,v 1.7 2003/03/30 05:24:52 jake Exp $ */ #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ -// Basic types upon which most other types are built. +/* + * Basic types upon which most other types are built. + */ typedef __signed char __int8_t; typedef unsigned char __uint8_t; -typedef short __int16_t; +typedef short __int16_t; typedef unsigned short __uint16_t; -typedef int __int32_t; +typedef int __int32_t; typedef unsigned int __uint32_t; -typedef long long __int64_t; + +#if defined(lint) +/* LONGLONG */ +typedef long long __int64_t; +/* LONGLONG */ typedef unsigned long long __uint64_t; +#elif defined(__GNUC__) +typedef int __attribute__((__mode__(__DI__))) __int64_t; +typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t; +#else +/* LONGLONG */ +typedef long long __int64_t; +/* LONGLONG */ +typedef unsigned long long __uint64_t; +#endif -// Standard type definitions. - +/* + * Standard type definitions. + */ typedef unsigned long __clock_t; /* clock()... */ typedef __int32_t __critical_t; typedef double __double_t; @@ -76,8 +102,25 @@ typedef __uint32_t __u_register_t; typedef __uint32_t __vm_offset_t; typedef __int64_t __vm_ooffset_t; +#ifdef PAE +typedef __uint64_t __vm_paddr_t; +#else typedef __uint32_t __vm_paddr_t; +#endif typedef __uint64_t __vm_pindex_t; typedef __uint32_t __vm_size_t; +/* + * Unusual type definitions. + */ +#if defined(__GNUC__) && (__GNUC__ == 2 && __GNUC_MINOR__ > 95 || __GNUC__ >= 3) +typedef __builtin_va_list __va_list; /* internally known to gcc */ +#else +typedef char * __va_list; +#endif /* post GCC 2.95 */ +#if defined __GNUC__ && !defined(__GNUC_VA_LIST) && !defined(__NO_GNUC_VA_LIST) +#define __GNUC_VA_LIST +typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/ +#endif + #endif /* !_MACHINE__TYPES_H_ */ diff --git a/lib/libc/regex/grot/mkh b/lib/libc/regex/grot/mkh old mode 100644 new mode 100755 diff --git a/lib/objgfx/objgfx40.so b/lib/objgfx/objgfx40.so old mode 100644 new mode 100755 Binary files differ diff --git a/lib/objgfx40/ROMAN1.DPF b/lib/objgfx40/ROMAN1.DPF old mode 100644 new mode 100755 Binary files differ diff --git a/lib/objgfx40/SCRIPT.DPF b/lib/objgfx40/SCRIPT.DPF old mode 100644 new mode 100755 Binary files differ diff --git a/lib/objgfx40/objgfx40.cpp b/lib/objgfx40/objgfx40.cpp index 0b6aca8..5d867d0 100644 --- a/lib/objgfx40/objgfx40.cpp +++ b/lib/objgfx40/objgfx40.cpp @@ -15,7 +15,7 @@ extern "C" { #include #include -#include +#include #include } diff --git a/lib/objgfx40/ogDisplay_UbixOS.cc b/lib/objgfx40/ogDisplay_UbixOS.cc old mode 100644 new mode 100755 diff --git a/lib/objgfx40/ogFont.cpp b/lib/objgfx40/ogFont.cpp index 0b21703..38f74dc 100644 --- a/lib/objgfx40/ogFont.cpp +++ b/lib/objgfx40/ogFont.cpp @@ -3,7 +3,7 @@ extern "C" { #ifdef __UBIXOS_KERNEL__ -#include +#include #include #include #else diff --git a/sys/Makefile.incl b/sys/Makefile.incl index bf5137b..71ba64b 100644 --- a/sys/Makefile.incl +++ b/sys/Makefile.incl @@ -3,7 +3,7 @@ KERNEL_CONF=${KERNEL_SRC}/${_ARCH}/conf KERNEL_NAME=kernel KERNEL_FLAGS=_ARCH=${_ARCH} CC="cc" CXX="c++" AS="as" AR="ar" LD="ld" NM=nm OBJDUMP= OBJCOPY="objcopy" RANLIB=ranlib -KERNEL_INC=${KERNEL_SRC}/../include +KERNEL_INC=${KERNEL_SRC}/include KMAKE= ${MAKE} ${KERNEL_FLAGS} INCLUDE=${KERNEL_INC} KERNEL=${KERNEL_NAME} diff --git a/sys/fs/devfs/devfs.c b/sys/fs/devfs/devfs.c index 4b8a33a..ffb764e 100644 --- a/sys/fs/devfs/devfs.c +++ b/sys/fs/devfs/devfs.c @@ -26,8 +26,8 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include +#include #include #include #include diff --git a/sys/fs/ubixfs/block.c b/sys/fs/ubixfs/block.c index 261cc3c..8be4d23 100644 --- a/sys/fs/ubixfs/block.c +++ b/sys/fs/ubixfs/block.c @@ -66,9 +66,9 @@ *****************************************************************************************/ -#include -#include -#include +#include +#include +#include void syncBat(struct vfs_mountPoint *mp) { diff --git a/sys/fs/ubixfs/dirCache.c b/sys/fs/ubixfs/dirCache.c index f6f7f08..d4a483d 100644 --- a/sys/fs/ubixfs/dirCache.c +++ b/sys/fs/ubixfs/dirCache.c @@ -28,8 +28,8 @@ *****************************************************************************************/ #include -#include -#include +#include +#include #include #include #include diff --git a/sys/fs/ubixfs/directory.c b/sys/fs/ubixfs/directory.c index c47d1fb..52cd70d 100644 --- a/sys/fs/ubixfs/directory.c +++ b/sys/fs/ubixfs/directory.c @@ -27,9 +27,9 @@ *****************************************************************************************/ -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/sys/fs/ubixfs/thread.c b/sys/fs/ubixfs/thread.c old mode 100644 new mode 100755 index b1205a4..69481e4 --- a/sys/fs/ubixfs/thread.c +++ b/sys/fs/ubixfs/thread.c @@ -27,9 +27,9 @@ *****************************************************************************************/ -#include +#include #include -#include +#include #include static struct { diff --git a/sys/fs/ubixfs/ubixfs.c b/sys/fs/ubixfs/ubixfs.c index 2ea5462..602331c 100644 --- a/sys/fs/ubixfs/ubixfs.c +++ b/sys/fs/ubixfs/ubixfs.c @@ -27,9 +27,9 @@ *****************************************************************************************/ -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/sys/fs/ufs/ffs.c b/sys/fs/ufs/ffs.c index 2a74592..c9b8721 100644 --- a/sys/fs/ufs/ffs.c +++ b/sys/fs/ufs/ffs.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/sys/fs/ufs/ufs.c b/sys/fs/ufs/ufs.c index c3ecd6d..9ecb3ce 100644 --- a/sys/fs/ufs/ufs.c +++ b/sys/fs/ufs/ufs.c @@ -28,10 +28,10 @@ *****************************************************************************************/ #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/sys/fs/vfs/file.c b/sys/fs/vfs/file.c index 69e670d..4534ab6 100644 --- a/sys/fs/vfs/file.c +++ b/sys/fs/vfs/file.c @@ -27,7 +27,7 @@ */ #include -#include +#include #include #include #include diff --git a/sys/fs/vfs/inode.c b/sys/fs/vfs/inode.c index 6794040..30816cc 100644 --- a/sys/fs/vfs/inode.c +++ b/sys/fs/vfs/inode.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include diff --git a/sys/fs/vfs/mount.c b/sys/fs/vfs/mount.c index 7834732..4363a75 100644 --- a/sys/fs/vfs/mount.c +++ b/sys/fs/vfs/mount.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include diff --git a/sys/fs/vfs/namei.c b/sys/fs/vfs/namei.c index 2991df0..139bb9c 100644 --- a/sys/fs/vfs/namei.c +++ b/sys/fs/vfs/namei.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include int follow_link(struct inode * dir, struct inode * inode, int flag, int mode, struct inode ** res_inode) { diff --git a/sys/fs/vfs/stat.c b/sys/fs/vfs/stat.c index 5b5ea1b..ff102b6 100644 --- a/sys/fs/vfs/stat.c +++ b/sys/fs/vfs/stat.c @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/sys/fs/vfs/vfs.c b/sys/fs/vfs/vfs.c index 5f3914a..63f5535 100644 --- a/sys/fs/vfs/vfs.c +++ b/sys/fs/vfs/vfs.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include diff --git a/sys/i386/cpu.c b/sys/i386/cpu.c index ceb3db9..ef9e0c0 100644 --- a/sys/i386/cpu.c +++ b/sys/i386/cpu.c @@ -26,4 +26,4 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include diff --git a/sys/i386/i386_exec.c b/sys/i386/i386_exec.c index ad86bab..ae96533 100644 --- a/sys/i386/i386_exec.c +++ b/sys/i386/i386_exec.c @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/i386/memcmp.S b/sys/i386/memcmp.S index 6f250dd..c8e68c2 100644 --- a/sys/i386/memcmp.S +++ b/sys/i386/memcmp.S @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include + #include ENTRY(memcmp) pushl %edi diff --git a/sys/i386/memset.S b/sys/i386/memset.S index 128d1d1..03bef8d 100644 --- a/sys/i386/memset.S +++ b/sys/i386/memset.S @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include + #include ENTRY(memset) diff --git a/sys/i386/sched.c b/sys/i386/sched.c index 98ec14f..069868d 100644 --- a/sys/i386/sched.c +++ b/sys/i386/sched.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/i386/strcmp.S b/sys/i386/strcmp.S index 79884e2..19bb2ff 100644 --- a/sys/i386/strcmp.S +++ b/sys/i386/strcmp.S @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include + #include ENTRY(strcmp) movl 0x04(%esp),%eax diff --git a/sys/i386/strcpy.S b/sys/i386/strcpy.S index dd55272..e6f6a0c 100644 --- a/sys/i386/strcpy.S +++ b/sys/i386/strcpy.S @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include + #include ENTRY(strcpy) movl 4(%esp),%ecx /* dst address */ diff --git a/sys/i386/strncmp.S b/sys/i386/strncmp.S index 30d5ba1..9696281 100644 --- a/sys/i386/strncmp.S +++ b/sys/i386/strncmp.S @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include + #include ENTRY(strncmp) pushl %ebx diff --git a/sys/i386/support.S b/sys/i386/support.S index 6b4c974..347cdf8 100644 --- a/sys/i386/support.S +++ b/sys/i386/support.S @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include + #include .text // void bzero(void *buf, u_int len) diff --git a/sys/i386/trap.c b/sys/i386/trap.c index 5bba1f8..60f0c65 100644 --- a/sys/i386/trap.c +++ b/sys/i386/trap.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include diff --git a/sys/include/fs/common/crc32.h b/sys/include/fs/common/crc32.h new file mode 100644 index 0000000..43e722b --- /dev/null +++ b/sys/include/fs/common/crc32.h @@ -0,0 +1,13 @@ +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * $FreeBSD: releng/10.2/sys/boot/common/crc32.h 213136 2010-09-24 19:49:12Z pjd $ + */ + +#ifndef _CRC32_H_ +#define _CRC32_H_ + +uint32_t crc32(const void *buf, size_t size); + +#endif /* !_CRC32_H_ */ diff --git a/sys/include/i386/asmacros.h b/sys/include/i386/asmacros.h new file mode 100644 index 0000000..1c48c28 --- /dev/null +++ b/sys/include/i386/asmacros.h @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * asmacros.h + * + * Created on: Jan 12, 2018 + * Author: cwolsen + */ + +#ifndef _I386_ASMACROS_H_ +#define _I386_ASMACROS_H_ + +/* + * CNAME is used to manage the relationship between symbol names in C + * and the equivalent assembly language names. CNAME is given a name as + * it would be used in a C program. It expands to the equivalent assembly + * language name. + */ +#define CNAME(csym) csym +#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ + +#define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ + .type CNAME(name),@function; CNAME(name): + +#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT +#define MCOUNT nop +#define END(name) .size name, . - name + +#endif /* END _I386_ASMACROS_H_ */ diff --git a/sys/include/i386/cpu.h b/sys/include/i386/cpu.h new file mode 100644 index 0000000..96841d6 --- /dev/null +++ b/sys/include/i386/cpu.h @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _CPU_H_ +#define _CPU_H_ + +#include + +/* + * 386 processor status longword. + */ +#define PSL_C 0x00000001 /* carry bit */ +#define PSL_PF 0x00000004 /* parity bit */ +#define PSL_AF 0x00000010 /* bcd carry bit */ +#define PSL_Z 0x00000040 /* zero bit */ +#define PSL_N 0x00000080 /* negative bit */ +#define PSL_T 0x00000100 /* trace enable bit */ +#define PSL_I 0x00000200 /* interrupt enable bit */ +#define PSL_D 0x00000400 /* string instruction direction bit */ +#define PSL_V 0x00000800 /* overflow bit */ +#define PSL_IOPL 0x00003000 /* i/o privilege level */ +#define PSL_NT 0x00004000 /* nested task bit */ +#define PSL_RF 0x00010000 /* resume flag bit */ +#define PSL_VM 0x00020000 /* virtual 8086 mode bit */ +#define PSL_AC 0x00040000 /* alignment checking */ +#define PSL_VIF 0x00080000 /* virtual interrupt enable */ +#define PSL_VIP 0x00100000 /* virtual interrupt pending */ +#define PSL_ID 0x00200000 /* identification bit */ + +/* Read Contents Of CR0 */ +static __inline u_int rcr0(void) { + u_int data; + __asm __volatile("movl %%cr0,%0" : "=r" (data)); + return (data); +} + +/* Write To CR0 */ +static __inline void load_cr0(u_int data) { + __asm __volatile("movl %0,%%cr0" : : "r" (data)); +} + +static __inline u_int rcr2(void) { + u_int data; + + __asm __volatile("movl %%cr2,%0" : "=r" (data)); + return (data); +} + +static __inline u_int rcr3(void) { + u_int data; + + __asm __volatile("movl %%cr3,%0" : "=r" (data)); + return (data); +} + +static __inline void load_cr3(u_int data) { + __asm __volatile("movl %0,%%cr3" : : "r" (data) : "memory"); +} + +static __inline u_int rcr4(void) { + u_int data; + + __asm __volatile("movl %%cr4,%0" : "=r" (data)); + return (data); +} + +static __inline void load_cr4(u_int data) { + __asm __volatile("movl %0,%%cr4" : : "r" (data)); +} + +static __inline void invlpg(u_int addr) { + __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); +} + +#endif + +/*** + END + ***/ diff --git a/sys/include/i386/elf.h b/sys/include/i386/elf.h new file mode 100644 index 0000000..a453017 --- /dev/null +++ b/sys/include/i386/elf.h @@ -0,0 +1,214 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _I386_ELF_H_ +#define _I386_ELF_H_ 1 + +#if defined(__i386__) || defined(_MACHINE_ELF_WANT_32BIT) + +/* + * ELF definitions for the i386 architecture. + */ + +#include /* Definitions common to all 32 bit architectures. */ +#if defined(__ELF_WORD_SIZE) && __ELF_WORD_SIZE == 64 +#include /* Definitions common to all 64 bit architectures. */ +#endif + +#ifndef __ELF_WORD_SIZE +#define __ELF_WORD_SIZE 32 /* Used by */ +#endif + +#include + +#define ELF_ARCH EM_386 + +#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486) + +/* + * Auxiliary vector entries for passing information to the interpreter. + * + * The i386 supplement to the SVR4 ABI specification names this "auxv_t", + * but POSIX lays claim to all symbols ending with "_t". + */ + +typedef struct { /* Auxiliary vector entry on initial stack */ + int a_type; /* Entry type. */ + union { + long a_val; /* Integer value. */ + void *a_ptr; /* Address. */ + void (*a_fcn)(void); /* Function pointer (not used). */ + }a_un; +}Elf32_Auxinfo; + +#if __ELF_WORD_SIZE == 64 +/* Fake for amd64 loader support */ +typedef struct { + int fake; +}Elf64_Auxinfo; +#endif + +__ElfType(Auxinfo); + +/* Values for a_type. */ +#define AT_NULL 0 /* Terminates the vector. */ +#define AT_IGNORE 1 /* Ignored entry. */ +#define AT_EXECFD 2 /* File descriptor of program to load. */ +#define AT_PHDR 3 /* Program header of program already loaded. */ +#define AT_PHENT 4 /* Size of each program header entry. */ +#define AT_PHNUM 5 /* Number of program header entries. */ +#define AT_PAGESZ 6 /* Page size in bytes. */ +#define AT_BASE 7 /* Interpreter's base address. */ +#define AT_FLAGS 8 /* Flags (unused for i386). */ +#define AT_ENTRY 9 /* Where interpreter should transfer control. */ +#define AT_NOTELF 10 /* Program is not ELF ?? */ +#define AT_UID 11 /* Real uid. */ +#define AT_EUID 12 /* Effective uid. */ +#define AT_GID 13 /* Real gid. */ +#define AT_EGID 14 /* Effective gid. */ +#define AT_EXECPATH 15 /* Path to the executable. */ +#define AT_CANARY 16 /* Canary for SSP. */ +#define AT_CANARYLEN 17 /* Length of the canary. */ +#define AT_OSRELDATE 18 /* OSRELDATE. */ +#define AT_NCPUS 19 /* Number of CPUs. */ +#define AT_PAGESIZES 20 /* Pagesizes. */ +#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ +#define AT_STACKPROT 23 /* Initial stack protection. */ + +#define AT_COUNT 24 /* Count of defined aux entry types. */ + +/* + * Relocation types. + */ + +#define R_386_COUNT 38 /* Count of defined relocation types. */ + +/* Define "machine" characteristics */ +#define ELF_TARG_CLASS ELFCLASS32 +#define ELF_TARG_DATA ELFDATA2LSB +#define ELF_TARG_MACH EM_386 +#define ELF_TARG_VER 1 + +#define ET_DYN_LOAD_ADDR 0x01001000 + +#elif defined(__amd64__) + +/* + * ELF definitions for the AMD64 architecture. + */ + +#ifndef __ELF_WORD_SIZE +#define __ELF_WORD_SIZE 64 /* Used by */ +#endif +#include /* Definitions common to all 32 bit architectures. */ +#include /* Definitions common to all 64 bit architectures. */ +#include + +#define ELF_ARCH EM_X86_64 +#define ELF_ARCH32 EM_386 + +#define ELF_MACHINE_OK(x) ((x) == EM_X86_64) + +/* + * Auxiliary vector entries for passing information to the interpreter. + * + * The i386 supplement to the SVR4 ABI specification names this "auxv_t", + * but POSIX lays claim to all symbols ending with "_t". + */ +typedef struct { /* Auxiliary vector entry on initial stack */ + int a_type; /* Entry type. */ + union { + int a_val; /* Integer value. */ + }a_un; +}Elf32_Auxinfo; + +typedef struct { /* Auxiliary vector entry on initial stack */ + long a_type; /* Entry type. */ + union { + long a_val; /* Integer value. */ + void *a_ptr; /* Address. */ + void (*a_fcn)(void); /* Function pointer (not used). */ + }a_un; +}Elf64_Auxinfo; + +__ElfType(Auxinfo); + +/* Values for a_type. */ +#define AT_NULL 0 /* Terminates the vector. */ +#define AT_IGNORE 1 /* Ignored entry. */ +#define AT_EXECFD 2 /* File descriptor of program to load. */ +#define AT_PHDR 3 /* Program header of program already loaded. */ +#define AT_PHENT 4 /* Size of each program header entry. */ +#define AT_PHNUM 5 /* Number of program header entries. */ +#define AT_PAGESZ 6 /* Page size in bytes. */ +#define AT_BASE 7 /* Interpreter's base address. */ +#define AT_FLAGS 8 /* Flags (unused for i386). */ +#define AT_ENTRY 9 /* Where interpreter should transfer control. */ +#define AT_NOTELF 10 /* Program is not ELF ?? */ +#define AT_UID 11 /* Real uid. */ +#define AT_EUID 12 /* Effective uid. */ +#define AT_GID 13 /* Real gid. */ +#define AT_EGID 14 /* Effective gid. */ +#define AT_EXECPATH 15 /* Path to the executable. */ +#define AT_CANARY 16 /* Canary for SSP */ +#define AT_CANARYLEN 17 /* Length of the canary. */ +#define AT_OSRELDATE 18 /* OSRELDATE. */ +#define AT_NCPUS 19 /* Number of CPUs. */ +#define AT_PAGESIZES 20 /* Pagesizes. */ +#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ +#define AT_TIMEKEEP 22 /* Pointer to timehands. */ +#define AT_STACKPROT 23 /* Initial stack protection. */ + +#define AT_COUNT 24 /* Count of defined aux entry types. */ + +/* + * Relocation types. + */ + +#define R_X86_64_COUNT 24 /* Count of defined relocation types. */ + +/* Define "machine" characteristics */ +#if __ELF_WORD_SIZE == 32 +#define ELF_TARG_CLASS ELFCLASS32 +#else +#define ELF_TARG_CLASS ELFCLASS64 +#endif +#define ELF_TARG_DATA ELFDATA2LSB +#define ELF_TARG_MACH EM_X86_64 +#define ELF_TARG_VER 1 + +#if __ELF_WORD_SIZE == 32 +#define ET_DYN_LOAD_ADDR 0x01001000 +#else +#define ET_DYN_LOAD_ADDR 0x01021000 +#endif + +#endif /* __i386__, __amd64__ */ + +#endif diff --git a/sys/include/i386/limits.h b/sys/include/i386/limits.h new file mode 100644 index 0000000..7910260 --- /dev/null +++ b/sys/include/i386/limits.h @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _I386_LIMITS_H +#define _I386_LIMITS_H + +#define __LONG_BIT 32 + +#endif /* END _I386_LIMITS_H */ diff --git a/sys/include/isa/atkbd.h b/sys/include/isa/atkbd.h new file mode 100644 index 0000000..c1e41d9 --- /dev/null +++ b/sys/include/isa/atkbd.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ISA_ATKBD_H +#define _ISA_ATKBD_H + +#define shiftKey 1 +#define controlKey 2 +#define altKey 4 +#define ledNumlock 2 +#define ledScrolllock 1 +#define ledCapslock 4 + +int atkbd_init(); +void atkbd_isr(); + +void keyboardHandler(); +void setLED(); + + +#endif /* END _ISA_ATKBD_H */ diff --git a/sys/include/isa/ne2k.h b/sys/include/isa/ne2k.h new file mode 100644 index 0000000..e908f9c --- /dev/null +++ b/sys/include/isa/ne2k.h @@ -0,0 +1,190 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ISA_NE2K_H +#define _ISA_NE2K_H + +#include +#include + +#define ether_addr ether_addr_t +typedef struct dp_rcvhdr +{ + uInt8 dr_status; /* Copy of rsr */ + uInt8 dr_next; /* Pointer to next packet */ + uInt8 dr_rbcl; /* Receive Byte Count Low */ + uInt8 dr_rbch; /* Receive Byte Count High */ +} dp_rcvhdr_t; + +typedef union etheraddr { + unsigned char bytes[6]; /* byteorder safe initialization */ + unsigned short shorts[3]; /* force 2-byte alignment */ +} ether_addr; + + +#define RSR_FO 0x08 +#define RSR_PRX 0x01 +#define DEF_ENABLED 0x200 + +#define OK 0 + + +#define startPage 0x4C +#define stopPage 0x80 + + +#define NE_CMD 0x00 +#define NE_PSTART 0x01 +#define NE_PSTOP 0x02 +#define NE_BNRY 0x03 +#define NE_TPSR 0x04 +#define NE_ISR 0x07 +#define NE_CURRENT 0x07 +#define NE_RBCR0 0x0A +#define NE_RBCR1 0x0B +#define NE_RCR 0x0C +#define NE_TCR 0x0D +#define NE_DCR 0x0E +#define NE_IMR 0x0F + + +#define NE_DCR_WTS 0x01 +#define NE_DCR_LS 0x08 +#define NE_DCR_AR 0x10 +#define NE_DCR_FT1 0x40 +#define NE_DCR_FT0 0x20 + + + +#define E8390_STOP 0x01 +#define E8390_NODMA 0x20 +#define E8390_PAGE0 0x00 +#define E8390_PAGE1 0x40 +#define E8390_CMD 0x00 +#define E8390_START 0x02 +#define E8390_RREAD 0x08 +#define E8390_RWRITE 0x10 +#define E8390_RXOFF 0x20 +#define E8390_TXOFF 0x00 +#define E8390_RXCONFIG 0x04 +#define E8390_TXCONFIG 0x00 + +#define EN0_COUNTER0 0x0d +#define EN0_DCFG 0x0e +#define EN0_RCNTLO 0x0a +#define EN0_RCNTHI 0x0b +#define EN0_ISR 0x07 +#define EN0_IMR 0x0f +#define EN0_RSARLO 0x08 +#define EN0_RSARHI 0x09 +#define EN0_TPSR 0x04 +#define EN0_RXCR 0x0c +#define EN0_TXCR 0x0D +#define EN0_STARTPG 0x01 +#define EN0_STOPPG 0x02 +#define EN0_BOUNDARY 0x03 + +#define EN1_PHYS 0x01 +#define EN1_CURPAG 0x07 +#define EN1_MULT 0x08 + +#define NE1SM_START_PG 0x20 +#define NE1SM_STOP_PG 0x40 +#define NESM_START_PG 0x40 +#define NESM_STOP_PG 0x80 + +#define ENISR_ALL 0x3f + +#define ENDCFG_WTS 0x01 + +#define NE_DATAPORT 0x10 + +#define TX_2X_PAGES 12 +#define TX_1X_PAGES 6 +#define TX_PAGES (dev->priv->pingPong ? TX_2X_PAGES : TX_1X_PAGES) + + +#define DP_CURR 0x7 /* Current Page Register */ +#define DP_MAR0 0x8 /* Multicast Address Register 0 */ +#define DP_MAR1 0x9 /* Multicast Address Register 1 */ +#define DP_MAR2 0xA /* Multicast Address Register 2 */ +#define DP_MAR3 0xB /* Multicast Address Register 3 */ +#define DP_MAR4 0xC /* Multicast Address Register 4 */ +#define DP_MAR5 0xD /* Multicast Address Register 5 */ +#define DP_MAR6 0xE /* Multicast Address Register 6 */ +#define DP_MAR7 0xF /* Multicast Address Register 7 */ + +#define DP_CNTR0 0xD /* Tally Counter 0 */ +#define DP_CNTR1 0xE /* Tally Counter 1 */ +#define DP_CNTR2 0xF /* Tally Counter 2 */ + + +#define DP_PAGESIZE 256 + +extern char *nicPacket; +extern uInt32 packetLength; + + +int ne2k_init(); +int ne2kProbe(int,struct device *); +int ne2kDevInit(struct device *); +void NS8390_init(struct device *dev,int startp); + +void ne2kISR(); +void ne2kHandler(); + +int NICtoPC(struct device *dev,void *packet,int length,int nic_addr); +int PCtoNIC(struct device *dev,void *packet,int length); + +struct nicBuffer *ne2kAllocBuffer(int); +struct nicBuffer *ne2kGetBuffer(); +void ne2kFreeBuffer(struct nicBuffer *); + +#endif + +/*** + $Log: ne2k.h,v $ + Revision 1.1.1.1 2006/06/01 12:46:14 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:36 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:39 reddawg + no message + + Revision 1.6 2004/07/14 12:03:49 reddawg + ne2k: ne2kInit to ne2k_init + Changed Startup Routines + + Revision 1.5 2004/05/21 14:57:16 reddawg + Cleaned up + + + END + ***/ diff --git a/sys/include/lib/bioscall.h b/sys/include/lib/bioscall.h new file mode 100644 index 0000000..6593bb4 --- /dev/null +++ b/sys/include/lib/bioscall.h @@ -0,0 +1,60 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _ISA_BIOSCALL_H +#define _ISA_BIOSCALL_H + +#include + +#define EFLAG_TF 0x100 +#define EFLAG_IF 0x200 +#define EFLAG_IOPL3 0x3000 +#define EFLAG_VM 0x20000 + +void biosCall(int biosInt, int eax, int ebx, int ecx, int edx, int esi, int edi, int es, int ds); +void bios16Code(); + +#endif + +/*** + $Log: bioscall.h,v $ + Revision 1.1.1.1 2006/06/01 12:46:13 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:36 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:40 reddawg + no message + + Revision 1.2 2004/05/21 15:00:27 reddawg + Cleaned up + + + END + ***/ diff --git a/sys/include/lib/kmalloc.h b/sys/include/lib/kmalloc.h new file mode 100644 index 0000000..edc4889 --- /dev/null +++ b/sys/include/lib/kmalloc.h @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LIB_KMALLOC_H +#define _LIB_KMALLOC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define sysID -2 +#define MALLOC_ALIGN_SIZE 32 +#define MALLOC_ALIGN(size) (size + ((((size) % (MALLOC_ALIGN_SIZE)) == 0)? 0 : ((MALLOC_ALIGN_SIZE) - ((size) % (MALLOC_ALIGN_SIZE))))) + + struct memDescriptor { + struct memDescriptor *prev; //4 + struct memDescriptor *next; //4 + void *baseAddr; //4 + uInt32 limit; //4 + /*uInt8 status; //1 */ + /*char reserved[11]; //11 */ + }; + + void kfree(void *baseAddr); + void *kmalloc(uInt32 len); + +#ifdef __cplusplus +} +#endif + +#endif + +/*** + $Log: kmalloc.h,v $ + Revision 1.1.1.1 2006/06/01 12:46:13 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:36 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:40 reddawg + no message + + Revision 1.7 2004/09/14 20:57:01 reddawg + Bug fixes: macro problem over opt a multiply + + Revision 1.6 2004/07/21 10:02:09 reddawg + devfs: renamed functions + device system: renamed functions + fdc: fixed a few potential bugs and cleaned up some unused variables + strol: fixed definition + endtask: made it print out freepage debug info + kmalloc: fixed a huge memory leak we had some unhandled descriptor insertion so some descriptors were lost + ld: fixed a pointer conversion + file: cleaned up a few unused variables + sched: broke task deletion + kprintf: fixed ogPrintf definition + + Revision 1.5 2004/07/19 02:08:27 reddawg + Cleaned out the rest of debuging code also temporarily disabled the ip stack to improve boot time + + Revision 1.4 2004/07/18 05:24:15 reddawg + Fixens + + Revision 1.3 2004/05/21 15:00:27 reddawg + Cleaned up + + END + ***/ diff --git a/sys/include/lib/libcpp.h b/sys/include/lib/libcpp.h new file mode 100644 index 0000000..47d9deb --- /dev/null +++ b/sys/include/lib/libcpp.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LIBCPP_H +#define __LIBCPP_H + +#include + +void * operator new(unsigned size); +void operator delete(void * ptr); +void * operator new[](unsigned size); +void operator delete[](void * ptr); + +#endif diff --git a/sys/include/math.h b/sys/include/math.h new file mode 100644 index 0000000..d5418c1 --- /dev/null +++ b/sys/include/math.h @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MATH_H +#define __MATH_H + +#include + +//typedef long long int quad_t; +//typedef unsigned long long int u_quad_t; + +double atan(double x); +double sqrt(double x); +u_quad_t __udivdi3(u_quad_t a, u_quad_t b); +quad_t __divdi3(quad_t a, quad_t b); + +#endif + +/*** + $Log: math.h,v $ + Revision 1.2 2006/10/31 20:41:16 reddawg + Includes + + Revision 1.1.1.1 2006/06/01 12:46:13 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:36 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:38 reddawg + no message + + Revision 1.2 2004/05/21 15:22:35 reddawg + Cleaned up + + + END + ***/ diff --git a/sys/include/net/api.h b/sys/include/net/api.h new file mode 100644 index 0000000..afec037 --- /dev/null +++ b/sys/include/net/api.h @@ -0,0 +1,400 @@ +/** + * @file + * netconn API (to be used from non-TCPIP threads) + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_API_H +#define LWIP_HDR_API_H + +#include "net/opt.h" + +#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ +/* Note: Netconn API is always available when sockets are enabled - + * sockets are implemented on top of them */ + +#include "net/arch.h" +#include "net/netbuf.h" +#include "net/sys.h" +#include "net/ip_addr.h" +#include "net/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Throughout this file, IP addresses and port numbers are expected to be in + * the same byte order as in the corresponding pcb. + */ + +/* Flags for netconn_write (u8_t) */ +#define NETCONN_NOFLAG 0x00 +#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */ +#define NETCONN_COPY 0x01 +#define NETCONN_MORE 0x02 +#define NETCONN_DONTBLOCK 0x04 + +/* Flags for struct netconn.flags (u8_t) */ +/** Should this netconn avoid blocking? */ +#define NETCONN_FLAG_NON_BLOCKING 0x02 +/** Was the last connect action a non-blocking one? */ +#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 +/** If a nonblocking write has been rejected before, poll_tcp needs to + check if the netconn is writable again */ +#define NETCONN_FLAG_CHECK_WRITESPACE 0x10 +#if LWIP_IPV6 +/** If this flag is set then only IPv6 communication is allowed on the + netconn. As per RFC#3493 this features defaults to OFF allowing + dual-stack usage by default. */ +#define NETCONN_FLAG_IPV6_V6ONLY 0x20 +#endif /* LWIP_IPV6 */ + + +/* Helpers to process several netconn_types by the same code */ +#define NETCONNTYPE_GROUP(t) ((t)&0xF0) +#define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0) +#if LWIP_IPV6 +#define NETCONN_TYPE_IPV6 0x08 +#define NETCONNTYPE_ISIPV6(t) (((t)&NETCONN_TYPE_IPV6) != 0) +#define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF3) == NETCONN_UDPLITE) +#define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF3) == NETCONN_UDPNOCHKSUM) +#else /* LWIP_IPV6 */ +#define NETCONNTYPE_ISIPV6(t) (0) +#define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE) +#define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM) +#endif /* LWIP_IPV6 */ + +/** @ingroup netconn_common + * Protocol family and type of the netconn + */ +enum netconn_type { + NETCONN_INVALID = 0, + /** TCP IPv4 */ + NETCONN_TCP = 0x10, +#if LWIP_IPV6 + /** TCP IPv6 */ + NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 /* 0x18 */, +#endif /* LWIP_IPV6 */ + /** UDP IPv4 */ + NETCONN_UDP = 0x20, + /** UDP IPv4 lite */ + NETCONN_UDPLITE = 0x21, + /** UDP IPv4 no checksum */ + NETCONN_UDPNOCHKSUM = 0x22, + +#if LWIP_IPV6 + /** UDP IPv6 (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ + NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 /* 0x28 */, + /** UDP IPv6 lite (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ + NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 /* 0x29 */, + /** UDP IPv6 no checksum (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ + NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 /* 0x2a */, +#endif /* LWIP_IPV6 */ + + /** Raw connection IPv4 */ + NETCONN_RAW = 0x40 +#if LWIP_IPV6 + /** Raw connection IPv6 (dual-stack by default, unless you call @ref netconn_set_ipv6only) */ + , NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6 /* 0x48 */ +#endif /* LWIP_IPV6 */ +}; + +/** Current state of the netconn. Non-TCP netconns are always + * in state NETCONN_NONE! */ +enum netconn_state { + NETCONN_NONE, + NETCONN_WRITE, + NETCONN_LISTEN, + NETCONN_CONNECT, + NETCONN_CLOSE +}; + +/** Used to inform the callback function about changes + * + * Event explanation: + * + * In the netconn implementation, there are three ways to block a client: + * + * - accept mbox (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, 0); in netconn_accept()) + * - receive mbox (sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); in netconn_recv_data()) + * - send queue is full (sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0); in lwip_netconn_do_write()) + * + * The events have to be seen as events signaling the state of these mboxes/semaphores. For non-blocking + * connections, you need to know in advance whether a call to a netconn function call would block or not, + * and these events tell you about that. + * + * RCVPLUS events say: Safe to perform a potentially blocking call call once more. + * They are counted in sockets - three RCVPLUS events for accept mbox means you are safe + * to call netconn_accept 3 times without being blocked. + * Same thing for receive mbox. + * + * RCVMINUS events say: Your call to to a possibly blocking function is "acknowledged". + * Socket implementation decrements the counter. + * + * For TX, there is no need to count, its merely a flag. SENDPLUS means you may send something. + * SENDPLUS occurs when enough data was delivered to peer so netconn_send() can be called again. + * A SENDMINUS event occurs when the next call to a netconn_send() would be blocking. + */ +enum netconn_evt { + NETCONN_EVT_RCVPLUS, + NETCONN_EVT_RCVMINUS, + NETCONN_EVT_SENDPLUS, + NETCONN_EVT_SENDMINUS, + NETCONN_EVT_ERROR +}; + +#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) +/** Used for netconn_join_leave_group() */ +enum netconn_igmp { + NETCONN_JOIN, + NETCONN_LEAVE +}; +#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ + +#if LWIP_DNS +/* Used for netconn_gethostbyname_addrtype(), these should match the DNS_ADDRTYPE defines in dns.h */ +#define NETCONN_DNS_DEFAULT NETCONN_DNS_IPV4_IPV6 +#define NETCONN_DNS_IPV4 0 +#define NETCONN_DNS_IPV6 1 +#define NETCONN_DNS_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */ +#define NETCONN_DNS_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */ +#endif /* LWIP_DNS */ + +/* forward-declare some structs to avoid to include their headers */ +struct ip_pcb; +struct tcp_pcb; +struct udp_pcb; +struct raw_pcb; +struct netconn; +struct api_msg; + +/** A callback prototype to inform about events for a netconn */ +typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len); + +/** A netconn descriptor */ +struct netconn { + /** type of the netconn (TCP, UDP or RAW) */ + enum netconn_type type; + /** current state of the netconn */ + enum netconn_state state; + /** the lwIP internal protocol control block */ + union { + struct ip_pcb *ip; + struct tcp_pcb *tcp; + struct udp_pcb *udp; + struct raw_pcb *raw; + } pcb; + /** the last error this netconn had */ + err_t last_err; +#if !LWIP_NETCONN_SEM_PER_THREAD + /** sem that is used to synchronously execute functions in the core context */ + sys_sem_t op_completed; +#endif + /** mbox where received packets are stored until they are fetched + by the netconn application thread (can grow quite big) */ + sys_mbox_t recvmbox; +#if LWIP_TCP + /** mbox where new connections are stored until processed + by the application thread */ + sys_mbox_t acceptmbox; +#endif /* LWIP_TCP */ + /** only used for socket layer */ +#if LWIP_SOCKET + int socket; +#endif /* LWIP_SOCKET */ +#if LWIP_SO_SNDTIMEO + /** timeout to wait for sending data (which means enqueueing data for sending + in internal buffers) in milliseconds */ + s32_t send_timeout; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVTIMEO + /** timeout in milliseconds to wait for new data to be received + (or connections to arrive for listening netconns) */ + int recv_timeout; +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF + /** maximum amount of bytes queued in recvmbox + not used for TCP: adjust TCP_WND instead! */ + int recv_bufsize; + /** number of bytes currently in recvmbox to be received, + tested against recv_bufsize to limit bytes on recvmbox + for UDP and RAW, used for FIONREAD */ + int recv_avail; +#endif /* LWIP_SO_RCVBUF */ +#if LWIP_SO_LINGER + /** values <0 mean linger is disabled, values > 0 are seconds to linger */ + s16_t linger; +#endif /* LWIP_SO_LINGER */ + /** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */ + u8_t flags; +#if LWIP_TCP + /** TCP: when data passed to netconn_write doesn't fit into the send buffer, + this temporarily stores how much is already sent. */ + size_t write_offset; + /** TCP: when data passed to netconn_write doesn't fit into the send buffer, + this temporarily stores the message. + Also used during connect and close. */ + struct api_msg *current_msg; +#endif /* LWIP_TCP */ + /** A callback function that is informed about events for this netconn */ + netconn_callback callback; +}; + +/** Register an Network connection event */ +#define API_EVENT(c,e,l) if (c->callback) { \ + (*c->callback)(c, e, l); \ + } + +/** Set conn->last_err to err but don't overwrite fatal errors */ +#define NETCONN_SET_SAFE_ERR(conn, err) do { if ((conn) != NULL) { \ + SYS_ARCH_DECL_PROTECT(netconn_set_safe_err_lev); \ + SYS_ARCH_PROTECT(netconn_set_safe_err_lev); \ + if (!ERR_IS_FATAL((conn)->last_err)) { \ + (conn)->last_err = err; \ + } \ + SYS_ARCH_UNPROTECT(netconn_set_safe_err_lev); \ +}} while(0); + +/* Network connection functions: */ + +/** @ingroup netconn_common + * Create new netconn connection + * @param t @ref netconn_type */ +#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) +#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) +struct netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, + netconn_callback callback); +err_t netconn_delete(struct netconn *conn); +/** Get the type of a netconn (as enum netconn_type). */ +#define netconn_type(conn) (conn->type) + +err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, + u16_t *port, u8_t local); +/** @ingroup netconn_common */ +#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) +/** @ingroup netconn_common */ +#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) + +err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port); +err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port); +err_t netconn_disconnect (struct netconn *conn); +err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); +/** @ingroup netconn_tcp */ +#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) +err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); +err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); +err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); +err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, + const ip_addr_t *addr, u16_t port); +err_t netconn_send(struct netconn *conn, struct netbuf *buf); +err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, + u8_t apiflags, size_t *bytes_written); +/** @ingroup netconn_tcp */ +#define netconn_write(conn, dataptr, size, apiflags) \ + netconn_write_partly(conn, dataptr, size, apiflags, NULL) +err_t netconn_close(struct netconn *conn); +err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); + +#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) +err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr, + const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); +#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ +#if LWIP_DNS +#if LWIP_IPV4 && LWIP_IPV6 +err_t netconn_gethostbyname_addrtype(const char *name, ip_addr_t *addr, u8_t dns_addrtype); +#define netconn_gethostbyname(name, addr) netconn_gethostbyname_addrtype(name, addr, NETCONN_DNS_DEFAULT) +#else /* LWIP_IPV4 && LWIP_IPV6 */ +err_t netconn_gethostbyname(const char *name, ip_addr_t *addr); +#define netconn_gethostbyname_addrtype(name, addr, dns_addrtype) netconn_gethostbyname(name, addr) +#endif /* LWIP_IPV4 && LWIP_IPV6 */ +#endif /* LWIP_DNS */ + +#define netconn_err(conn) ((conn)->last_err) +#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) + +/** Set the blocking status of netconn calls (@todo: write/send is missing) */ +#define netconn_set_nonblocking(conn, val) do { if(val) { \ + (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ +} else { \ + (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) +/** Get the blocking status of netconn calls (@todo: write/send is missing) */ +#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) + +#if LWIP_IPV6 +/** @ingroup netconn_common + * TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) + */ +#define netconn_set_ipv6only(conn, val) do { if(val) { \ + (conn)->flags |= NETCONN_FLAG_IPV6_V6ONLY; \ +} else { \ + (conn)->flags &= ~ NETCONN_FLAG_IPV6_V6ONLY; }} while(0) +/** @ingroup netconn_common + * TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY) + */ +#define netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0) +#endif /* LWIP_IPV6 */ + +#if LWIP_SO_SNDTIMEO +/** Set the send timeout in milliseconds */ +#define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) +/** Get the send timeout in milliseconds */ +#define netconn_get_sendtimeout(conn) ((conn)->send_timeout) +#endif /* LWIP_SO_SNDTIMEO */ +#if LWIP_SO_RCVTIMEO +/** Set the receive timeout in milliseconds */ +#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) +/** Get the receive timeout in milliseconds */ +#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) +#endif /* LWIP_SO_RCVTIMEO */ +#if LWIP_SO_RCVBUF +/** Set the receive buffer in bytes */ +#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) +/** Get the receive buffer in bytes */ +#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) +#endif /* LWIP_SO_RCVBUF*/ + +#if LWIP_NETCONN_SEM_PER_THREAD +void netconn_thread_init(void); +void netconn_thread_cleanup(void); +#else /* LWIP_NETCONN_SEM_PER_THREAD */ +#define netconn_thread_init() +#define netconn_thread_cleanup() +#endif /* LWIP_NETCONN_SEM_PER_THREAD */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETCONN || LWIP_SOCKET */ + +#endif /* LWIP_HDR_API_H */ diff --git a/sys/include/net/apps/FILES b/sys/include/net/apps/FILES index adfc0f3..c983076 100644 --- a/sys/include/net/apps/FILES +++ b/sys/include/net/apps/FILES @@ -1,2 +1,2 @@ -This directory contains application headers. -Every application shall provide one api file APP.h and optionally one options file APP_opts.h +This directory contains application headers. +Every application shall provide one api file APP.h and optionally one options file APP_opts.h diff --git a/sys/include/net/apps/fs.h b/sys/include/net/apps/fs.h new file mode 100644 index 0000000..0283a0b --- /dev/null +++ b/sys/include/net/apps/fs.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_APPS_FS_H +#define LWIP_HDR_APPS_FS_H + +#include "httpd_opts.h" +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define FS_READ_EOF -1 +#define FS_READ_DELAYED -2 + +#if HTTPD_PRECALCULATED_CHECKSUM +struct fsdata_chksum { + u32_t offset; + u16_t chksum; + u16_t len; +}; +#endif /* HTTPD_PRECALCULATED_CHECKSUM */ + +#define FS_FILE_FLAGS_HEADER_INCLUDED 0x01 +#define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02 + +struct fs_file { + const char *data; + int len; + int index; + void *pextension; +#if HTTPD_PRECALCULATED_CHECKSUM + const struct fsdata_chksum *chksum; + u16_t chksum_count; +#endif /* HTTPD_PRECALCULATED_CHECKSUM */ + u8_t flags; +#if LWIP_HTTPD_CUSTOM_FILES + u8_t is_custom_file; +#endif /* LWIP_HTTPD_CUSTOM_FILES */ +#if LWIP_HTTPD_FILE_STATE + void *state; +#endif /* LWIP_HTTPD_FILE_STATE */ +}; + +#if LWIP_HTTPD_FS_ASYNC_READ +typedef void (*fs_wait_cb)(void *arg); +#endif /* LWIP_HTTPD_FS_ASYNC_READ */ + +err_t fs_open(struct fs_file *file, const char *name); +void fs_close(struct fs_file *file); +#if LWIP_HTTPD_DYNAMIC_FILE_READ +#if LWIP_HTTPD_FS_ASYNC_READ +int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg); +#else /* LWIP_HTTPD_FS_ASYNC_READ */ +int fs_read(struct fs_file *file, char *buffer, int count); +#endif /* LWIP_HTTPD_FS_ASYNC_READ */ +#endif /* LWIP_HTTPD_DYNAMIC_FILE_READ */ +#if LWIP_HTTPD_FS_ASYNC_READ +int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg); +#endif /* LWIP_HTTPD_FS_ASYNC_READ */ +int fs_bytes_left(struct fs_file *file); + +#if LWIP_HTTPD_FILE_STATE +/** This user-defined function is called when a file is opened. */ +void *fs_state_init(struct fs_file *file, const char *name); +/** This user-defined function is called when a file is closed. */ +void fs_state_free(struct fs_file *file, void *state); +#endif /* #if LWIP_HTTPD_FILE_STATE */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_FS_H */ diff --git a/sys/include/net/apps/httpd.h b/sys/include/net/apps/httpd.h index 40f1811..57831dd 100644 --- a/sys/include/net/apps/httpd.h +++ b/sys/include/net/apps/httpd.h @@ -1,236 +1,236 @@ -/** - * @file - * HTTP server - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - * This version of the file has been modified by Texas Instruments to offer - * simple server-side-include (SSI) and Common Gateway Interface (CGI) - * capability. - */ - -#ifndef LWIP_HDR_APPS_HTTPD_H -#define LWIP_HDR_APPS_HTTPD_H - -#include "httpd_opts.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_HTTPD_CGI - -/* - * Function pointer for a CGI script handler. - * - * This function is called each time the HTTPD server is asked for a file - * whose name was previously registered as a CGI function using a call to - * http_set_cgi_handler. The iIndex parameter provides the index of the - * CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters - * pcParam and pcValue provide access to the parameters provided along with - * the URI. iNumParams provides a count of the entries in the pcParam and - * pcValue arrays. Each entry in the pcParam array contains the name of a - * parameter with the corresponding entry in the pcValue array containing the - * value for that parameter. Note that pcParam may contain multiple elements - * with the same name if, for example, a multi-selection list control is used - * in the form generating the data. - * - * The function should return a pointer to a character string which is the - * path and filename of the response that is to be sent to the connected - * browser, for example "/thanks.htm" or "/response/error.ssi". - * - * The maximum number of parameters that will be passed to this function via - * iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming - * HTTP request above this number will be discarded. - * - * Requests intended for use by this CGI mechanism must be sent using the GET - * method (which encodes all parameters within the URI rather than in a block - * later in the request). Attempts to use the POST method will result in the - * request being ignored. - * - */ -typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[], - char *pcValue[]); - -/* - * Structure defining the base filename (URL) of a CGI and the associated - * function which is to be called when that URL is requested. - */ -typedef struct -{ - const char *pcCGIName; - tCGIHandler pfnCGIHandler; -} tCGI; - -void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers); - -#endif /* LWIP_HTTPD_CGI */ - -#if LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI - -#if LWIP_HTTPD_CGI_SSI -/** Define this generic CGI handler in your application. - * It is called once for every URI with parameters. - * The parameters can be stored to - */ -extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue -#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE - , void *connection_state -#endif /* LWIP_HTTPD_FILE_STATE */ - ); -#endif /* LWIP_HTTPD_CGI_SSI */ - -#endif /* LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI */ - -#if LWIP_HTTPD_SSI - -/* - * Function pointer for the SSI tag handler callback. - * - * This function will be called each time the HTTPD server detects a tag of the - * form in a .shtml, .ssi or .shtm file where "name" appears as - * one of the tags supplied to http_set_ssi_handler in the ppcTags array. The - * returned insert string, which will be appended after the the string - * "" in file sent back to the client,should be written to pointer - * pcInsert. iInsertLen contains the size of the buffer pointed to by - * pcInsert. The iIndex parameter provides the zero-based index of the tag as - * found in the ppcTags array and identifies the tag that is to be processed. - * - * The handler returns the number of characters written to pcInsert excluding - * any terminating NULL or a negative number to indicate a failure (tag not - * recognized, for example). - * - * Note that the behavior of this SSI mechanism is somewhat different from the - * "normal" SSI processing as found in, for example, the Apache web server. In - * this case, the inserted text is appended following the SSI tag rather than - * replacing the tag entirely. This allows for an implementation that does not - * require significant additional buffering of output data yet which will still - * offer usable SSI functionality. One downside to this approach is when - * attempting to use SSI within JavaScript. The SSI tag is structured to - * resemble an HTML comment but this syntax does not constitute a comment - * within JavaScript and, hence, leaving the tag in place will result in - * problems in these cases. To work around this, any SSI tag which needs to - * output JavaScript code must do so in an encapsulated way, sending the whole - * HTML section as a single include. - */ -typedef u16_t (*tSSIHandler)( -#if LWIP_HTTPD_SSI_RAW - const char* ssi_tag_name, -#else /* LWIP_HTTPD_SSI_RAW */ - int iIndex, -#endif /* LWIP_HTTPD_SSI_RAW */ - char *pcInsert, int iInsertLen -#if LWIP_HTTPD_SSI_MULTIPART - , u16_t current_tag_part, u16_t *next_tag_part -#endif /* LWIP_HTTPD_SSI_MULTIPART */ -#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE - , void *connection_state -#endif /* LWIP_HTTPD_FILE_STATE */ - ); - -/** Set the SSI handler function - * (if LWIP_HTTPD_SSI_RAW==1, only the first argument is used) - */ -void http_set_ssi_handler(tSSIHandler pfnSSIHandler, - const char **ppcTags, int iNumTags); - -/** For LWIP_HTTPD_SSI_RAW==1, return this to indicate the tag is unknown. - * In this case, the webserver writes a warning into the page. - * You can also just return 0 to write nothing for unknown tags. - */ -#define HTTPD_SSI_TAG_UNKNOWN 0xFFFF - -#endif /* LWIP_HTTPD_SSI */ - -#if LWIP_HTTPD_SUPPORT_POST - -/* These functions must be implemented by the application */ - -/** Called when a POST request has been received. The application can decide - * whether to accept it or not. - * - * @param connection Unique connection identifier, valid until httpd_post_end - * is called. - * @param uri The HTTP header URI receiving the POST request. - * @param http_request The raw HTTP request (the first packet, normally). - * @param http_request_len Size of 'http_request'. - * @param content_len Content-Length from HTTP header. - * @param response_uri Filename of response file, to be filled when denying the - * request - * @param response_uri_len Size of the 'response_uri' buffer. - * @param post_auto_wnd Set this to 0 to let the callback code handle window - * updates by calling 'httpd_post_data_recved' (to throttle rx speed) - * default is 1 (httpd handles window updates automatically) - * @return ERR_OK: Accept the POST request, data may be passed in - * another err_t: Deny the POST request, send back 'bad request'. - */ -err_t httpd_post_begin(void *connection, const char *uri, const char *http_request, - u16_t http_request_len, int content_len, char *response_uri, - u16_t response_uri_len, u8_t *post_auto_wnd); - -/** Called for each pbuf of data that has been received for a POST. - * ATTENTION: The application is responsible for freeing the pbufs passed in! - * - * @param connection Unique connection identifier. - * @param p Received data. - * @return ERR_OK: Data accepted. - * another err_t: Data denied, http_post_get_response_uri will be called. - */ -err_t httpd_post_receive_data(void *connection, struct pbuf *p); - -/** Called when all data is received or when the connection is closed. - * The application must return the filename/URI of a file to send in response - * to this POST request. If the response_uri buffer is untouched, a 404 - * response is returned. - * - * @param connection Unique connection identifier. - * @param response_uri Filename of response file, to be filled when denying the request - * @param response_uri_len Size of the 'response_uri' buffer. - */ -void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len); - -#if LWIP_HTTPD_POST_MANUAL_WND -void httpd_post_data_recved(void *connection, u16_t recved_len); -#endif /* LWIP_HTTPD_POST_MANUAL_WND */ - -#endif /* LWIP_HTTPD_SUPPORT_POST */ - -void httpd_init(void); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HTTPD_H */ +/** + * @file + * HTTP server + */ + +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * This version of the file has been modified by Texas Instruments to offer + * simple server-side-include (SSI) and Common Gateway Interface (CGI) + * capability. + */ + +#ifndef LWIP_HDR_APPS_HTTPD_H +#define LWIP_HDR_APPS_HTTPD_H + +#include "httpd_opts.h" +#include "lwip/err.h" +#include "lwip/pbuf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_HTTPD_CGI + +/* + * Function pointer for a CGI script handler. + * + * This function is called each time the HTTPD server is asked for a file + * whose name was previously registered as a CGI function using a call to + * http_set_cgi_handler. The iIndex parameter provides the index of the + * CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters + * pcParam and pcValue provide access to the parameters provided along with + * the URI. iNumParams provides a count of the entries in the pcParam and + * pcValue arrays. Each entry in the pcParam array contains the name of a + * parameter with the corresponding entry in the pcValue array containing the + * value for that parameter. Note that pcParam may contain multiple elements + * with the same name if, for example, a multi-selection list control is used + * in the form generating the data. + * + * The function should return a pointer to a character string which is the + * path and filename of the response that is to be sent to the connected + * browser, for example "/thanks.htm" or "/response/error.ssi". + * + * The maximum number of parameters that will be passed to this function via + * iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming + * HTTP request above this number will be discarded. + * + * Requests intended for use by this CGI mechanism must be sent using the GET + * method (which encodes all parameters within the URI rather than in a block + * later in the request). Attempts to use the POST method will result in the + * request being ignored. + * + */ +typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[], + char *pcValue[]); + +/* + * Structure defining the base filename (URL) of a CGI and the associated + * function which is to be called when that URL is requested. + */ +typedef struct +{ + const char *pcCGIName; + tCGIHandler pfnCGIHandler; +} tCGI; + +void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers); + +#endif /* LWIP_HTTPD_CGI */ + +#if LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI + +#if LWIP_HTTPD_CGI_SSI +/** Define this generic CGI handler in your application. + * It is called once for every URI with parameters. + * The parameters can be stored to + */ +extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue +#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE + , void *connection_state +#endif /* LWIP_HTTPD_FILE_STATE */ + ); +#endif /* LWIP_HTTPD_CGI_SSI */ + +#endif /* LWIP_HTTPD_CGI || LWIP_HTTPD_CGI_SSI */ + +#if LWIP_HTTPD_SSI + +/* + * Function pointer for the SSI tag handler callback. + * + * This function will be called each time the HTTPD server detects a tag of the + * form in a .shtml, .ssi or .shtm file where "name" appears as + * one of the tags supplied to http_set_ssi_handler in the ppcTags array. The + * returned insert string, which will be appended after the the string + * "" in file sent back to the client,should be written to pointer + * pcInsert. iInsertLen contains the size of the buffer pointed to by + * pcInsert. The iIndex parameter provides the zero-based index of the tag as + * found in the ppcTags array and identifies the tag that is to be processed. + * + * The handler returns the number of characters written to pcInsert excluding + * any terminating NULL or a negative number to indicate a failure (tag not + * recognized, for example). + * + * Note that the behavior of this SSI mechanism is somewhat different from the + * "normal" SSI processing as found in, for example, the Apache web server. In + * this case, the inserted text is appended following the SSI tag rather than + * replacing the tag entirely. This allows for an implementation that does not + * require significant additional buffering of output data yet which will still + * offer usable SSI functionality. One downside to this approach is when + * attempting to use SSI within JavaScript. The SSI tag is structured to + * resemble an HTML comment but this syntax does not constitute a comment + * within JavaScript and, hence, leaving the tag in place will result in + * problems in these cases. To work around this, any SSI tag which needs to + * output JavaScript code must do so in an encapsulated way, sending the whole + * HTML section as a single include. + */ +typedef u16_t (*tSSIHandler)( +#if LWIP_HTTPD_SSI_RAW + const char* ssi_tag_name, +#else /* LWIP_HTTPD_SSI_RAW */ + int iIndex, +#endif /* LWIP_HTTPD_SSI_RAW */ + char *pcInsert, int iInsertLen +#if LWIP_HTTPD_SSI_MULTIPART + , u16_t current_tag_part, u16_t *next_tag_part +#endif /* LWIP_HTTPD_SSI_MULTIPART */ +#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE + , void *connection_state +#endif /* LWIP_HTTPD_FILE_STATE */ + ); + +/** Set the SSI handler function + * (if LWIP_HTTPD_SSI_RAW==1, only the first argument is used) + */ +void http_set_ssi_handler(tSSIHandler pfnSSIHandler, + const char **ppcTags, int iNumTags); + +/** For LWIP_HTTPD_SSI_RAW==1, return this to indicate the tag is unknown. + * In this case, the webserver writes a warning into the page. + * You can also just return 0 to write nothing for unknown tags. + */ +#define HTTPD_SSI_TAG_UNKNOWN 0xFFFF + +#endif /* LWIP_HTTPD_SSI */ + +#if LWIP_HTTPD_SUPPORT_POST + +/* These functions must be implemented by the application */ + +/** Called when a POST request has been received. The application can decide + * whether to accept it or not. + * + * @param connection Unique connection identifier, valid until httpd_post_end + * is called. + * @param uri The HTTP header URI receiving the POST request. + * @param http_request The raw HTTP request (the first packet, normally). + * @param http_request_len Size of 'http_request'. + * @param content_len Content-Length from HTTP header. + * @param response_uri Filename of response file, to be filled when denying the + * request + * @param response_uri_len Size of the 'response_uri' buffer. + * @param post_auto_wnd Set this to 0 to let the callback code handle window + * updates by calling 'httpd_post_data_recved' (to throttle rx speed) + * default is 1 (httpd handles window updates automatically) + * @return ERR_OK: Accept the POST request, data may be passed in + * another err_t: Deny the POST request, send back 'bad request'. + */ +err_t httpd_post_begin(void *connection, const char *uri, const char *http_request, + u16_t http_request_len, int content_len, char *response_uri, + u16_t response_uri_len, u8_t *post_auto_wnd); + +/** Called for each pbuf of data that has been received for a POST. + * ATTENTION: The application is responsible for freeing the pbufs passed in! + * + * @param connection Unique connection identifier. + * @param p Received data. + * @return ERR_OK: Data accepted. + * another err_t: Data denied, http_post_get_response_uri will be called. + */ +err_t httpd_post_receive_data(void *connection, struct pbuf *p); + +/** Called when all data is received or when the connection is closed. + * The application must return the filename/URI of a file to send in response + * to this POST request. If the response_uri buffer is untouched, a 404 + * response is returned. + * + * @param connection Unique connection identifier. + * @param response_uri Filename of response file, to be filled when denying the request + * @param response_uri_len Size of the 'response_uri' buffer. + */ +void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len); + +#if LWIP_HTTPD_POST_MANUAL_WND +void httpd_post_data_recved(void *connection, u16_t recved_len); +#endif /* LWIP_HTTPD_POST_MANUAL_WND */ + +#endif /* LWIP_HTTPD_SUPPORT_POST */ + +void httpd_init(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HTTPD_H */ diff --git a/sys/include/net/apps/httpd_opts.h b/sys/include/net/apps/httpd_opts.h index 340db15..2669745 100644 --- a/sys/include/net/apps/httpd_opts.h +++ b/sys/include/net/apps/httpd_opts.h @@ -1,323 +1,323 @@ -/** - * @file - * HTTP server options list - */ - -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - * This version of the file has been modified by Texas Instruments to offer - * simple server-side-include (SSI) and Common Gateway Interface (CGI) - * capability. - */ - -#ifndef LWIP_HDR_APPS_HTTPD_OPTS_H -#define LWIP_HDR_APPS_HTTPD_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup httpd_opts Options - * @ingroup httpd - * @{ - */ - -/** Set this to 1 to support CGI (old style) */ -#if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__ -#define LWIP_HTTPD_CGI 0 -#endif - -/** Set this to 1 to support CGI (new style) */ -#if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__ -#define LWIP_HTTPD_CGI_SSI 0 -#endif - -/** Set this to 1 to support SSI (Server-Side-Includes) */ -#if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI 0 -#endif - -/** Set this to 1 to implement an SSI tag handler callback that gets a const char* - * to the tag (instead of an index into a pre-registered array of known tags) */ -#if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI_RAW 0 -#endif - -/** Set this to 1 to support HTTP POST */ -#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_POST 0 -#endif - -/* The maximum number of parameters that the CGI handler can be sent. */ -#if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16 -#endif - -/** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more - * arguments indicating a counter for insert string that are too long to be - * inserted at once: the SSI handler function must then set 'next_tag_part' - * which will be passed back to it in the next call. */ -#if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI_MULTIPART 0 -#endif - -/* The maximum length of the string comprising the tag name */ -#if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8 -#endif - -/* The maximum length of string that can be returned to replace any given tag */ -#if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192 -#endif - -#if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__ -#define LWIP_HTTPD_POST_MANUAL_WND 0 -#endif - -/** This string is passed in the HTTP header as "Server: " */ -#if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__ -#define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)" -#endif - -/** Set this to 1 if you want to include code that creates HTTP headers - * at runtime. Default is off: HTTP headers are then created statically - * by the makefsdata tool. Static headers mean smaller code size, but - * the (readonly) fsdata will grow a bit as every file includes the HTTP - * header. */ -#if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__ -#define LWIP_HTTPD_DYNAMIC_HEADERS 0 -#endif - -#if !defined HTTPD_DEBUG || defined __DOXYGEN__ -#define HTTPD_DEBUG LWIP_DBG_OFF -#endif - -/** Set this to 1 to use a memp pool for allocating - * struct http_state instead of the heap. - */ -#if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ -#define HTTPD_USE_MEM_POOL 0 -#endif - -/** The server port for HTTPD to use */ -#if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__ -#define HTTPD_SERVER_PORT 80 -#endif - -/** Maximum retries before the connection is aborted/closed. - * - number of times pcb->poll is called -> default is 4*500ms = 2s; - * - reset when pcb->sent is called - */ -#if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__ -#define HTTPD_MAX_RETRIES 4 -#endif - -/** The poll delay is X*500ms */ -#if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__ -#define HTTPD_POLL_INTERVAL 4 -#endif - -/** Priority for tcp pcbs created by HTTPD (very low by default). - * Lower priorities get killed first when running out of memory. - */ -#if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__ -#define HTTPD_TCP_PRIO TCP_PRIO_MIN -#endif - -/** Set this to 1 to enable timing each file sent */ -#if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__ -#define LWIP_HTTPD_TIMING 0 -#endif -/** Set this to 1 to enable timing each file sent */ -#if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__ -#define HTTPD_DEBUG_TIMING LWIP_DBG_OFF -#endif - -/** Set this to one to show error pages when parsing a request fails instead - of simply closing the connection. */ -#if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_EXTSTATUS 0 -#endif - -/** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */ -#if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_V09 1 -#endif - -/** Set this to 1 to enable HTTP/1.1 persistent connections. - * ATTENTION: If the generated file system includes HTTP headers, these must - * include the "Connection: keep-alive" header (pass argument "-11" to makefsdata). - */ -#if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0 -#endif - -/** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */ -#if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__ -#define LWIP_HTTPD_SUPPORT_REQUESTLIST 1 -#endif - -#if LWIP_HTTPD_SUPPORT_REQUESTLIST -/** Number of rx pbufs to enqueue to parse an incoming request (up to the first - newline) */ -#if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__ -#define LWIP_HTTPD_REQ_QUEUELEN 5 -#endif - -/** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming - request (up to the first double-newline) */ -#if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__ -#define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH -#endif - -/** Defines the maximum length of a HTTP request line (up to the first CRLF, - copied from pbuf into this a global buffer when pbuf- or packet-queues - are received - otherwise the input pbuf is used directly) */ -#if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE)) -#endif -#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ - -/** This is the size of a static buffer used when URIs end with '/'. - * In this buffer, the directory requested is concatenated with all the - * configured default file names. - * Set to 0 to disable checking default filenames on non-root directories. - */ -#if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63 -#endif - -/** Maximum length of the filename to send as response to a POST request, - * filled in by the application when a POST is finished. - */ -#if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__ -#define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63 -#endif - -/** Set this to 0 to not send the SSI tag (default is on, so the tag will - * be sent in the HTML page */ -#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__ -#define LWIP_HTTPD_SSI_INCLUDE_TAG 1 -#endif - -/** Set this to 1 to call tcp_abort when tcp_close fails with memory error. - * This can be used to prevent consuming all memory in situations where the - * HTTP server has low priority compared to other communication. */ -#if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__ -#define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0 -#endif - -/** Set this to 1 to kill the oldest connection when running out of - * memory for 'struct http_state' or 'struct http_ssi_state'. - * ATTENTION: This puts all connections on a linked list, so may be kind of slow. - */ -#if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__ -#define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0 -#endif - -/** Set this to 1 to send URIs without extension without headers - * (who uses this at all??) */ -#if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__ -#define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0 -#endif - -/** Default: Tags are sent from struct http_state and are therefore volatile */ -#if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__ -#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY -#endif - -/* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low - when http is not an important protocol in the device. */ -#if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__ -#define HTTPD_LIMIT_SENDING_TO_2MSS 1 -#endif - -/* Define this to a function that returns the maximum amount of data to enqueue. - The function have this signature: u16_t fn(struct tcp_pcb* pcb); */ -#if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__ -#if HTTPD_LIMIT_SENDING_TO_2MSS -#define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb)) -#endif -#endif - -/*------------------- FS OPTIONS -------------------*/ - -/** Set this to 1 and provide the functions: - * - "int fs_open_custom(struct fs_file *file, const char *name)" - * Called first for every opened file to allow opening files - * that are not included in fsdata(_custom).c - * - "void fs_close_custom(struct fs_file *file)" - * Called to free resources allocated by fs_open_custom(). - */ -#if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__ -#define LWIP_HTTPD_CUSTOM_FILES 0 -#endif - -/** Set this to 1 to support fs_read() to dynamically read file data. - * Without this (default=off), only one-block files are supported, - * and the contents must be ready after fs_open(). - */ -#if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__ -#define LWIP_HTTPD_DYNAMIC_FILE_READ 0 -#endif - -/** Set this to 1 to include an application state argument per file - * that is opened. This allows to keep a state per connection/file. - */ -#if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__ -#define LWIP_HTTPD_FILE_STATE 0 -#endif - -/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for - * predefined (MSS-sized) chunks of the files to prevent having to calculate - * the checksums at runtime. */ -#if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__ -#define HTTPD_PRECALCULATED_CHECKSUM 0 -#endif - -/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations - * (fs_read_async returns FS_READ_DELAYED and calls a callback when finished). - */ -#if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__ -#define LWIP_HTTPD_FS_ASYNC_READ 0 -#endif - -/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the - * file system (to prevent changing the file included in CVS) */ -#if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__ -#define HTTPD_USE_CUSTOM_FSDATA 0 -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */ +/** + * @file + * HTTP server options list + */ + +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + * This version of the file has been modified by Texas Instruments to offer + * simple server-side-include (SSI) and Common Gateway Interface (CGI) + * capability. + */ + +#ifndef LWIP_HDR_APPS_HTTPD_OPTS_H +#define LWIP_HDR_APPS_HTTPD_OPTS_H + +#include "lwip/opt.h" + +/** + * @defgroup httpd_opts Options + * @ingroup httpd + * @{ + */ + +/** Set this to 1 to support CGI (old style) */ +#if !defined LWIP_HTTPD_CGI || defined __DOXYGEN__ +#define LWIP_HTTPD_CGI 0 +#endif + +/** Set this to 1 to support CGI (new style) */ +#if !defined LWIP_HTTPD_CGI_SSI || defined __DOXYGEN__ +#define LWIP_HTTPD_CGI_SSI 0 +#endif + +/** Set this to 1 to support SSI (Server-Side-Includes) */ +#if !defined LWIP_HTTPD_SSI || defined __DOXYGEN__ +#define LWIP_HTTPD_SSI 0 +#endif + +/** Set this to 1 to implement an SSI tag handler callback that gets a const char* + * to the tag (instead of an index into a pre-registered array of known tags) */ +#if !defined LWIP_HTTPD_SSI_RAW || defined __DOXYGEN__ +#define LWIP_HTTPD_SSI_RAW 0 +#endif + +/** Set this to 1 to support HTTP POST */ +#if !defined LWIP_HTTPD_SUPPORT_POST || defined __DOXYGEN__ +#define LWIP_HTTPD_SUPPORT_POST 0 +#endif + +/* The maximum number of parameters that the CGI handler can be sent. */ +#if !defined LWIP_HTTPD_MAX_CGI_PARAMETERS || defined __DOXYGEN__ +#define LWIP_HTTPD_MAX_CGI_PARAMETERS 16 +#endif + +/** LWIP_HTTPD_SSI_MULTIPART==1: SSI handler function is called with 2 more + * arguments indicating a counter for insert string that are too long to be + * inserted at once: the SSI handler function must then set 'next_tag_part' + * which will be passed back to it in the next call. */ +#if !defined LWIP_HTTPD_SSI_MULTIPART || defined __DOXYGEN__ +#define LWIP_HTTPD_SSI_MULTIPART 0 +#endif + +/* The maximum length of the string comprising the tag name */ +#if !defined LWIP_HTTPD_MAX_TAG_NAME_LEN || defined __DOXYGEN__ +#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8 +#endif + +/* The maximum length of string that can be returned to replace any given tag */ +#if !defined LWIP_HTTPD_MAX_TAG_INSERT_LEN || defined __DOXYGEN__ +#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192 +#endif + +#if !defined LWIP_HTTPD_POST_MANUAL_WND || defined __DOXYGEN__ +#define LWIP_HTTPD_POST_MANUAL_WND 0 +#endif + +/** This string is passed in the HTTP header as "Server: " */ +#if !defined HTTPD_SERVER_AGENT || defined __DOXYGEN__ +#define HTTPD_SERVER_AGENT "lwIP/" LWIP_VERSION_STRING " (http://savannah.nongnu.org/projects/lwip)" +#endif + +/** Set this to 1 if you want to include code that creates HTTP headers + * at runtime. Default is off: HTTP headers are then created statically + * by the makefsdata tool. Static headers mean smaller code size, but + * the (readonly) fsdata will grow a bit as every file includes the HTTP + * header. */ +#if !defined LWIP_HTTPD_DYNAMIC_HEADERS || defined __DOXYGEN__ +#define LWIP_HTTPD_DYNAMIC_HEADERS 0 +#endif + +#if !defined HTTPD_DEBUG || defined __DOXYGEN__ +#define HTTPD_DEBUG LWIP_DBG_OFF +#endif + +/** Set this to 1 to use a memp pool for allocating + * struct http_state instead of the heap. + */ +#if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ +#define HTTPD_USE_MEM_POOL 0 +#endif + +/** The server port for HTTPD to use */ +#if !defined HTTPD_SERVER_PORT || defined __DOXYGEN__ +#define HTTPD_SERVER_PORT 80 +#endif + +/** Maximum retries before the connection is aborted/closed. + * - number of times pcb->poll is called -> default is 4*500ms = 2s; + * - reset when pcb->sent is called + */ +#if !defined HTTPD_MAX_RETRIES || defined __DOXYGEN__ +#define HTTPD_MAX_RETRIES 4 +#endif + +/** The poll delay is X*500ms */ +#if !defined HTTPD_POLL_INTERVAL || defined __DOXYGEN__ +#define HTTPD_POLL_INTERVAL 4 +#endif + +/** Priority for tcp pcbs created by HTTPD (very low by default). + * Lower priorities get killed first when running out of memory. + */ +#if !defined HTTPD_TCP_PRIO || defined __DOXYGEN__ +#define HTTPD_TCP_PRIO TCP_PRIO_MIN +#endif + +/** Set this to 1 to enable timing each file sent */ +#if !defined LWIP_HTTPD_TIMING || defined __DOXYGEN__ +#define LWIP_HTTPD_TIMING 0 +#endif +/** Set this to 1 to enable timing each file sent */ +#if !defined HTTPD_DEBUG_TIMING || defined __DOXYGEN__ +#define HTTPD_DEBUG_TIMING LWIP_DBG_OFF +#endif + +/** Set this to one to show error pages when parsing a request fails instead + of simply closing the connection. */ +#if !defined LWIP_HTTPD_SUPPORT_EXTSTATUS || defined __DOXYGEN__ +#define LWIP_HTTPD_SUPPORT_EXTSTATUS 0 +#endif + +/** Set this to 0 to drop support for HTTP/0.9 clients (to save some bytes) */ +#if !defined LWIP_HTTPD_SUPPORT_V09 || defined __DOXYGEN__ +#define LWIP_HTTPD_SUPPORT_V09 1 +#endif + +/** Set this to 1 to enable HTTP/1.1 persistent connections. + * ATTENTION: If the generated file system includes HTTP headers, these must + * include the "Connection: keep-alive" header (pass argument "-11" to makefsdata). + */ +#if !defined LWIP_HTTPD_SUPPORT_11_KEEPALIVE || defined __DOXYGEN__ +#define LWIP_HTTPD_SUPPORT_11_KEEPALIVE 0 +#endif + +/** Set this to 1 to support HTTP request coming in in multiple packets/pbufs */ +#if !defined LWIP_HTTPD_SUPPORT_REQUESTLIST || defined __DOXYGEN__ +#define LWIP_HTTPD_SUPPORT_REQUESTLIST 1 +#endif + +#if LWIP_HTTPD_SUPPORT_REQUESTLIST +/** Number of rx pbufs to enqueue to parse an incoming request (up to the first + newline) */ +#if !defined LWIP_HTTPD_REQ_QUEUELEN || defined __DOXYGEN__ +#define LWIP_HTTPD_REQ_QUEUELEN 5 +#endif + +/** Number of (TCP payload-) bytes (in pbufs) to enqueue to parse and incoming + request (up to the first double-newline) */ +#if !defined LWIP_HTTPD_REQ_BUFSIZE || defined __DOXYGEN__ +#define LWIP_HTTPD_REQ_BUFSIZE LWIP_HTTPD_MAX_REQ_LENGTH +#endif + +/** Defines the maximum length of a HTTP request line (up to the first CRLF, + copied from pbuf into this a global buffer when pbuf- or packet-queues + are received - otherwise the input pbuf is used directly) */ +#if !defined LWIP_HTTPD_MAX_REQ_LENGTH || defined __DOXYGEN__ +#define LWIP_HTTPD_MAX_REQ_LENGTH LWIP_MIN(1023, (LWIP_HTTPD_REQ_QUEUELEN * PBUF_POOL_BUFSIZE)) +#endif +#endif /* LWIP_HTTPD_SUPPORT_REQUESTLIST */ + +/** This is the size of a static buffer used when URIs end with '/'. + * In this buffer, the directory requested is concatenated with all the + * configured default file names. + * Set to 0 to disable checking default filenames on non-root directories. + */ +#if !defined LWIP_HTTPD_MAX_REQUEST_URI_LEN || defined __DOXYGEN__ +#define LWIP_HTTPD_MAX_REQUEST_URI_LEN 63 +#endif + +/** Maximum length of the filename to send as response to a POST request, + * filled in by the application when a POST is finished. + */ +#if !defined LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN || defined __DOXYGEN__ +#define LWIP_HTTPD_POST_MAX_RESPONSE_URI_LEN 63 +#endif + +/** Set this to 0 to not send the SSI tag (default is on, so the tag will + * be sent in the HTML page */ +#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG || defined __DOXYGEN__ +#define LWIP_HTTPD_SSI_INCLUDE_TAG 1 +#endif + +/** Set this to 1 to call tcp_abort when tcp_close fails with memory error. + * This can be used to prevent consuming all memory in situations where the + * HTTP server has low priority compared to other communication. */ +#if !defined LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR || defined __DOXYGEN__ +#define LWIP_HTTPD_ABORT_ON_CLOSE_MEM_ERROR 0 +#endif + +/** Set this to 1 to kill the oldest connection when running out of + * memory for 'struct http_state' or 'struct http_ssi_state'. + * ATTENTION: This puts all connections on a linked list, so may be kind of slow. + */ +#if !defined LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED || defined __DOXYGEN__ +#define LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED 0 +#endif + +/** Set this to 1 to send URIs without extension without headers + * (who uses this at all??) */ +#if !defined LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI || defined __DOXYGEN__ +#define LWIP_HTTPD_OMIT_HEADER_FOR_EXTENSIONLESS_URI 0 +#endif + +/** Default: Tags are sent from struct http_state and are therefore volatile */ +#if !defined HTTP_IS_TAG_VOLATILE || defined __DOXYGEN__ +#define HTTP_IS_TAG_VOLATILE(ptr) TCP_WRITE_FLAG_COPY +#endif + +/* By default, the httpd is limited to send 2*pcb->mss to keep resource usage low + when http is not an important protocol in the device. */ +#if !defined HTTPD_LIMIT_SENDING_TO_2MSS || defined __DOXYGEN__ +#define HTTPD_LIMIT_SENDING_TO_2MSS 1 +#endif + +/* Define this to a function that returns the maximum amount of data to enqueue. + The function have this signature: u16_t fn(struct tcp_pcb* pcb); */ +#if !defined HTTPD_MAX_WRITE_LEN || defined __DOXYGEN__ +#if HTTPD_LIMIT_SENDING_TO_2MSS +#define HTTPD_MAX_WRITE_LEN(pcb) (2 * tcp_mss(pcb)) +#endif +#endif + +/*------------------- FS OPTIONS -------------------*/ + +/** Set this to 1 and provide the functions: + * - "int fs_open_custom(struct fs_file *file, const char *name)" + * Called first for every opened file to allow opening files + * that are not included in fsdata(_custom).c + * - "void fs_close_custom(struct fs_file *file)" + * Called to free resources allocated by fs_open_custom(). + */ +#if !defined LWIP_HTTPD_CUSTOM_FILES || defined __DOXYGEN__ +#define LWIP_HTTPD_CUSTOM_FILES 0 +#endif + +/** Set this to 1 to support fs_read() to dynamically read file data. + * Without this (default=off), only one-block files are supported, + * and the contents must be ready after fs_open(). + */ +#if !defined LWIP_HTTPD_DYNAMIC_FILE_READ || defined __DOXYGEN__ +#define LWIP_HTTPD_DYNAMIC_FILE_READ 0 +#endif + +/** Set this to 1 to include an application state argument per file + * that is opened. This allows to keep a state per connection/file. + */ +#if !defined LWIP_HTTPD_FILE_STATE || defined __DOXYGEN__ +#define LWIP_HTTPD_FILE_STATE 0 +#endif + +/** HTTPD_PRECALCULATED_CHECKSUM==1: include precompiled checksums for + * predefined (MSS-sized) chunks of the files to prevent having to calculate + * the checksums at runtime. */ +#if !defined HTTPD_PRECALCULATED_CHECKSUM || defined __DOXYGEN__ +#define HTTPD_PRECALCULATED_CHECKSUM 0 +#endif + +/** LWIP_HTTPD_FS_ASYNC_READ==1: support asynchronous read operations + * (fs_read_async returns FS_READ_DELAYED and calls a callback when finished). + */ +#if !defined LWIP_HTTPD_FS_ASYNC_READ || defined __DOXYGEN__ +#define LWIP_HTTPD_FS_ASYNC_READ 0 +#endif + +/** Set this to 1 to include "fsdata_custom.c" instead of "fsdata.c" for the + * file system (to prevent changing the file included in CVS) */ +#if !defined HTTPD_USE_CUSTOM_FSDATA || defined __DOXYGEN__ +#define HTTPD_USE_CUSTOM_FSDATA 0 +#endif + +/** + * @} + */ + +#endif /* LWIP_HDR_APPS_HTTPD_OPTS_H */ diff --git a/sys/include/net/apps/lwiperf.h b/sys/include/net/apps/lwiperf.h index 7dbebb0..63a0c0c 100644 --- a/sys/include/net/apps/lwiperf.h +++ b/sys/include/net/apps/lwiperf.h @@ -1,84 +1,84 @@ -/** - * @file - * lwIP iPerf server implementation - */ - -/* - * Copyright (c) 2014 Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_APPS_LWIPERF_H -#define LWIP_HDR_APPS_LWIPERF_H - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define LWIPERF_TCP_PORT_DEFAULT 5001 - -/** lwIPerf test results */ -enum lwiperf_report_type -{ - /** The server side test is done */ - LWIPERF_TCP_DONE_SERVER, - /** The client side test is done */ - LWIPERF_TCP_DONE_CLIENT, - /** Local error lead to test abort */ - LWIPERF_TCP_ABORTED_LOCAL, - /** Data check error lead to test abort */ - LWIPERF_TCP_ABORTED_LOCAL_DATAERROR, - /** Transmit error lead to test abort */ - LWIPERF_TCP_ABORTED_LOCAL_TXERROR, - /** Remote side aborted the test */ - LWIPERF_TCP_ABORTED_REMOTE -}; - -/** Prototype of a report function that is called when a session is finished. - This report function can show the test results. - @param report_type contains the test result */ -typedef void (*lwiperf_report_fn)(void *arg, enum lwiperf_report_type report_type, - const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port, - u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec); - - -void* lwiperf_start_tcp_server(const ip_addr_t* local_addr, u16_t local_port, - lwiperf_report_fn report_fn, void* report_arg); -void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg); -void lwiperf_abort(void* lwiperf_session); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_LWIPERF_H */ +/** + * @file + * lwIP iPerf server implementation + */ + +/* + * Copyright (c) 2014 Simon Goldschmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ +#ifndef LWIP_HDR_APPS_LWIPERF_H +#define LWIP_HDR_APPS_LWIPERF_H + +#include "lwip/opt.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define LWIPERF_TCP_PORT_DEFAULT 5001 + +/** lwIPerf test results */ +enum lwiperf_report_type +{ + /** The server side test is done */ + LWIPERF_TCP_DONE_SERVER, + /** The client side test is done */ + LWIPERF_TCP_DONE_CLIENT, + /** Local error lead to test abort */ + LWIPERF_TCP_ABORTED_LOCAL, + /** Data check error lead to test abort */ + LWIPERF_TCP_ABORTED_LOCAL_DATAERROR, + /** Transmit error lead to test abort */ + LWIPERF_TCP_ABORTED_LOCAL_TXERROR, + /** Remote side aborted the test */ + LWIPERF_TCP_ABORTED_REMOTE +}; + +/** Prototype of a report function that is called when a session is finished. + This report function can show the test results. + @param report_type contains the test result */ +typedef void (*lwiperf_report_fn)(void *arg, enum lwiperf_report_type report_type, + const ip_addr_t* local_addr, u16_t local_port, const ip_addr_t* remote_addr, u16_t remote_port, + u32_t bytes_transferred, u32_t ms_duration, u32_t bandwidth_kbitpsec); + + +void* lwiperf_start_tcp_server(const ip_addr_t* local_addr, u16_t local_port, + lwiperf_report_fn report_fn, void* report_arg); +void* lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void* report_arg); +void lwiperf_abort(void* lwiperf_session); + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_LWIPERF_H */ diff --git a/sys/include/net/apps/mdns.h b/sys/include/net/apps/mdns.h new file mode 100644 index 0000000..b19f80c --- /dev/null +++ b/sys/include/net/apps/mdns.h @@ -0,0 +1,69 @@ +/** + * @file + * MDNS responder + */ + + /* + * Copyright (c) 2015 Verisure Innovation AB + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Erik Ekman + * + */ +#ifndef LWIP_HDR_MDNS_H +#define LWIP_HDR_MDNS_H + +#include "lwip/apps/mdns_opts.h" +#include "lwip/netif.h" + +#if LWIP_MDNS_RESPONDER + +enum mdns_sd_proto { + DNSSD_PROTO_UDP = 0, + DNSSD_PROTO_TCP = 1 +}; + +#define MDNS_LABEL_MAXLEN 63 + +struct mdns_host; +struct mdns_service; + +/** Callback function to add text to a reply, called when generating the reply */ +typedef void (*service_get_txt_fn_t)(struct mdns_service *service, void *txt_userdata); + +void mdns_resp_init(void); + +err_t mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl); +err_t mdns_resp_remove_netif(struct netif *netif); + +err_t mdns_resp_add_service(struct netif *netif, const char *name, const char *service, enum mdns_sd_proto proto, u16_t port, u32_t dns_ttl, service_get_txt_fn_t txt_fn, void *txt_userdata); +err_t mdns_resp_add_service_txtitem(struct mdns_service *service, const char *txt, u8_t txt_len); +void mdns_resp_netif_settings_changed(struct netif *netif); + +#endif /* LWIP_MDNS_RESPONDER */ + +#endif /* LWIP_HDR_MDNS_H */ diff --git a/sys/include/net/apps/mdns_opts.h b/sys/include/net/apps/mdns_opts.h index bf186bc..9f8e5f5 100644 --- a/sys/include/net/apps/mdns_opts.h +++ b/sys/include/net/apps/mdns_opts.h @@ -1,74 +1,74 @@ -/** - * @file - * MDNS responder - */ - - /* - * Copyright (c) 2015 Verisure Innovation AB - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Ekman - * - */ - -#ifndef LWIP_HDR_APPS_MDNS_OPTS_H -#define LWIP_HDR_APPS_MDNS_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup mdns_opts Options - * @ingroup mdns - * @{ - */ - -/** - * LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS - * transport. IGMP is needed for IPv4 multicast. - */ -#ifndef LWIP_MDNS_RESPONDER -#define LWIP_MDNS_RESPONDER 0 -#endif /* LWIP_MDNS_RESPONDER */ - -/** The maximum number of services per netif */ -#ifndef MDNS_MAX_SERVICES -#define MDNS_MAX_SERVICES 1 -#endif - -/** - * MDNS_DEBUG: Enable debugging for multicast DNS. - */ -#ifndef MDNS_DEBUG -#define MDNS_DEBUG LWIP_DBG_OFF -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_MDNS_OPTS_H */ - +/** + * @file + * MDNS responder + */ + + /* + * Copyright (c) 2015 Verisure Innovation AB + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Erik Ekman + * + */ + +#ifndef LWIP_HDR_APPS_MDNS_OPTS_H +#define LWIP_HDR_APPS_MDNS_OPTS_H + +#include "lwip/opt.h" + +/** + * @defgroup mdns_opts Options + * @ingroup mdns + * @{ + */ + +/** + * LWIP_MDNS_RESPONDER==1: Turn on multicast DNS module. UDP must be available for MDNS + * transport. IGMP is needed for IPv4 multicast. + */ +#ifndef LWIP_MDNS_RESPONDER +#define LWIP_MDNS_RESPONDER 0 +#endif /* LWIP_MDNS_RESPONDER */ + +/** The maximum number of services per netif */ +#ifndef MDNS_MAX_SERVICES +#define MDNS_MAX_SERVICES 1 +#endif + +/** + * MDNS_DEBUG: Enable debugging for multicast DNS. + */ +#ifndef MDNS_DEBUG +#define MDNS_DEBUG LWIP_DBG_OFF +#endif + +/** + * @} + */ + +#endif /* LWIP_HDR_APPS_MDNS_OPTS_H */ + diff --git a/sys/include/net/apps/mdns_priv.h b/sys/include/net/apps/mdns_priv.h new file mode 100644 index 0000000..9a48b5f --- /dev/null +++ b/sys/include/net/apps/mdns_priv.h @@ -0,0 +1,66 @@ +/** + * @file + * MDNS responder private definitions + */ + + /* + * Copyright (c) 2015 Verisure Innovation AB + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Erik Ekman + * + */ +#ifndef LWIP_HDR_MDNS_PRIV_H +#define LWIP_HDR_MDNS_PRIV_H + +#include "lwip/apps/mdns_opts.h" +#include "lwip/pbuf.h" + +#if LWIP_MDNS_RESPONDER + +/* Domain struct and methods - visible for unit tests */ + +#define MDNS_DOMAIN_MAXLEN 256 +#define MDNS_READNAME_ERROR 0xFFFF + +struct mdns_domain { + /* Encoded domain name */ + u8_t name[MDNS_DOMAIN_MAXLEN]; + /* Total length of domain name, including zero */ + u16_t length; + /* Set if compression of this domain is not allowed */ + u8_t skip_compression; +}; + +err_t mdns_domain_add_label(struct mdns_domain *domain, const char *label, u8_t len); +u16_t mdns_readname(struct pbuf *p, u16_t offset, struct mdns_domain *domain); +int mdns_domain_eq(struct mdns_domain *a, struct mdns_domain *b); +u16_t mdns_compress_domain(struct pbuf *pbuf, u16_t *offset, struct mdns_domain *domain); + +#endif /* LWIP_MDNS_RESPONDER */ + +#endif /* LWIP_HDR_MDNS_PRIV_H */ diff --git a/sys/include/net/apps/mqtt.h b/sys/include/net/apps/mqtt.h index 34b230b..f0f5bab 100644 --- a/sys/include/net/apps/mqtt.h +++ b/sys/include/net/apps/mqtt.h @@ -1,244 +1,244 @@ -/** - * @file - * MQTT client - */ - -/* - * Copyright (c) 2016 Erik Andersson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Andersson - * - */ -#ifndef LWIP_HDR_APPS_MQTT_CLIENT_H -#define LWIP_HDR_APPS_MQTT_CLIENT_H - -#include "lwip/apps/mqtt_opts.h" -#include "lwip/err.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct mqtt_client_t mqtt_client_t; - -/** @ingroup mqtt - * Default MQTT port */ -#define MQTT_PORT 1883 - -/*---------------------------------------------------------------------------------------------- */ -/* Connection with server */ - -/** - * @ingroup mqtt - * Client information and connection parameters */ -struct mqtt_connect_client_info_t { - /** Client identifier, must be set by caller */ - const char *client_id; - /** User name and password, set to NULL if not used */ - const char* client_user; - const char* client_pass; - /** keep alive time in seconds, 0 to disable keep alive functionality*/ - u16_t keep_alive; - /** will topic, set to NULL if will is not to be used, - will_msg, will_qos and will retain are then ignored */ - const char* will_topic; - const char* will_msg; - u8_t will_qos; - u8_t will_retain; -}; - -/** - * @ingroup mqtt - * Connection status codes */ -typedef enum -{ - MQTT_CONNECT_ACCEPTED = 0, - MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1, - MQTT_CONNECT_REFUSED_IDENTIFIER = 2, - MQTT_CONNECT_REFUSED_SERVER = 3, - MQTT_CONNECT_REFUSED_USERNAME_PASS = 4, - MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5, - MQTT_CONNECT_DISCONNECTED = 256, - MQTT_CONNECT_TIMEOUT = 257 -} mqtt_connection_status_t; - -/** - * @ingroup mqtt - * Function prototype for mqtt connection status callback. Called when - * client has connected to the server after initiating a mqtt connection attempt by - * calling mqtt_connect() or when connection is closed by server or an error - * - * @param client MQTT client itself - * @param arg Additional argument to pass to the callback function - * @param status Connect result code or disconnection notification @see mqtt_connection_status_t - * - */ -typedef void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status); - - -/** - * @ingroup mqtt - * Data callback flags */ -enum { - /** Flag set when last fragment of data arrives in data callback */ - MQTT_DATA_FLAG_LAST = 1 -}; - -/** - * @ingroup mqtt - * Function prototype for MQTT incoming publish data callback function. Called when data - * arrives to a subscribed topic @see mqtt_subscribe - * - * @param arg Additional argument to pass to the callback function - * @param data User data, pointed object, data may not be referenced after callback return, - NULL is passed when all publish data are delivered - * @param len Length of publish data fragment - * @param flags MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message - * - */ -typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags); - - -/** - * @ingroup mqtt - * Function prototype for MQTT incoming publish function. Called when an incoming publish - * arrives to a subscribed topic @see mqtt_subscribe - * - * @param arg Additional argument to pass to the callback function - * @param topic Zero terminated Topic text string, topic may not be referenced after callback return - * @param tot_len Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked - */ -typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len); - - -/** - * @ingroup mqtt - * Function prototype for mqtt request callback. Called when a subscribe, unsubscribe - * or publish request has completed - * @param arg Pointer to user data supplied when invoking request - * @param err ERR_OK on success - * ERR_TIMEOUT if no response was received within timeout, - * ERR_ABRT if (un)subscribe was denied - */ -typedef void (*mqtt_request_cb_t)(void *arg, err_t err); - - -/** - * Pending request item, binds application callback to pending server requests - */ -struct mqtt_request_t -{ - /** Next item in list, NULL means this is the last in chain, - next pointing at itself means request is unallocated */ - struct mqtt_request_t *next; - /** Callback to upper layer */ - mqtt_request_cb_t cb; - void *arg; - /** MQTT packet identifier */ - u16_t pkt_id; - /** Expire time relative to element before this */ - u16_t timeout_diff; -}; - -/** Ring buffer */ -struct mqtt_ringbuf_t { - u16_t put; - u16_t get; - u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE]; -}; - -/** MQTT client */ -struct mqtt_client_t -{ - /** Timers and timeouts */ - u16_t cyclic_tick; - u16_t keep_alive; - u16_t server_watchdog; - /** Packet identifier generator*/ - u16_t pkt_id_seq; - /** Packet identifier of pending incoming publish */ - u16_t inpub_pkt_id; - /** Connection state */ - u8_t conn_state; - struct tcp_pcb *conn; - /** Connection callback */ - void *connect_arg; - mqtt_connection_cb_t connect_cb; - /** Pending requests to server */ - struct mqtt_request_t *pend_req_queue; - struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT]; - void *inpub_arg; - /** Incoming data callback */ - mqtt_incoming_data_cb_t data_cb; - mqtt_incoming_publish_cb_t pub_cb; - /** Input */ - u32_t msg_idx; - u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN]; - /** Output ring-buffer */ - struct mqtt_ringbuf_t output; -}; - - -/** Connect to server */ -err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg, - const struct mqtt_connect_client_info_t *client_info); - -/** Disconnect from server */ -void mqtt_disconnect(mqtt_client_t *client); - -/** Create new client */ -mqtt_client_t *mqtt_client_new(void); - -/** Check connection status */ -u8_t mqtt_client_is_connected(mqtt_client_t *client); - -/** Set callback to call for incoming publish */ -void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t, - mqtt_incoming_data_cb_t data_cb, void *arg); - -/** Common function for subscribe and unsubscribe */ -err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub); - -/** @ingroup mqtt - *Subscribe to topic */ -#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1) -/** @ingroup mqtt - * Unsubscribe to topic */ -#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0) - - -/** Publish data to topic */ -err_t mqtt_publish(mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain, - mqtt_request_cb_t cb, void *arg); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_MQTT_CLIENT_H */ +/** + * @file + * MQTT client + */ + +/* + * Copyright (c) 2016 Erik Andersson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Erik Andersson + * + */ +#ifndef LWIP_HDR_APPS_MQTT_CLIENT_H +#define LWIP_HDR_APPS_MQTT_CLIENT_H + +#include "lwip/apps/mqtt_opts.h" +#include "lwip/err.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct mqtt_client_t mqtt_client_t; + +/** @ingroup mqtt + * Default MQTT port */ +#define MQTT_PORT 1883 + +/*---------------------------------------------------------------------------------------------- */ +/* Connection with server */ + +/** + * @ingroup mqtt + * Client information and connection parameters */ +struct mqtt_connect_client_info_t { + /** Client identifier, must be set by caller */ + const char *client_id; + /** User name and password, set to NULL if not used */ + const char* client_user; + const char* client_pass; + /** keep alive time in seconds, 0 to disable keep alive functionality*/ + u16_t keep_alive; + /** will topic, set to NULL if will is not to be used, + will_msg, will_qos and will retain are then ignored */ + const char* will_topic; + const char* will_msg; + u8_t will_qos; + u8_t will_retain; +}; + +/** + * @ingroup mqtt + * Connection status codes */ +typedef enum +{ + MQTT_CONNECT_ACCEPTED = 0, + MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1, + MQTT_CONNECT_REFUSED_IDENTIFIER = 2, + MQTT_CONNECT_REFUSED_SERVER = 3, + MQTT_CONNECT_REFUSED_USERNAME_PASS = 4, + MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5, + MQTT_CONNECT_DISCONNECTED = 256, + MQTT_CONNECT_TIMEOUT = 257 +} mqtt_connection_status_t; + +/** + * @ingroup mqtt + * Function prototype for mqtt connection status callback. Called when + * client has connected to the server after initiating a mqtt connection attempt by + * calling mqtt_connect() or when connection is closed by server or an error + * + * @param client MQTT client itself + * @param arg Additional argument to pass to the callback function + * @param status Connect result code or disconnection notification @see mqtt_connection_status_t + * + */ +typedef void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status); + + +/** + * @ingroup mqtt + * Data callback flags */ +enum { + /** Flag set when last fragment of data arrives in data callback */ + MQTT_DATA_FLAG_LAST = 1 +}; + +/** + * @ingroup mqtt + * Function prototype for MQTT incoming publish data callback function. Called when data + * arrives to a subscribed topic @see mqtt_subscribe + * + * @param arg Additional argument to pass to the callback function + * @param data User data, pointed object, data may not be referenced after callback return, + NULL is passed when all publish data are delivered + * @param len Length of publish data fragment + * @param flags MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message + * + */ +typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags); + + +/** + * @ingroup mqtt + * Function prototype for MQTT incoming publish function. Called when an incoming publish + * arrives to a subscribed topic @see mqtt_subscribe + * + * @param arg Additional argument to pass to the callback function + * @param topic Zero terminated Topic text string, topic may not be referenced after callback return + * @param tot_len Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked + */ +typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len); + + +/** + * @ingroup mqtt + * Function prototype for mqtt request callback. Called when a subscribe, unsubscribe + * or publish request has completed + * @param arg Pointer to user data supplied when invoking request + * @param err ERR_OK on success + * ERR_TIMEOUT if no response was received within timeout, + * ERR_ABRT if (un)subscribe was denied + */ +typedef void (*mqtt_request_cb_t)(void *arg, err_t err); + + +/** + * Pending request item, binds application callback to pending server requests + */ +struct mqtt_request_t +{ + /** Next item in list, NULL means this is the last in chain, + next pointing at itself means request is unallocated */ + struct mqtt_request_t *next; + /** Callback to upper layer */ + mqtt_request_cb_t cb; + void *arg; + /** MQTT packet identifier */ + u16_t pkt_id; + /** Expire time relative to element before this */ + u16_t timeout_diff; +}; + +/** Ring buffer */ +struct mqtt_ringbuf_t { + u16_t put; + u16_t get; + u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE]; +}; + +/** MQTT client */ +struct mqtt_client_t +{ + /** Timers and timeouts */ + u16_t cyclic_tick; + u16_t keep_alive; + u16_t server_watchdog; + /** Packet identifier generator*/ + u16_t pkt_id_seq; + /** Packet identifier of pending incoming publish */ + u16_t inpub_pkt_id; + /** Connection state */ + u8_t conn_state; + struct tcp_pcb *conn; + /** Connection callback */ + void *connect_arg; + mqtt_connection_cb_t connect_cb; + /** Pending requests to server */ + struct mqtt_request_t *pend_req_queue; + struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT]; + void *inpub_arg; + /** Incoming data callback */ + mqtt_incoming_data_cb_t data_cb; + mqtt_incoming_publish_cb_t pub_cb; + /** Input */ + u32_t msg_idx; + u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN]; + /** Output ring-buffer */ + struct mqtt_ringbuf_t output; +}; + + +/** Connect to server */ +err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg, + const struct mqtt_connect_client_info_t *client_info); + +/** Disconnect from server */ +void mqtt_disconnect(mqtt_client_t *client); + +/** Create new client */ +mqtt_client_t *mqtt_client_new(void); + +/** Check connection status */ +u8_t mqtt_client_is_connected(mqtt_client_t *client); + +/** Set callback to call for incoming publish */ +void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t, + mqtt_incoming_data_cb_t data_cb, void *arg); + +/** Common function for subscribe and unsubscribe */ +err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub); + +/** @ingroup mqtt + *Subscribe to topic */ +#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1) +/** @ingroup mqtt + * Unsubscribe to topic */ +#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0) + + +/** Publish data to topic */ +err_t mqtt_publish(mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain, + mqtt_request_cb_t cb, void *arg); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_MQTT_CLIENT_H */ diff --git a/sys/include/net/apps/mqtt_opts.h b/sys/include/net/apps/mqtt_opts.h index ffefacd..7d07829 100644 --- a/sys/include/net/apps/mqtt_opts.h +++ b/sys/include/net/apps/mqtt_opts.h @@ -1,103 +1,103 @@ -/** - * @file - * MQTT client options - */ - -/* - * Copyright (c) 2016 Erik Andersson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Erik Andersson - * - */ -#ifndef LWIP_HDR_APPS_MQTT_OPTS_H -#define LWIP_HDR_APPS_MQTT_OPTS_H - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup mqtt_opts Options - * @ingroup mqtt - * @{ - */ - -/** - * Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads - */ -#ifndef MQTT_OUTPUT_RINGBUF_SIZE -#define MQTT_OUTPUT_RINGBUF_SIZE 256 -#endif - -/** - * Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8 - * If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8 - */ -#ifndef MQTT_VAR_HEADER_BUFFER_LEN -#define MQTT_VAR_HEADER_BUFFER_LEN 128 -#endif - -/** - * Maximum number of pending subscribe, unsubscribe and publish requests to server . - */ -#ifndef MQTT_REQ_MAX_IN_FLIGHT -#define MQTT_REQ_MAX_IN_FLIGHT 4 -#endif - -/** - * Seconds between each cyclic timer call. - */ -#ifndef MQTT_CYCLIC_TIMER_INTERVAL -#define MQTT_CYCLIC_TIMER_INTERVAL 5 -#endif - -/** - * Publish, subscribe and unsubscribe request timeout in seconds. - */ -#ifndef MQTT_REQ_TIMEOUT -#define MQTT_REQ_TIMEOUT 30 -#endif - -/** - * Seconds for MQTT connect response timeout after sending connect request - */ -#ifndef MQTT_CONNECT_TIMOUT -#define MQTT_CONNECT_TIMOUT 100 -#endif - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_MQTT_OPTS_H */ +/** + * @file + * MQTT client options + */ + +/* + * Copyright (c) 2016 Erik Andersson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Erik Andersson + * + */ +#ifndef LWIP_HDR_APPS_MQTT_OPTS_H +#define LWIP_HDR_APPS_MQTT_OPTS_H + +#include "lwip/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup mqtt_opts Options + * @ingroup mqtt + * @{ + */ + +/** + * Output ring-buffer size, must be able to fit largest outgoing publish message topic+payloads + */ +#ifndef MQTT_OUTPUT_RINGBUF_SIZE +#define MQTT_OUTPUT_RINGBUF_SIZE 256 +#endif + +/** + * Number of bytes in receive buffer, must be at least the size of the longest incoming topic + 8 + * If one wants to avoid fragmented incoming publish, set length to max incoming topic length + max payload length + 8 + */ +#ifndef MQTT_VAR_HEADER_BUFFER_LEN +#define MQTT_VAR_HEADER_BUFFER_LEN 128 +#endif + +/** + * Maximum number of pending subscribe, unsubscribe and publish requests to server . + */ +#ifndef MQTT_REQ_MAX_IN_FLIGHT +#define MQTT_REQ_MAX_IN_FLIGHT 4 +#endif + +/** + * Seconds between each cyclic timer call. + */ +#ifndef MQTT_CYCLIC_TIMER_INTERVAL +#define MQTT_CYCLIC_TIMER_INTERVAL 5 +#endif + +/** + * Publish, subscribe and unsubscribe request timeout in seconds. + */ +#ifndef MQTT_REQ_TIMEOUT +#define MQTT_REQ_TIMEOUT 30 +#endif + +/** + * Seconds for MQTT connect response timeout after sending connect request + */ +#ifndef MQTT_CONNECT_TIMOUT +#define MQTT_CONNECT_TIMOUT 100 +#endif + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_MQTT_OPTS_H */ diff --git a/sys/include/net/apps/netbiosns.h b/sys/include/net/apps/netbiosns.h new file mode 100644 index 0000000..4126606 --- /dev/null +++ b/sys/include/net/apps/netbiosns.h @@ -0,0 +1,43 @@ +/** + * @file + * NETBIOS name service responder + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ +#ifndef LWIP_HDR_APPS_NETBIOS_H +#define LWIP_HDR_APPS_NETBIOS_H + +#include "lwip/apps/netbiosns_opts.h" + +void netbiosns_init(void); +#ifndef NETBIOS_LWIP_NAME +void netbiosns_set_name(const char* hostname); +#endif +void netbiosns_stop(void); + +#endif /* LWIP_HDR_APPS_NETBIOS_H */ diff --git a/sys/include/net/apps/netbiosns_opts.h b/sys/include/net/apps/netbiosns_opts.h index 0909ef7..f4d2039 100644 --- a/sys/include/net/apps/netbiosns_opts.h +++ b/sys/include/net/apps/netbiosns_opts.h @@ -1,59 +1,59 @@ -/** - * @file - * NETBIOS name service responder options - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ -#ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H -#define LWIP_HDR_APPS_NETBIOS_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup netbiosns_opts Options - * @ingroup netbiosns - * @{ - */ - -/** NetBIOS name of lwip device - * This must be uppercase until NETBIOS_STRCMP() is defined to a string - * comparision function that is case insensitive. - * If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME): - * (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "") - * - * If this is not defined, netbiosns_set_name() can be called at runtime to change the name. - */ -#ifdef __DOXYGEN__ -#define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV" -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */ +/** + * @file + * NETBIOS name service responder options + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ +#ifndef LWIP_HDR_APPS_NETBIOS_OPTS_H +#define LWIP_HDR_APPS_NETBIOS_OPTS_H + +#include "lwip/opt.h" + +/** + * @defgroup netbiosns_opts Options + * @ingroup netbiosns + * @{ + */ + +/** NetBIOS name of lwip device + * This must be uppercase until NETBIOS_STRCMP() is defined to a string + * comparision function that is case insensitive. + * If you want to use the netif's hostname, use this (with LWIP_NETIF_HOSTNAME): + * (ip_current_netif() != NULL ? ip_current_netif()->hostname != NULL ? ip_current_netif()->hostname : "" : "") + * + * If this is not defined, netbiosns_set_name() can be called at runtime to change the name. + */ +#ifdef __DOXYGEN__ +#define NETBIOS_LWIP_NAME "NETBIOSLWIPDEV" +#endif + +/** + * @} + */ + +#endif /* LWIP_HDR_APPS_NETBIOS_OPTS_H */ diff --git a/sys/include/net/apps/snmp.h b/sys/include/net/apps/snmp.h index 10e8ff4..5f267be 100644 --- a/sys/include/net/apps/snmp.h +++ b/sys/include/net/apps/snmp.h @@ -1,128 +1,128 @@ -/** - * @file - * SNMP server main API - start and basic configuration - */ - -/* - * Copyright (c) 2001, 2002 Leon Woestenberg - * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Leon Woestenberg - * Martin Hentschel - * - */ -#ifndef LWIP_HDR_APPS_SNMP_H -#define LWIP_HDR_APPS_SNMP_H - -#include "lwip/apps/snmp_opts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/err.h" -#include "lwip/apps/snmp_core.h" - -/** SNMP variable binding descriptor (publically needed for traps) */ -struct snmp_varbind -{ - /** pointer to next varbind, NULL for last in list */ - struct snmp_varbind *next; - /** pointer to previous varbind, NULL for first in list */ - struct snmp_varbind *prev; - - /** object identifier */ - struct snmp_obj_id oid; - - /** value ASN1 type */ - u8_t type; - /** object value length */ - u16_t value_len; - /** object value */ - void *value; -}; - -/** - * @ingroup snmp_core - * Agent setup, start listening to port 161. - */ -void snmp_init(void); -void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs); - -void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid); -const struct snmp_obj_id* snmp_get_device_enterprise_oid(void); - -void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); -void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst); - -/** Generic trap: cold start */ -#define SNMP_GENTRAP_COLDSTART 0 -/** Generic trap: warm start */ -#define SNMP_GENTRAP_WARMSTART 1 -/** Generic trap: link down */ -#define SNMP_GENTRAP_LINKDOWN 2 -/** Generic trap: link up */ -#define SNMP_GENTRAP_LINKUP 3 -/** Generic trap: authentication failure */ -#define SNMP_GENTRAP_AUTH_FAILURE 4 -/** Generic trap: EGP neighbor lost */ -#define SNMP_GENTRAP_EGP_NEIGHBOR_LOSS 5 -/** Generic trap: enterprise specific */ -#define SNMP_GENTRAP_ENTERPRISE_SPECIFIC 6 - -err_t snmp_send_trap_generic(s32_t generic_trap); -err_t snmp_send_trap_specific(s32_t specific_trap, struct snmp_varbind *varbinds); -err_t snmp_send_trap(const struct snmp_obj_id* oid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds); - -#define SNMP_AUTH_TRAPS_DISABLED 0 -#define SNMP_AUTH_TRAPS_ENABLED 1 -void snmp_set_auth_traps_enabled(u8_t enable); -u8_t snmp_get_auth_traps_enabled(void); - -const char * snmp_get_community(void); -const char * snmp_get_community_write(void); -const char * snmp_get_community_trap(void); -void snmp_set_community(const char * const community); -void snmp_set_community_write(const char * const community); -void snmp_set_community_trap(const char * const community); - -void snmp_coldstart_trap(void); -void snmp_authfail_trap(void); - -typedef void (*snmp_write_callback_fct)(const u32_t* oid, u8_t oid_len, void* callback_arg); -void snmp_set_write_callback(snmp_write_callback_fct write_callback, void* callback_arg); - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_H */ +/** + * @file + * SNMP server main API - start and basic configuration + */ + +/* + * Copyright (c) 2001, 2002 Leon Woestenberg + * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Leon Woestenberg + * Martin Hentschel + * + */ +#ifndef LWIP_HDR_APPS_SNMP_H +#define LWIP_HDR_APPS_SNMP_H + +#include "lwip/apps/snmp_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/err.h" +#include "lwip/apps/snmp_core.h" + +/** SNMP variable binding descriptor (publically needed for traps) */ +struct snmp_varbind +{ + /** pointer to next varbind, NULL for last in list */ + struct snmp_varbind *next; + /** pointer to previous varbind, NULL for first in list */ + struct snmp_varbind *prev; + + /** object identifier */ + struct snmp_obj_id oid; + + /** value ASN1 type */ + u8_t type; + /** object value length */ + u16_t value_len; + /** object value */ + void *value; +}; + +/** + * @ingroup snmp_core + * Agent setup, start listening to port 161. + */ +void snmp_init(void); +void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs); + +void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid); +const struct snmp_obj_id* snmp_get_device_enterprise_oid(void); + +void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); +void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst); + +/** Generic trap: cold start */ +#define SNMP_GENTRAP_COLDSTART 0 +/** Generic trap: warm start */ +#define SNMP_GENTRAP_WARMSTART 1 +/** Generic trap: link down */ +#define SNMP_GENTRAP_LINKDOWN 2 +/** Generic trap: link up */ +#define SNMP_GENTRAP_LINKUP 3 +/** Generic trap: authentication failure */ +#define SNMP_GENTRAP_AUTH_FAILURE 4 +/** Generic trap: EGP neighbor lost */ +#define SNMP_GENTRAP_EGP_NEIGHBOR_LOSS 5 +/** Generic trap: enterprise specific */ +#define SNMP_GENTRAP_ENTERPRISE_SPECIFIC 6 + +err_t snmp_send_trap_generic(s32_t generic_trap); +err_t snmp_send_trap_specific(s32_t specific_trap, struct snmp_varbind *varbinds); +err_t snmp_send_trap(const struct snmp_obj_id* oid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds); + +#define SNMP_AUTH_TRAPS_DISABLED 0 +#define SNMP_AUTH_TRAPS_ENABLED 1 +void snmp_set_auth_traps_enabled(u8_t enable); +u8_t snmp_get_auth_traps_enabled(void); + +const char * snmp_get_community(void); +const char * snmp_get_community_write(void); +const char * snmp_get_community_trap(void); +void snmp_set_community(const char * const community); +void snmp_set_community_write(const char * const community); +void snmp_set_community_trap(const char * const community); + +void snmp_coldstart_trap(void); +void snmp_authfail_trap(void); + +typedef void (*snmp_write_callback_fct)(const u32_t* oid, u8_t oid_len, void* callback_arg); +void snmp_set_write_callback(snmp_write_callback_fct write_callback, void* callback_arg); + +#endif /* LWIP_SNMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_SNMP_H */ diff --git a/sys/include/net/apps/snmp_core.h b/sys/include/net/apps/snmp_core.h new file mode 100644 index 0000000..a832572 --- /dev/null +++ b/sys/include/net/apps/snmp_core.h @@ -0,0 +1,364 @@ +/** + * @file + * SNMP core API for implementing MIBs + */ + +/* + * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Christiaan Simons + * Martin Hentschel + */ + +#ifndef LWIP_HDR_APPS_SNMP_CORE_H +#define LWIP_HDR_APPS_SNMP_CORE_H + +#include "lwip/apps/snmp_opts.h" + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/ip_addr.h" +#include "lwip/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* basic ASN1 defines */ +#define SNMP_ASN1_CLASS_UNIVERSAL 0x00 +#define SNMP_ASN1_CLASS_APPLICATION 0x40 +#define SNMP_ASN1_CLASS_CONTEXT 0x80 +#define SNMP_ASN1_CLASS_PRIVATE 0xC0 + +#define SNMP_ASN1_CONTENTTYPE_PRIMITIVE 0x00 +#define SNMP_ASN1_CONTENTTYPE_CONSTRUCTED 0x20 + +/* universal tags (from ASN.1 spec.) */ +#define SNMP_ASN1_UNIVERSAL_END_OF_CONTENT 0 +#define SNMP_ASN1_UNIVERSAL_INTEGER 2 +#define SNMP_ASN1_UNIVERSAL_OCTET_STRING 4 +#define SNMP_ASN1_UNIVERSAL_NULL 5 +#define SNMP_ASN1_UNIVERSAL_OBJECT_ID 6 +#define SNMP_ASN1_UNIVERSAL_SEQUENCE_OF 16 + +/* application specific (SNMP) tags (from SNMPv2-SMI) */ +#define SNMP_ASN1_APPLICATION_IPADDR 0 /* [APPLICATION 0] IMPLICIT OCTET STRING (SIZE (4)) */ +#define SNMP_ASN1_APPLICATION_COUNTER 1 /* [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) => u32_t */ +#define SNMP_ASN1_APPLICATION_GAUGE 2 /* [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) => u32_t */ +#define SNMP_ASN1_APPLICATION_TIMETICKS 3 /* [APPLICATION 3] IMPLICIT INTEGER (0..4294967295) => u32_t */ +#define SNMP_ASN1_APPLICATION_OPAQUE 4 /* [APPLICATION 4] IMPLICIT OCTET STRING */ +#define SNMP_ASN1_APPLICATION_COUNTER64 6 /* [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615) */ + +/* context specific (SNMP) tags (from RFC 1905) */ +#define SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE 1 + +/* full ASN1 type defines */ +#define SNMP_ASN1_TYPE_END_OF_CONTENT (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_END_OF_CONTENT) +#define SNMP_ASN1_TYPE_INTEGER (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_INTEGER) +#define SNMP_ASN1_TYPE_OCTET_STRING (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OCTET_STRING) +#define SNMP_ASN1_TYPE_NULL (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_NULL) +#define SNMP_ASN1_TYPE_OBJECT_ID (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_UNIVERSAL_OBJECT_ID) +#define SNMP_ASN1_TYPE_SEQUENCE (SNMP_ASN1_CLASS_UNIVERSAL | SNMP_ASN1_CONTENTTYPE_CONSTRUCTED | SNMP_ASN1_UNIVERSAL_SEQUENCE_OF) +#define SNMP_ASN1_TYPE_IPADDR (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_IPADDR) +#define SNMP_ASN1_TYPE_IPADDRESS SNMP_ASN1_TYPE_IPADDR +#define SNMP_ASN1_TYPE_COUNTER (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER) +#define SNMP_ASN1_TYPE_COUNTER32 SNMP_ASN1_TYPE_COUNTER +#define SNMP_ASN1_TYPE_GAUGE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_GAUGE) +#define SNMP_ASN1_TYPE_GAUGE32 SNMP_ASN1_TYPE_GAUGE +#define SNMP_ASN1_TYPE_UNSIGNED32 SNMP_ASN1_TYPE_GAUGE +#define SNMP_ASN1_TYPE_TIMETICKS (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_TIMETICKS) +#define SNMP_ASN1_TYPE_OPAQUE (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_OPAQUE) +#define SNMP_ASN1_TYPE_COUNTER64 (SNMP_ASN1_CLASS_APPLICATION | SNMP_ASN1_CONTENTTYPE_PRIMITIVE | SNMP_ASN1_APPLICATION_COUNTER64) + +#define SNMP_VARBIND_EXCEPTION_OFFSET 0xF0 +#define SNMP_VARBIND_EXCEPTION_MASK 0x0F + +/** error codes predefined by SNMP prot. */ +typedef enum { + SNMP_ERR_NOERROR = 0, +/* +outdated v1 error codes. do not use anmore! +#define SNMP_ERR_NOSUCHNAME 2 use SNMP_ERR_NOSUCHINSTANCE instead +#define SNMP_ERR_BADVALUE 3 use SNMP_ERR_WRONGTYPE,SNMP_ERR_WRONGLENGTH,SNMP_ERR_WRONGENCODING or SNMP_ERR_WRONGVALUE instead +#define SNMP_ERR_READONLY 4 use SNMP_ERR_NOTWRITABLE instead +*/ + SNMP_ERR_GENERROR = 5, + SNMP_ERR_NOACCESS = 6, + SNMP_ERR_WRONGTYPE = 7, + SNMP_ERR_WRONGLENGTH = 8, + SNMP_ERR_WRONGENCODING = 9, + SNMP_ERR_WRONGVALUE = 10, + SNMP_ERR_NOCREATION = 11, + SNMP_ERR_INCONSISTENTVALUE = 12, + SNMP_ERR_RESOURCEUNAVAILABLE = 13, + SNMP_ERR_COMMITFAILED = 14, + SNMP_ERR_UNDOFAILED = 15, + SNMP_ERR_NOTWRITABLE = 17, + SNMP_ERR_INCONSISTENTNAME = 18, + + SNMP_ERR_NOSUCHINSTANCE = SNMP_VARBIND_EXCEPTION_OFFSET + SNMP_ASN1_CONTEXT_VARBIND_NO_SUCH_INSTANCE +} snmp_err_t; + +/** internal object identifier representation */ +struct snmp_obj_id +{ + u8_t len; + u32_t id[SNMP_MAX_OBJ_ID_LEN]; +}; + +struct snmp_obj_id_const_ref +{ + u8_t len; + const u32_t* id; +}; + +extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero; /* administrative identifier from SNMPv2-SMI */ + +/** SNMP variant value, used as reference in struct snmp_node_instance and table implementation */ +union snmp_variant_value +{ + void* ptr; + const void* const_ptr; + u32_t u32; + s32_t s32; +}; + + +/** +SNMP MIB node types + tree node is the only node the stack can process in order to walk the tree, + all other nodes are assumed to be leaf nodes. + This cannot be an enum because users may want to define their own node types. +*/ +#define SNMP_NODE_TREE 0x00 +/* predefined leaf node types */ +#define SNMP_NODE_SCALAR 0x01 +#define SNMP_NODE_SCALAR_ARRAY 0x02 +#define SNMP_NODE_TABLE 0x03 +#define SNMP_NODE_THREADSYNC 0x04 + +/** node "base class" layout, the mandatory fields for a node */ +struct snmp_node +{ + /** one out of SNMP_NODE_TREE or any leaf node type (like SNMP_NODE_SCALAR) */ + u8_t node_type; + /** the number assigned to this node which used as part of the full OID */ + u32_t oid; +}; + +/** SNMP node instance access types */ +typedef enum { + SNMP_NODE_INSTANCE_ACCESS_READ = 1, + SNMP_NODE_INSTANCE_ACCESS_WRITE = 2, + SNMP_NODE_INSTANCE_READ_ONLY = SNMP_NODE_INSTANCE_ACCESS_READ, + SNMP_NODE_INSTANCE_READ_WRITE = (SNMP_NODE_INSTANCE_ACCESS_READ | SNMP_NODE_INSTANCE_ACCESS_WRITE), + SNMP_NODE_INSTANCE_WRITE_ONLY = SNMP_NODE_INSTANCE_ACCESS_WRITE, + SNMP_NODE_INSTANCE_NOT_ACCESSIBLE = 0 +} snmp_access_t; + +struct snmp_node_instance; + +typedef s16_t (*node_instance_get_value_method)(struct snmp_node_instance*, void*); +typedef snmp_err_t (*node_instance_set_test_method)(struct snmp_node_instance*, u16_t, void*); +typedef snmp_err_t (*node_instance_set_value_method)(struct snmp_node_instance*, u16_t, void*); +typedef void (*node_instance_release_method)(struct snmp_node_instance*); + +#define SNMP_GET_VALUE_RAW_DATA 0x8000 + +/** SNMP node instance */ +struct snmp_node_instance +{ + /** prefilled with the node, get_instance() is called on; may be changed by user to any value to pass an arbitrary node between calls to get_instance() and get_value/test_value/set_value */ + const struct snmp_node* node; + /** prefilled with the instance id requested; for get_instance() this is the exact oid requested; for get_next_instance() this is the relative starting point, stack expects relative oid of next node here */ + struct snmp_obj_id instance_oid; + + /** ASN type for this object (see snmp_asn1.h for definitions) */ + u8_t asn1_type; + /** one out of instance access types defined above (SNMP_NODE_INSTANCE_READ_ONLY,...) */ + snmp_access_t access; + + /** returns object value for the given object identifier. Return values <0 to indicate an error */ + node_instance_get_value_method get_value; + /** tests length and/or range BEFORE setting */ + node_instance_set_test_method set_test; + /** sets object value, only called when set_test() was successful */ + node_instance_set_value_method set_value; + /** called in any case when the instance is not required anymore by stack (useful for freeing memory allocated in get_instance/get_next_instance methods) */ + node_instance_release_method release_instance; + + /** reference to pass arbitrary value between calls to get_instance() and get_value/test_value/set_value */ + union snmp_variant_value reference; + /** see reference (if reference is a pointer, the length of underlying data may be stored here or anything else) */ + u32_t reference_len; +}; + + +/** SNMP tree node */ +struct snmp_tree_node +{ + /** inherited "base class" members */ + struct snmp_node node; + u16_t subnode_count; + const struct snmp_node* const *subnodes; +}; + +#define SNMP_CREATE_TREE_NODE(oid, subnodes) \ + {{ SNMP_NODE_TREE, (oid) }, \ + (u16_t)LWIP_ARRAYSIZE(subnodes), (subnodes) } + +#define SNMP_CREATE_EMPTY_TREE_NODE(oid) \ + {{ SNMP_NODE_TREE, (oid) }, \ + 0, NULL } + +/** SNMP leaf node */ +struct snmp_leaf_node +{ + /** inherited "base class" members */ + struct snmp_node node; + snmp_err_t (*get_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); + snmp_err_t (*get_next_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); +}; + +/** represents a single mib with its base oid and root node */ +struct snmp_mib +{ + const u32_t *base_oid; + u8_t base_oid_len; + const struct snmp_node *root_node; +}; + +#define SNMP_MIB_CREATE(oid_list, root_node) { (oid_list), (u8_t)LWIP_ARRAYSIZE(oid_list), root_node } + +/** OID range structure */ +struct snmp_oid_range +{ + u32_t min; + u32_t max; +}; + +/** checks if incoming OID length and values are in allowed ranges */ +u8_t snmp_oid_in_range(const u32_t *oid_in, u8_t oid_len, const struct snmp_oid_range *oid_ranges, u8_t oid_ranges_len); + +typedef enum { + SNMP_NEXT_OID_STATUS_SUCCESS, + SNMP_NEXT_OID_STATUS_NO_MATCH, + SNMP_NEXT_OID_STATUS_BUF_TO_SMALL +} snmp_next_oid_status_t; + +/** state for next_oid_init / next_oid_check functions */ +struct snmp_next_oid_state +{ + const u32_t* start_oid; + u8_t start_oid_len; + + u32_t* next_oid; + u8_t next_oid_len; + u8_t next_oid_max_len; + + snmp_next_oid_status_t status; + void* reference; +}; + +void snmp_next_oid_init(struct snmp_next_oid_state *state, + const u32_t *start_oid, u8_t start_oid_len, + u32_t *next_oid_buf, u8_t next_oid_max_len); +u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len); +u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference); + +void snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len); +void snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len); +void snmp_oid_prefix(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len); +void snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len); +u8_t snmp_oid_equal(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len); +s8_t snmp_oid_compare(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len); + +#if LWIP_IPV4 +u8_t snmp_oid_to_ip4(const u32_t *oid, ip4_addr_t *ip); +void snmp_ip4_to_oid(const ip4_addr_t *ip, u32_t *oid); +#endif /* LWIP_IPV4 */ +#if LWIP_IPV6 +u8_t snmp_oid_to_ip6(const u32_t *oid, ip6_addr_t *ip); +void snmp_ip6_to_oid(const ip6_addr_t *ip, u32_t *oid); +#endif /* LWIP_IPV6 */ +#if LWIP_IPV4 || LWIP_IPV6 +u8_t snmp_ip_to_oid(const ip_addr_t *ip, u32_t *oid); +u8_t snmp_ip_port_to_oid(const ip_addr_t *ip, u16_t port, u32_t *oid); + +u8_t snmp_oid_to_ip(const u32_t *oid, u8_t oid_len, ip_addr_t *ip); +u8_t snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port); +#endif /* LWIP_IPV4 || LWIP_IPV6 */ + +struct netif; +u8_t netif_to_num(const struct netif *netif); + +snmp_err_t snmp_set_test_ok(struct snmp_node_instance* instance, u16_t value_len, void* value); /* generic function which can be used if test is always successful */ + +err_t snmp_decode_bits(const u8_t *buf, u32_t buf_len, u32_t *bit_value); +err_t snmp_decode_truthvalue(const s32_t *asn1_value, u8_t *bool_value); +u8_t snmp_encode_bits(u8_t *buf, u32_t buf_len, u32_t bit_value, u8_t bit_count); +u8_t snmp_encode_truthvalue(s32_t *asn1_value, u32_t bool_value); + +struct snmp_statistics +{ + u32_t inpkts; + u32_t outpkts; + u32_t inbadversions; + u32_t inbadcommunitynames; + u32_t inbadcommunityuses; + u32_t inasnparseerrs; + u32_t intoobigs; + u32_t innosuchnames; + u32_t inbadvalues; + u32_t inreadonlys; + u32_t ingenerrs; + u32_t intotalreqvars; + u32_t intotalsetvars; + u32_t ingetrequests; + u32_t ingetnexts; + u32_t insetrequests; + u32_t ingetresponses; + u32_t intraps; + u32_t outtoobigs; + u32_t outnosuchnames; + u32_t outbadvalues; + u32_t outgenerrs; + u32_t outgetrequests; + u32_t outgetnexts; + u32_t outsetrequests; + u32_t outgetresponses; + u32_t outtraps; +}; + +extern struct snmp_statistics snmp_stats; + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_SNMP */ + +#endif /* LWIP_HDR_APPS_SNMP_CORE_H */ diff --git a/sys/include/net/apps/snmp_mib2.h b/sys/include/net/apps/snmp_mib2.h index 2f4a689..392ee25 100644 --- a/sys/include/net/apps/snmp_mib2.h +++ b/sys/include/net/apps/snmp_mib2.h @@ -1,78 +1,78 @@ -/** - * @file - * SNMP MIB2 API - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Dirk Ziegelmeier - * - */ -#ifndef LWIP_HDR_APPS_SNMP_MIB2_H -#define LWIP_HDR_APPS_SNMP_MIB2_H - -#include "lwip/apps/snmp_opts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ -#if SNMP_LWIP_MIB2 - -#include "lwip/apps/snmp_core.h" - -extern const struct snmp_mib mib2; - -#if SNMP_USE_NETCONN -#include "lwip/apps/snmp_threadsync.h" -void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg); -extern struct snmp_threadsync_instance snmp_mib2_lwip_locks; -#endif - -#ifndef SNMP_SYSSERVICES -#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) -#endif - -void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */ -void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); -void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen); -void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); -void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen); -void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); -void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen); - -#endif /* SNMP_LWIP_MIB2 */ -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_MIB2_H */ +/** + * @file + * SNMP MIB2 API + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Dirk Ziegelmeier + * + */ +#ifndef LWIP_HDR_APPS_SNMP_MIB2_H +#define LWIP_HDR_APPS_SNMP_MIB2_H + +#include "lwip/apps/snmp_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ +#if SNMP_LWIP_MIB2 + +#include "lwip/apps/snmp_core.h" + +extern const struct snmp_mib mib2; + +#if SNMP_USE_NETCONN +#include "lwip/apps/snmp_threadsync.h" +void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg); +extern struct snmp_threadsync_instance snmp_mib2_lwip_locks; +#endif + +#ifndef SNMP_SYSSERVICES +#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) +#endif + +void snmp_mib2_set_sysdescr(const u8_t* str, const u16_t* len); /* read-only be defintion */ +void snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); +void snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen); +void snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); +void snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen); +void snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize); +void snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen); + +#endif /* SNMP_LWIP_MIB2 */ +#endif /* LWIP_SNMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_SNMP_MIB2_H */ diff --git a/sys/include/net/apps/snmp_opts.h b/sys/include/net/apps/snmp_opts.h new file mode 100644 index 0000000..d4ae068 --- /dev/null +++ b/sys/include/net/apps/snmp_opts.h @@ -0,0 +1,293 @@ +/** + * @file + * SNMP server options list + */ + +/* + * Copyright (c) 2015 Dirk Ziegelmeier + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Dirk Ziegelmeier + * + */ +#ifndef LWIP_HDR_SNMP_OPTS_H +#define LWIP_HDR_SNMP_OPTS_H + +#include "lwip/opt.h" + +/** + * @defgroup snmp_opts Options + * @ingroup snmp + * @{ + */ + +/** + * LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available + * for SNMP transport. + * If you want to use your own SNMP agent, leave this disabled. + * To integrate MIB2 of an external agent, you need to enable + * LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks + * and statistics counters you need to get MIB2 working. + */ +#if !defined LWIP_SNMP || defined __DOXYGEN__ +#define LWIP_SNMP 0 +#endif + +/** + * SNMP_USE_NETCONN: Use netconn API instead of raw API. + * Makes SNMP agent run in a worker thread, so blocking operations + * can be done in MIB calls. + */ +#if !defined SNMP_USE_NETCONN || defined __DOXYGEN__ +#define SNMP_USE_NETCONN 0 +#endif + +/** + * SNMP_USE_RAW: Use raw API. + * SNMP agent does not run in a worker thread, so blocking operations + * should not be done in MIB calls. + */ +#if !defined SNMP_USE_RAW || defined __DOXYGEN__ +#define SNMP_USE_RAW 1 +#endif + +#if SNMP_USE_NETCONN && SNMP_USE_RAW +#error SNMP stack can use only one of the APIs {raw, netconn} +#endif + +#if LWIP_SNMP && !SNMP_USE_NETCONN && !SNMP_USE_RAW +#error SNMP stack needs a receive API and UDP {raw, netconn} +#endif + +#if SNMP_USE_NETCONN +/** + * SNMP_STACK_SIZE: Stack size of SNMP netconn worker thread + */ +#if !defined SNMP_STACK_SIZE || defined __DOXYGEN__ +#define SNMP_STACK_SIZE DEFAULT_THREAD_STACKSIZE +#endif + +/** + * SNMP_THREAD_PRIO: SNMP netconn worker thread priority + */ +#if !defined SNMP_THREAD_PRIO || defined __DOXYGEN__ +#define SNMP_THREAD_PRIO DEFAULT_THREAD_PRIO +#endif +#endif /* SNMP_USE_NETCONN */ + +/** + * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap + * destination is required + */ +#if !defined SNMP_TRAP_DESTINATIONS || defined __DOXYGEN__ +#define SNMP_TRAP_DESTINATIONS 1 +#endif + +/** + * Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not + * a safe action and disabled when SNMP_SAFE_REQUESTS = 1). + * Unsafe requests are disabled by default! + */ +#if !defined SNMP_SAFE_REQUESTS || defined __DOXYGEN__ +#define SNMP_SAFE_REQUESTS 1 +#endif + +/** + * The maximum length of strings used. + */ +#if !defined SNMP_MAX_OCTET_STRING_LEN || defined __DOXYGEN__ +#define SNMP_MAX_OCTET_STRING_LEN 127 +#endif + +/** + * The maximum number of Sub ID's inside an object identifier. + * Indirectly this also limits the maximum depth of SNMP tree. + */ +#if !defined SNMP_MAX_OBJ_ID_LEN || defined __DOXYGEN__ +#define SNMP_MAX_OBJ_ID_LEN 50 +#endif + +#if !defined SNMP_MAX_VALUE_SIZE || defined __DOXYGEN__ +/** + * The maximum size of a value. + */ +#define SNMP_MIN_VALUE_SIZE (2 * sizeof(u32_t*)) /* size required to store the basic types (8 bytes for counter64) */ +/** + * The minimum size of a value. + */ +#define SNMP_MAX_VALUE_SIZE LWIP_MAX(LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN), sizeof(u32_t)*(SNMP_MAX_OBJ_ID_LEN)), SNMP_MIN_VALUE_SIZE) +#endif + +/** + * The snmp read-access community. Used for write-access and traps, too + * unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively. + */ +#if !defined SNMP_COMMUNITY || defined __DOXYGEN__ +#define SNMP_COMMUNITY "public" +#endif + +/** + * The snmp write-access community. + * Set this community to "" in order to disallow any write access. + */ +#if !defined SNMP_COMMUNITY_WRITE || defined __DOXYGEN__ +#define SNMP_COMMUNITY_WRITE "private" +#endif + +/** + * The snmp community used for sending traps. + */ +#if !defined SNMP_COMMUNITY_TRAP || defined __DOXYGEN__ +#define SNMP_COMMUNITY_TRAP "public" +#endif + +/** + * The maximum length of community string. + * If community names shall be adjusted at runtime via snmp_set_community() calls, + * enter here the possible maximum length (+1 for terminating null character). + */ +#if !defined SNMP_MAX_COMMUNITY_STR_LEN || defined __DOXYGEN__ +#define SNMP_MAX_COMMUNITY_STR_LEN LWIP_MAX(LWIP_MAX(sizeof(SNMP_COMMUNITY), sizeof(SNMP_COMMUNITY_WRITE)), sizeof(SNMP_COMMUNITY_TRAP)) +#endif + +/** + * The OID identifiying the device. This may be the enterprise OID itself or any OID located below it in tree. + */ +#if !defined SNMP_DEVICE_ENTERPRISE_OID || defined __DOXYGEN__ +#define SNMP_LWIP_ENTERPRISE_OID 26381 +/** + * IANA assigned enterprise ID for lwIP is 26381 + * @see http://www.iana.org/assignments/enterprise-numbers + * + * @note this enterprise ID is assigned to the lwIP project, + * all object identifiers living under this ID are assigned + * by the lwIP maintainers! + * @note don't change this define, use snmp_set_device_enterprise_oid() + * + * If you need to create your own private MIB you'll need + * to apply for your own enterprise ID with IANA: + * http://www.iana.org/numbers.html + */ +#define SNMP_DEVICE_ENTERPRISE_OID {1, 3, 6, 1, 4, 1, SNMP_LWIP_ENTERPRISE_OID} +/** + * Length of SNMP_DEVICE_ENTERPRISE_OID + */ +#define SNMP_DEVICE_ENTERPRISE_OID_LEN 7 +#endif + +/** + * SNMP_DEBUG: Enable debugging for SNMP messages. + */ +#if !defined SNMP_DEBUG || defined __DOXYGEN__ +#define SNMP_DEBUG LWIP_DBG_OFF +#endif + +/** + * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs. + */ +#if !defined SNMP_MIB_DEBUG || defined __DOXYGEN__ +#define SNMP_MIB_DEBUG LWIP_DBG_OFF +#endif + +/** + * Indicates if the MIB2 implementation of LWIP SNMP stack is used. + */ +#if !defined SNMP_LWIP_MIB2 || defined __DOXYGEN__ +#define SNMP_LWIP_MIB2 LWIP_SNMP +#endif + +/** + * Value return for sysDesc field of MIB2. + */ +#if !defined SNMP_LWIP_MIB2_SYSDESC || defined __DOXYGEN__ +#define SNMP_LWIP_MIB2_SYSDESC "lwIP" +#endif + +/** + * Value return for sysName field of MIB2. + * To make sysName field settable, call snmp_mib2_set_sysname() to provide the necessary buffers. + */ +#if !defined SNMP_LWIP_MIB2_SYSNAME || defined __DOXYGEN__ +#define SNMP_LWIP_MIB2_SYSNAME "FQDN-unk" +#endif + +/** + * Value return for sysContact field of MIB2. + * To make sysContact field settable, call snmp_mib2_set_syscontact() to provide the necessary buffers. + */ +#if !defined SNMP_LWIP_MIB2_SYSCONTACT || defined __DOXYGEN__ +#define SNMP_LWIP_MIB2_SYSCONTACT "" +#endif + +/** + * Value return for sysLocation field of MIB2. + * To make sysLocation field settable, call snmp_mib2_set_syslocation() to provide the necessary buffers. + */ +#if !defined SNMP_LWIP_MIB2_SYSLOCATION || defined __DOXYGEN__ +#define SNMP_LWIP_MIB2_SYSLOCATION "" +#endif + +/** + * This value is used to limit the repetitions processed in GetBulk requests (value == 0 means no limitation). + * This may be useful to limit the load for a single request. + * According to SNMP RFC 1905 it is allowed to not return all requested variables from a GetBulk request if system load would be too high. + * so the effect is that the client will do more requests to gather all data. + * For the stack this could be useful in case that SNMP processing is done in TCP/IP thread. In this situation a request with many + * repetitions could block the thread for a longer time. Setting limit here will keep the stack more responsive. + */ +#if !defined SNMP_LWIP_GETBULK_MAX_REPETITIONS || defined __DOXYGEN__ +#define SNMP_LWIP_GETBULK_MAX_REPETITIONS 0 +#endif + +/** + * @} + */ + +/* + ------------------------------------ + ---------- SNMPv3 options ---------- + ------------------------------------ +*/ + +/** + * LWIP_SNMP_V3==1: This enables EXPERIMENTAL SNMPv3 support. LWIP_SNMP must + * also be enabled. + * THIS IS UNDER DEVELOPMENT AND SHOULD NOT BE ENABLED IN PRODUCTS. + */ +#ifndef LWIP_SNMP_V3 +#define LWIP_SNMP_V3 0 +#endif + +#ifndef LWIP_SNMP_V3_CRYPTO +#define LWIP_SNMP_V3_CRYPTO LWIP_SNMP_V3 +#endif + +#ifndef LWIP_SNMP_V3_MBEDTLS +#define LWIP_SNMP_V3_MBEDTLS LWIP_SNMP_V3 +#endif + +#endif /* LWIP_HDR_SNMP_OPTS_H */ diff --git a/sys/include/net/apps/snmp_scalar.h b/sys/include/net/apps/snmp_scalar.h index 40a060c..99bcdf9 100644 --- a/sys/include/net/apps/snmp_scalar.h +++ b/sys/include/net/apps/snmp_scalar.h @@ -1,113 +1,113 @@ -/** - * @file - * SNMP server MIB API to implement scalar nodes - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Martin Hentschel - * - */ - -#ifndef LWIP_HDR_APPS_SNMP_SCALAR_H -#define LWIP_HDR_APPS_SNMP_SCALAR_H - -#include "lwip/apps/snmp_opts.h" -#include "lwip/apps/snmp_core.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -/** basic scalar node */ -struct snmp_scalar_node -{ - /** inherited "base class" members */ - struct snmp_leaf_node node; - u8_t asn1_type; - snmp_access_t access; - node_instance_get_value_method get_value; - node_instance_set_test_method set_test; - node_instance_set_value_method set_value; -}; - - -snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -#define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \ - {{{ SNMP_NODE_SCALAR, (oid) }, \ - snmp_scalar_get_instance, \ - snmp_scalar_get_next_instance }, \ - (asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) } - -#define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL) - -/** scalar array node - a tree node which contains scalars only as children */ -struct snmp_scalar_array_node_def -{ - u32_t oid; - u8_t asn1_type; - snmp_access_t access; -}; - -typedef s16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*); -typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*); -typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*); - -/** basic scalar array node */ -struct snmp_scalar_array_node -{ - /** inherited "base class" members */ - struct snmp_leaf_node node; - u16_t array_node_count; - const struct snmp_scalar_array_node_def* array_nodes; - snmp_scalar_array_get_value_method get_value; - snmp_scalar_array_set_test_method set_test; - snmp_scalar_array_set_value_method set_value; -}; - -snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -#define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \ - {{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \ - snmp_scalar_array_get_instance, \ - snmp_scalar_array_get_next_instance }, \ - (u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) } - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */ +/** + * @file + * SNMP server MIB API to implement scalar nodes + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Martin Hentschel + * + */ + +#ifndef LWIP_HDR_APPS_SNMP_SCALAR_H +#define LWIP_HDR_APPS_SNMP_SCALAR_H + +#include "lwip/apps/snmp_opts.h" +#include "lwip/apps/snmp_core.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +/** basic scalar node */ +struct snmp_scalar_node +{ + /** inherited "base class" members */ + struct snmp_leaf_node node; + u8_t asn1_type; + snmp_access_t access; + node_instance_get_value_method get_value; + node_instance_set_test_method set_test; + node_instance_set_value_method set_value; +}; + + +snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); +snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); + +#define SNMP_SCALAR_CREATE_NODE(oid, access, asn1_type, get_value_method, set_test_method, set_value_method) \ + {{{ SNMP_NODE_SCALAR, (oid) }, \ + snmp_scalar_get_instance, \ + snmp_scalar_get_next_instance }, \ + (asn1_type), (access), (get_value_method), (set_test_method), (set_value_method) } + +#define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL) + +/** scalar array node - a tree node which contains scalars only as children */ +struct snmp_scalar_array_node_def +{ + u32_t oid; + u8_t asn1_type; + snmp_access_t access; +}; + +typedef s16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_array_node_def*, void*); +typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*); +typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*); + +/** basic scalar array node */ +struct snmp_scalar_array_node +{ + /** inherited "base class" members */ + struct snmp_leaf_node node; + u16_t array_node_count; + const struct snmp_scalar_array_node_def* array_nodes; + snmp_scalar_array_get_value_method get_value; + snmp_scalar_array_set_test_method set_test; + snmp_scalar_array_set_value_method set_value; +}; + +snmp_err_t snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); +snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); + +#define SNMP_SCALAR_CREATE_ARRAY_NODE(oid, array_nodes, get_value_method, set_test_method, set_value_method) \ + {{{ SNMP_NODE_SCALAR_ARRAY, (oid) }, \ + snmp_scalar_array_get_instance, \ + snmp_scalar_array_get_next_instance }, \ + (u16_t)LWIP_ARRAYSIZE(array_nodes), (array_nodes), (get_value_method), (set_test_method), (set_value_method) } + +#endif /* LWIP_SNMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_SNMP_SCALAR_H */ diff --git a/sys/include/net/apps/snmp_table.h b/sys/include/net/apps/snmp_table.h new file mode 100644 index 0000000..6930d0b --- /dev/null +++ b/sys/include/net/apps/snmp_table.h @@ -0,0 +1,134 @@ +/** + * @file + * SNMP server MIB API to implement table nodes + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Martin Hentschel + * + */ + +#ifndef LWIP_HDR_APPS_SNMP_TABLE_H +#define LWIP_HDR_APPS_SNMP_TABLE_H + +#include "lwip/apps/snmp_opts.h" +#include "lwip/apps/snmp_core.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +/** default (customizable) read/write table */ +struct snmp_table_col_def +{ + u32_t index; + u8_t asn1_type; + snmp_access_t access; +}; + +/** table node */ +struct snmp_table_node +{ + /** inherited "base class" members */ + struct snmp_leaf_node node; + u16_t column_count; + const struct snmp_table_col_def* columns; + snmp_err_t (*get_cell_instance)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, struct snmp_node_instance* cell_instance); + snmp_err_t (*get_next_cell_instance)(const u32_t* column, struct snmp_obj_id* row_oid, struct snmp_node_instance* cell_instance); + /** returns object value for the given object identifier */ + node_instance_get_value_method get_value; + /** tests length and/or range BEFORE setting */ + node_instance_set_test_method set_test; + /** sets object value, only called when set_test() was successful */ + node_instance_set_value_method set_value; +}; + +snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); +snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); + +#define SNMP_TABLE_CREATE(oid, columns, get_cell_instance_method, get_next_cell_instance_method, get_value_method, set_test_method, set_value_method) \ + {{{ SNMP_NODE_TABLE, (oid) }, \ + snmp_table_get_instance, \ + snmp_table_get_next_instance }, \ + (u16_t)LWIP_ARRAYSIZE(columns), (columns), \ + (get_cell_instance_method), (get_next_cell_instance_method), \ + (get_value_method), (set_test_method), (set_value_method)} + +#define SNMP_TABLE_GET_COLUMN_FROM_OID(oid) ((oid)[1]) /* first array value is (fixed) row entry (fixed to 1) and 2nd value is column, follow3ed by instance */ + + +/** simple read-only table */ +typedef enum { + SNMP_VARIANT_VALUE_TYPE_U32, + SNMP_VARIANT_VALUE_TYPE_S32, + SNMP_VARIANT_VALUE_TYPE_PTR, + SNMP_VARIANT_VALUE_TYPE_CONST_PTR +} snmp_table_column_data_type_t; + +struct snmp_table_simple_col_def +{ + u32_t index; + u8_t asn1_type; + snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/ +}; + +/** simple read-only table node */ +struct snmp_table_simple_node +{ + /* inherited "base class" members */ + struct snmp_leaf_node node; + u16_t column_count; + const struct snmp_table_simple_col_def* columns; + snmp_err_t (*get_cell_value)(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len); + snmp_err_t (*get_next_cell_instance_and_value)(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len); +}; + +snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); +snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); + +#define SNMP_TABLE_CREATE_SIMPLE(oid, columns, get_cell_value_method, get_next_cell_instance_and_value_method) \ + {{{ SNMP_NODE_TABLE, (oid) }, \ + snmp_table_simple_get_instance, \ + snmp_table_simple_get_next_instance }, \ + (u16_t)LWIP_ARRAYSIZE(columns), (columns), (get_cell_value_method), (get_next_cell_instance_and_value_method) } + +s16_t snmp_table_extract_value_from_s32ref(struct snmp_node_instance* instance, void* value); +s16_t snmp_table_extract_value_from_u32ref(struct snmp_node_instance* instance, void* value); +s16_t snmp_table_extract_value_from_refconstptr(struct snmp_node_instance* instance, void* value); + +#endif /* LWIP_SNMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_SNMP_TABLE_H */ diff --git a/sys/include/net/apps/snmp_threadsync.h b/sys/include/net/apps/snmp_threadsync.h index a25dbf2..5eb3538 100644 --- a/sys/include/net/apps/snmp_threadsync.h +++ b/sys/include/net/apps/snmp_threadsync.h @@ -1,114 +1,114 @@ -/** - * @file - * SNMP server MIB API to implement thread synchronization - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Dirk Ziegelmeier - * - */ - -#ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H -#define LWIP_HDR_APPS_SNMP_THREADSYNC_H - -#include "lwip/apps/snmp_opts.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/apps/snmp_core.h" -#include "lwip/sys.h" - -typedef void (*snmp_threadsync_called_fn)(void* arg); -typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg); - - -/** Thread sync runtime data. For internal usage only. */ -struct threadsync_data -{ - union { - snmp_err_t err; - s16_t s16; - } retval; - union { - const u32_t *root_oid; - void *value; - } arg1; - union { - u8_t root_oid_len; - u16_t len; - } arg2; - const struct snmp_threadsync_node *threadsync_node; - struct snmp_node_instance proxy_instance; -}; - -/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */ -struct snmp_threadsync_instance -{ - sys_sem_t sem; - sys_mutex_t sem_usage_mutex; - snmp_threadsync_synchronizer_fn sync_fn; - struct threadsync_data data; -}; - -/** SNMP thread sync proxy leaf node */ -struct snmp_threadsync_node -{ - /* inherited "base class" members */ - struct snmp_leaf_node node; - - const struct snmp_leaf_node *target; - struct snmp_threadsync_instance *instance; -}; - -snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); -snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); - -/** Create thread sync proxy node */ -#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \ - {{{ SNMP_NODE_THREADSYNC, (oid) }, \ - snmp_threadsync_get_instance, \ - snmp_threadsync_get_next_instance }, \ - (target_leaf_node), \ - (threadsync_instance) } - -/** Create thread sync instance data */ -void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn); - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */ +/** + * @file + * SNMP server MIB API to implement thread synchronization + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Dirk Ziegelmeier + * + */ + +#ifndef LWIP_HDR_APPS_SNMP_THREADSYNC_H +#define LWIP_HDR_APPS_SNMP_THREADSYNC_H + +#include "lwip/apps/snmp_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ + +#include "lwip/apps/snmp_core.h" +#include "lwip/sys.h" + +typedef void (*snmp_threadsync_called_fn)(void* arg); +typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg); + + +/** Thread sync runtime data. For internal usage only. */ +struct threadsync_data +{ + union { + snmp_err_t err; + s16_t s16; + } retval; + union { + const u32_t *root_oid; + void *value; + } arg1; + union { + u8_t root_oid_len; + u16_t len; + } arg2; + const struct snmp_threadsync_node *threadsync_node; + struct snmp_node_instance proxy_instance; +}; + +/** Thread sync instance. Needed EXCATLY once for every thread to be synced into. */ +struct snmp_threadsync_instance +{ + sys_sem_t sem; + sys_mutex_t sem_usage_mutex; + snmp_threadsync_synchronizer_fn sync_fn; + struct threadsync_data data; +}; + +/** SNMP thread sync proxy leaf node */ +struct snmp_threadsync_node +{ + /* inherited "base class" members */ + struct snmp_leaf_node node; + + const struct snmp_leaf_node *target; + struct snmp_threadsync_instance *instance; +}; + +snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); +snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance); + +/** Create thread sync proxy node */ +#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \ + {{{ SNMP_NODE_THREADSYNC, (oid) }, \ + snmp_threadsync_get_instance, \ + snmp_threadsync_get_next_instance }, \ + (target_leaf_node), \ + (threadsync_instance) } + +/** Create thread sync instance data */ +void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn); + +#endif /* LWIP_SNMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_SNMP_THREADSYNC_H */ diff --git a/sys/include/net/apps/snmpv3.h b/sys/include/net/apps/snmpv3.h new file mode 100644 index 0000000..99a7fd2 --- /dev/null +++ b/sys/include/net/apps/snmpv3.h @@ -0,0 +1,90 @@ +/** + * @file + * Additional SNMPv3 functionality RFC3414 and RFC3826. + */ + +/* + * Copyright (c) 2016 Elias Oenal. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Elias Oenal + */ + +#ifndef LWIP_HDR_APPS_SNMP_V3_H +#define LWIP_HDR_APPS_SNMP_V3_H + +#include "lwip/apps/snmp_opts.h" +#include "lwip/err.h" + +#if LWIP_SNMP && LWIP_SNMP_V3 + +#define SNMP_V3_AUTH_ALGO_INVAL 0 +#define SNMP_V3_AUTH_ALGO_MD5 1 +#define SNMP_V3_AUTH_ALGO_SHA 2 + +#define SNMP_V3_PRIV_ALGO_INVAL 0 +#define SNMP_V3_PRIV_ALGO_DES 1 +#define SNMP_V3_PRIV_ALGO_AES 2 + +#define SNMP_V3_PRIV_MODE_DECRYPT 0 +#define SNMP_V3_PRIV_MODE_ENCRYPT 1 + +/* + * The following callback functions must be implemented by the application. + * There is a dummy implementation in snmpv3_dummy.c. + */ + +void snmpv3_get_engine_id(const char **id, u8_t *len); +err_t snmpv3_set_engine_id(const char* id, u8_t len); + +u32_t snmpv3_get_engine_boots(void); +void snmpv3_set_engine_boots(u32_t boots); + +u32_t snmpv3_get_engine_time(void); +void snmpv3_reset_engine_time(void); + +err_t snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *priv_algo, u8_t *priv_key); + +/* The following functions are provided by the SNMPv3 agent */ + +void snmpv3_engine_id_changed(void); + +void snmpv3_password_to_key_md5( + const u8_t *password, /* IN */ + u8_t passwordlen, /* IN */ + const u8_t *engineID, /* IN - pointer to snmpEngineID */ + u8_t engineLength, /* IN - length of snmpEngineID */ + u8_t *key); /* OUT - pointer to caller 16-octet buffer */ + +void snmpv3_password_to_key_sha( + const u8_t *password, /* IN */ + u8_t passwordlen, /* IN */ + const u8_t *engineID, /* IN - pointer to snmpEngineID */ + u8_t engineLength, /* IN - length of snmpEngineID */ + u8_t *key); /* OUT - pointer to caller 20-octet buffer */ + +#endif + +#endif /* LWIP_HDR_APPS_SNMP_V3_H */ diff --git a/sys/include/net/apps/sntp.h b/sys/include/net/apps/sntp.h index 40df9cc..3910917 100644 --- a/sys/include/net/apps/sntp.h +++ b/sys/include/net/apps/sntp.h @@ -1,76 +1,76 @@ -/** - * @file - * SNTP client API - */ - -/* - * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Frédéric Bernon, Simon Goldschmidt - * - */ -#ifndef LWIP_HDR_APPS_SNTP_H -#define LWIP_HDR_APPS_SNTP_H - -#include "lwip/apps/sntp_opts.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* SNTP operating modes: default is to poll using unicast. - The mode has to be set before calling sntp_init(). */ -#define SNTP_OPMODE_POLL 0 -#define SNTP_OPMODE_LISTENONLY 1 -void sntp_setoperatingmode(u8_t operating_mode); -u8_t sntp_getoperatingmode(void); - -void sntp_init(void); -void sntp_stop(void); -u8_t sntp_enabled(void); - -void sntp_setserver(u8_t idx, const ip_addr_t *addr); -const ip_addr_t* sntp_getserver(u8_t idx); - -#if SNTP_SERVER_DNS -void sntp_setservername(u8_t idx, char *server); -char *sntp_getservername(u8_t idx); -#endif /* SNTP_SERVER_DNS */ - -#if SNTP_GET_SERVERS_FROM_DHCP -void sntp_servermode_dhcp(int set_servers_from_dhcp); -#else /* SNTP_GET_SERVERS_FROM_DHCP */ -#define sntp_servermode_dhcp(x) -#endif /* SNTP_GET_SERVERS_FROM_DHCP */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_APPS_SNTP_H */ +/** + * @file + * SNTP client API + */ + +/* + * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Frédéric Bernon, Simon Goldschmidt + * + */ +#ifndef LWIP_HDR_APPS_SNTP_H +#define LWIP_HDR_APPS_SNTP_H + +#include "lwip/apps/sntp_opts.h" +#include "lwip/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* SNTP operating modes: default is to poll using unicast. + The mode has to be set before calling sntp_init(). */ +#define SNTP_OPMODE_POLL 0 +#define SNTP_OPMODE_LISTENONLY 1 +void sntp_setoperatingmode(u8_t operating_mode); +u8_t sntp_getoperatingmode(void); + +void sntp_init(void); +void sntp_stop(void); +u8_t sntp_enabled(void); + +void sntp_setserver(u8_t idx, const ip_addr_t *addr); +const ip_addr_t* sntp_getserver(u8_t idx); + +#if SNTP_SERVER_DNS +void sntp_setservername(u8_t idx, char *server); +char *sntp_getservername(u8_t idx); +#endif /* SNTP_SERVER_DNS */ + +#if SNTP_GET_SERVERS_FROM_DHCP +void sntp_servermode_dhcp(int set_servers_from_dhcp); +#else /* SNTP_GET_SERVERS_FROM_DHCP */ +#define sntp_servermode_dhcp(x) +#endif /* SNTP_GET_SERVERS_FROM_DHCP */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_SNTP_H */ diff --git a/sys/include/net/apps/sntp_opts.h b/sys/include/net/apps/sntp_opts.h new file mode 100644 index 0000000..c28b864 --- /dev/null +++ b/sys/include/net/apps/sntp_opts.h @@ -0,0 +1,173 @@ +/** + * @file + * SNTP client options list + */ + +/* + * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Frédéric Bernon, Simon Goldschmidt + * + */ +#ifndef LWIP_HDR_APPS_SNTP_OPTS_H +#define LWIP_HDR_APPS_SNTP_OPTS_H + +#include "lwip/opt.h" + +/** + * @defgroup sntp_opts Options + * @ingroup sntp + * @{ + */ + +/** SNTP macro to change system time in seconds + * Define SNTP_SET_SYSTEM_TIME_US(sec, us) to set the time in microseconds instead of this one + * if you need the additional precision. + */ +#if !defined SNTP_SET_SYSTEM_TIME || defined __DOXYGEN__ +#define SNTP_SET_SYSTEM_TIME(sec) LWIP_UNUSED_ARG(sec) +#endif + +/** The maximum number of SNTP servers that can be set */ +#if !defined SNTP_MAX_SERVERS || defined __DOXYGEN__ +#define SNTP_MAX_SERVERS LWIP_DHCP_MAX_NTP_SERVERS +#endif + +/** Set this to 1 to implement the callback function called by dhcp when + * NTP servers are received. */ +#if !defined SNTP_GET_SERVERS_FROM_DHCP || defined __DOXYGEN__ +#define SNTP_GET_SERVERS_FROM_DHCP LWIP_DHCP_GET_NTP_SRV +#endif + +/** Set this to 1 to support DNS names (or IP address strings) to set sntp servers + * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: + * \#define SNTP_SERVER_ADDRESS "pool.ntp.org" + */ +#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__ +#define SNTP_SERVER_DNS 0 +#endif + +/** + * SNTP_DEBUG: Enable debugging for SNTP. + */ +#if !defined SNTP_DEBUG || defined __DOXYGEN__ +#define SNTP_DEBUG LWIP_DBG_OFF +#endif + +/** SNTP server port */ +#if !defined SNTP_PORT || defined __DOXYGEN__ +#define SNTP_PORT 123 +#endif + +/** Set this to 1 to allow config of SNTP server(s) by DNS name */ +#if !defined SNTP_SERVER_DNS || defined __DOXYGEN__ +#define SNTP_SERVER_DNS 0 +#endif + +/** Sanity check: + * Define this to + * - 0 to turn off sanity checks (default; smaller code) + * - >= 1 to check address and port of the response packet to ensure the + * response comes from the server we sent the request to. + * - >= 2 to check returned Originate Timestamp against Transmit Timestamp + * sent to the server (to ensure response to older request). + * - >= 3 @todo: discard reply if any of the LI, Stratum, or Transmit Timestamp + * fields is 0 or the Mode field is not 4 (unicast) or 5 (broadcast). + * - >= 4 @todo: to check that the Root Delay and Root Dispersion fields are each + * greater than or equal to 0 and less than infinity, where infinity is + * currently a cozy number like one second. This check avoids using a + * server whose synchronization source has expired for a very long time. + */ +#if !defined SNTP_CHECK_RESPONSE || defined __DOXYGEN__ +#define SNTP_CHECK_RESPONSE 0 +#endif + +/** According to the RFC, this shall be a random delay + * between 1 and 5 minutes (in milliseconds) to prevent load peaks. + * This can be defined to a random generation function, + * which must return the delay in milliseconds as u32_t. + * Turned off by default. + */ +#if !defined SNTP_STARTUP_DELAY || defined __DOXYGEN__ +#define SNTP_STARTUP_DELAY 0 +#endif + +/** If you want the startup delay to be a function, define this + * to a function (including the brackets) and define SNTP_STARTUP_DELAY to 1. + */ +#if !defined SNTP_STARTUP_DELAY_FUNC || defined __DOXYGEN__ +#define SNTP_STARTUP_DELAY_FUNC SNTP_STARTUP_DELAY +#endif + +/** SNTP receive timeout - in milliseconds + * Also used as retry timeout - this shouldn't be too low. + * Default is 3 seconds. + */ +#if !defined SNTP_RECV_TIMEOUT || defined __DOXYGEN__ +#define SNTP_RECV_TIMEOUT 3000 +#endif + +/** SNTP update delay - in milliseconds + * Default is 1 hour. Must not be beolw 15 seconds by specification (i.e. 15000) + */ +#if !defined SNTP_UPDATE_DELAY || defined __DOXYGEN__ +#define SNTP_UPDATE_DELAY 3600000 +#endif + +/** SNTP macro to get system time, used with SNTP_CHECK_RESPONSE >= 2 + * to send in request and compare in response. + */ +#if !defined SNTP_GET_SYSTEM_TIME || defined __DOXYGEN__ +#define SNTP_GET_SYSTEM_TIME(sec, us) do { (sec) = 0; (us) = 0; } while(0) +#endif + +/** Default retry timeout (in milliseconds) if the response + * received is invalid. + * This is doubled with each retry until SNTP_RETRY_TIMEOUT_MAX is reached. + */ +#if !defined SNTP_RETRY_TIMEOUT || defined __DOXYGEN__ +#define SNTP_RETRY_TIMEOUT SNTP_RECV_TIMEOUT +#endif + +/** Maximum retry timeout (in milliseconds). */ +#if !defined SNTP_RETRY_TIMEOUT_MAX || defined __DOXYGEN__ +#define SNTP_RETRY_TIMEOUT_MAX (SNTP_RETRY_TIMEOUT * 10) +#endif + +/** Increase retry timeout with every retry sent + * Default is on to conform to RFC. + */ +#if !defined SNTP_RETRY_TIMEOUT_EXP || defined __DOXYGEN__ +#define SNTP_RETRY_TIMEOUT_EXP 1 +#endif + +/** + * @} + */ + +#endif /* LWIP_HDR_APPS_SNTP_OPTS_H */ diff --git a/sys/include/net/apps/tftp_opts.h b/sys/include/net/apps/tftp_opts.h index 6968a80..bf115dc 100644 --- a/sys/include/net/apps/tftp_opts.h +++ b/sys/include/net/apps/tftp_opts.h @@ -1,105 +1,105 @@ -/****************************************************************//** - * - * @file tftp_opts.h - * - * @author Logan Gunthorpe - * - * @brief Trivial File Transfer Protocol (RFC 1350) implementation options - * - * Copyright (c) Deltatee Enterprises Ltd. 2013 - * All rights reserved. - * - ********************************************************************/ - -/* - * Redistribution and use in source and binary forms, with or without - * modification,are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Author: Logan Gunthorpe - * - */ - -#ifndef LWIP_HDR_APPS_TFTP_OPTS_H -#define LWIP_HDR_APPS_TFTP_OPTS_H - -#include "lwip/opt.h" - -/** - * @defgroup tftp_opts Options - * @ingroup tftp - * @{ - */ - -/** - * Enable TFTP debug messages - */ -#if !defined TFTP_DEBUG || defined __DOXYGEN__ -#define TFTP_DEBUG LWIP_DBG_ON -#endif - -/** - * TFTP server port - */ -#if !defined TFTP_PORT || defined __DOXYGEN__ -#define TFTP_PORT 69 -#endif - -/** - * TFTP timeout - */ -#if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__ -#define TFTP_TIMEOUT_MSECS 10000 -#endif - -/** - * Max. number of retries when a file is read from server - */ -#if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__ -#define TFTP_MAX_RETRIES 5 -#endif - -/** - * TFTP timer cyclic interval - */ -#if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__ -#define TFTP_TIMER_MSECS 50 -#endif - -/** - * Max. length of TFTP filename - */ -#if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__ -#define TFTP_MAX_FILENAME_LEN 20 -#endif - -/** - * Max. length of TFTP mode - */ -#if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__ -#define TFTP_MAX_MODE_LEN 7 -#endif - -/** - * @} - */ - -#endif /* LWIP_HDR_APPS_TFTP_OPTS_H */ +/****************************************************************//** + * + * @file tftp_opts.h + * + * @author Logan Gunthorpe + * + * @brief Trivial File Transfer Protocol (RFC 1350) implementation options + * + * Copyright (c) Deltatee Enterprises Ltd. 2013 + * All rights reserved. + * + ********************************************************************/ + +/* + * Redistribution and use in source and binary forms, with or without + * modification,are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Logan Gunthorpe + * + */ + +#ifndef LWIP_HDR_APPS_TFTP_OPTS_H +#define LWIP_HDR_APPS_TFTP_OPTS_H + +#include "lwip/opt.h" + +/** + * @defgroup tftp_opts Options + * @ingroup tftp + * @{ + */ + +/** + * Enable TFTP debug messages + */ +#if !defined TFTP_DEBUG || defined __DOXYGEN__ +#define TFTP_DEBUG LWIP_DBG_ON +#endif + +/** + * TFTP server port + */ +#if !defined TFTP_PORT || defined __DOXYGEN__ +#define TFTP_PORT 69 +#endif + +/** + * TFTP timeout + */ +#if !defined TFTP_TIMEOUT_MSECS || defined __DOXYGEN__ +#define TFTP_TIMEOUT_MSECS 10000 +#endif + +/** + * Max. number of retries when a file is read from server + */ +#if !defined TFTP_MAX_RETRIES || defined __DOXYGEN__ +#define TFTP_MAX_RETRIES 5 +#endif + +/** + * TFTP timer cyclic interval + */ +#if !defined TFTP_TIMER_MSECS || defined __DOXYGEN__ +#define TFTP_TIMER_MSECS 50 +#endif + +/** + * Max. length of TFTP filename + */ +#if !defined TFTP_MAX_FILENAME_LEN || defined __DOXYGEN__ +#define TFTP_MAX_FILENAME_LEN 20 +#endif + +/** + * Max. length of TFTP mode + */ +#if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__ +#define TFTP_MAX_MODE_LEN 7 +#endif + +/** + * @} + */ + +#endif /* LWIP_HDR_APPS_TFTP_OPTS_H */ diff --git a/sys/include/net/apps/tftp_server.h b/sys/include/net/apps/tftp_server.h new file mode 100644 index 0000000..1ad91dc --- /dev/null +++ b/sys/include/net/apps/tftp_server.h @@ -0,0 +1,94 @@ +/****************************************************************//** + * + * @file tftp_server.h + * + * @author Logan Gunthorpe + * + * @brief Trivial File Transfer Protocol (RFC 1350) + * + * Copyright (c) Deltatee Enterprises Ltd. 2013 + * All rights reserved. + * + ********************************************************************/ + +/* + * Redistribution and use in source and binary forms, with or without + * modification,are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Logan Gunthorpe + * + */ + +#ifndef LWIP_HDR_APPS_TFTP_SERVER_H +#define LWIP_HDR_APPS_TFTP_SERVER_H + +#include "lwip/apps/tftp_opts.h" +#include "lwip/err.h" +#include "lwip/pbuf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup tftp + * TFTP context containing callback functions for TFTP transfers + */ +struct tftp_context { + /** + * Open file for read/write. + * @param fname Filename + * @param mode Mode string from TFTP RFC 1350 (netascii, octet, mail) + * @param write Flag indicating read (0) or write (!= 0) access + * @returns File handle supplied to other functions + */ + void* (*open)(const char* fname, const char* mode, u8_t write); + /** + * Close file handle + * @param handle File handle returned by open() + */ + void (*close)(void* handle); + /** + * Read from file + * @param handle File handle returned by open() + * @param buf Target buffer to copy read data to + * @param bytes Number of bytes to copy to buf + * @returns >= 0: Success; < 0: Error + */ + int (*read)(void* handle, void* buf, int bytes); + /** + * Write to file + * @param handle File handle returned by open() + * @param pbuf PBUF adjusted such that payload pointer points + * to the beginning of write data. In other words, + * TFTP headers are stripped off. + * @returns >= 0: Success; < 0: Error + */ + int (*write)(void* handle, struct pbuf* p); +}; + +err_t tftp_init(const struct tftp_context* ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_APPS_TFTP_SERVER_H */ diff --git a/sys/include/net/arch/cpu.h b/sys/include/net/arch/cpu.h new file mode 100644 index 0000000..aba02eb --- /dev/null +++ b/sys/include/net/arch/cpu.h @@ -0,0 +1,8 @@ +#ifndef __ARCH_CPU_H__ +#define __ARCH_CPU_H__ + +#ifndef BYTE_ORDER +#define BYTE_ORDER LITTLE_ENDIAN +#endif /* BYTE_ORDER */ + +#endif diff --git a/sys/include/net/arch/init.h b/sys/include/net/arch/init.h new file mode 100644 index 0000000..3967942 --- /dev/null +++ b/sys/include/net/arch/init.h @@ -0,0 +1,6 @@ +#ifndef __ARCH_INIT_H__ +#define __ARCH_INIT_H__ + +#define TCPIP_INIT_DONE(arg) sys_sem_signal(*(sys_sem_t *)arg) + +#endif diff --git a/sys/include/net/arch/lib.h b/sys/include/net/arch/lib.h new file mode 100644 index 0000000..3f2385f --- /dev/null +++ b/sys/include/net/arch/lib.h @@ -0,0 +1,13 @@ +#ifndef __ARCH_LIB_H__ +#define __ARCH_LIB_H__ + +#ifndef _STRING_H_ +#ifndef _STRING_H +int strlen(const char *str); +int strncmp(const char *str1, const char *str2, int len); +void bcopy(const void *src, void *dest, int len); +void bzero(void *data, int n); +#endif /* _STRING_H */ +#endif /* _STRING_H_ */ + +#endif diff --git a/sys/include/net/arch/perf.h b/sys/include/net/arch/perf.h new file mode 100644 index 0000000..ab8135a --- /dev/null +++ b/sys/include/net/arch/perf.h @@ -0,0 +1,32 @@ +#ifndef __ARCH_PERF_H__ +#define __ARCH_PERF_H__ + +#include + +#ifdef PERF +#define PERF_START { \ + unsigned long __c1l, __c1h, __c2l, __c2h; \ + __asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h)) +#define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \ + perf_print(__c1l, __c1h, __c2l, __c2h, x);} + +/*#define PERF_START do { \ + struct tms __perf_start, __perf_end; \ + times(&__perf_start) +#define PERF_STOP(x) times(&__perf_end); \ + perf_print_times(&__perf_start, &__perf_end, x);\ + } while(0)*/ +#else /* PERF */ +#define PERF_START /* null definition */ +#define PERF_STOP(x) /* null definition */ +#endif /* PERF */ + +void perf_print(unsigned long c1l, unsigned long c1h, + unsigned long c2l, unsigned long c2h, + char *key); + +void perf_print_times(struct tms *start, struct tms *end, char *key); + +void perf_init(char *fname); + +#endif diff --git a/sys/include/net/autoip.h b/sys/include/net/autoip.h new file mode 100644 index 0000000..7899e40 --- /dev/null +++ b/sys/include/net/autoip.h @@ -0,0 +1,99 @@ +/** + * @file + * + * AutoIP Automatic LinkLocal IP Configuration + */ + +/* + * + * Copyright (c) 2007 Dominik Spies + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Dominik Spies + * + * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform + * with RFC 3927. + * + */ + +#ifndef LWIP_HDR_AUTOIP_H +#define LWIP_HDR_AUTOIP_H + +#include "net/opt.h" + +#if LWIP_IPV4 && LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ + +#include "net/netif.h" +/* #include "net/udp.h" */ +#include "net/etharp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** AutoIP Timing */ +#define AUTOIP_TMR_INTERVAL 100 +#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) + +/** AutoIP state information per netif */ +struct autoip +{ + /** the currently selected, probed, announced or used LL IP-Address */ + ip4_addr_t llipaddr; + /** current AutoIP state machine state */ + u8_t state; + /** sent number of probes or announces, dependent on state */ + u8_t sent_num; + /** ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ + u16_t ttw; + /** ticks until a conflict can be solved by defending */ + u8_t lastconflict; + /** total number of probed/used Link Local IP-Addresses */ + u8_t tried_llipaddr; +}; + + +void autoip_set_struct(struct netif *netif, struct autoip *autoip); +/** Remove a struct autoip previously set to the netif using autoip_set_struct() */ +#define autoip_remove_struct(netif) do { (netif)->autoip = NULL; } while (0) +err_t autoip_start(struct netif *netif); +err_t autoip_stop(struct netif *netif); +void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); +void autoip_tmr(void); +void autoip_network_changed(struct netif *netif); +u8_t autoip_supplied_address(const struct netif *netif); + +/* for lwIP internal use by ip4.c */ +u8_t autoip_accept_packet(struct netif *netif, const ip4_addr_t *addr); + +#define netif_autoip_data(netif) ((struct autoip*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP)) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV4 && LWIP_AUTOIP */ + +#endif /* LWIP_HDR_AUTOIP_H */ diff --git a/sys/include/net/debug.h b/sys/include/net/debug.h new file mode 100644 index 0000000..2244253 --- /dev/null +++ b/sys/include/net/debug.h @@ -0,0 +1,167 @@ +/** + * @file + * Debug messages infrastructure + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_DEBUG_H +#define LWIP_HDR_DEBUG_H + +#include +#include + +/** + * @defgroup debugging_levels LWIP_DBG_MIN_LEVEL and LWIP_DBG_TYPES_ON values + * @ingroup lwip_opts_debugmsg + * @{ + */ + +/** @name Debug level (LWIP_DBG_MIN_LEVEL) + * @{ + */ +/** Debug level: ALL messages*/ +#define LWIP_DBG_LEVEL_ALL 0x00 +/** Debug level: Warnings. bad checksums, dropped packets, ... */ +#define LWIP_DBG_LEVEL_WARNING 0x01 +/** Debug level: Serious. memory allocation failures, ... */ +#define LWIP_DBG_LEVEL_SERIOUS 0x02 +/** Debug level: Severe */ +#define LWIP_DBG_LEVEL_SEVERE 0x03 +/** + * @} + */ + +#define LWIP_DBG_MASK_LEVEL 0x03 +/* compatibility define only */ +#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL + +/** @name Enable/disable debug messages completely (LWIP_DBG_TYPES_ON) + * @{ + */ +/** flag for LWIP_DEBUGF to enable that debug message */ +#define LWIP_DBG_ON 0x80U +/** flag for LWIP_DEBUGF to disable that debug message */ +#define LWIP_DBG_OFF 0x00U +/** + * @} + */ + +/** @name Debug message types (LWIP_DBG_TYPES_ON) + * @{ + */ +/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ +#define LWIP_DBG_TRACE 0x40U +/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ +#define LWIP_DBG_STATE 0x20U +/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ +#define LWIP_DBG_FRESH 0x10U +/** flag for LWIP_DEBUGF to halt after printing this debug message */ +#define LWIP_DBG_HALT 0x08U +/** + * @} + */ + +/** + * @} + */ + +/** + * @defgroup lwip_assertions Assertion handling + * @ingroup lwip_opts_debug + * @{ + */ +/** + * LWIP_NOASSERT: Disable LWIP_ASSERT checks: + * To disable assertions define LWIP_NOASSERT in arch/cc.h. + */ +#ifdef __DOXYGEN__ +#define LWIP_NOASSERT +#undef LWIP_NOASSERT +#endif +/** + * @} + */ + +#ifndef LWIP_NOASSERT +#define LWIP_ASSERT(message, assertion) do { if (!(assertion)) { \ + LWIP_PLATFORM_ASSERT(message); }} while(0) +#ifndef LWIP_PLATFORM_ASSERT +#error "If you want to use LWIP_ASSERT, LWIP_PLATFORM_ASSERT(message) needs to be defined in your arch/cc.h" +#endif +#else /* LWIP_NOASSERT */ +#define LWIP_ASSERT(message, assertion) +#endif /* LWIP_NOASSERT */ + +#ifndef LWIP_ERROR +#ifndef LWIP_NOASSERT +#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message) +#elif defined LWIP_DEBUG +#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message)) +#else +#define LWIP_PLATFORM_ERROR(message) +#endif + +/* if "expression" isn't true, then print "message" and execute "handler" expression */ +#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ + LWIP_PLATFORM_ERROR(message); handler;}} while(0) +#endif /* LWIP_ERROR */ + +/** Enable debug message printing, but only if debug message type is enabled + * AND is of correct type AND is at least LWIP_DBG_LEVEL. + */ +#ifdef __DOXYGEN__ +#define LWIP_DEBUG +#undef LWIP_DEBUG +#endif + +#ifdef LWIP_DEBUG +#ifndef LWIP_PLATFORM_DIAG +#error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h" +#endif +#define LWIP_DEBUGF(debug, message) do { \ + if ( \ + ((debug) & LWIP_DBG_ON) && \ + ((debug) & LWIP_DBG_TYPES_ON) && \ + ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ + LWIP_PLATFORM_DIAG(message); \ + if ((debug) & LWIP_DBG_HALT) { \ + while(1); \ + } \ + } \ + } while(0) + +#else /* LWIP_DEBUG */ +#define LWIP_DEBUGF(debug, message) +#endif /* LWIP_DEBUG */ + +#endif /* LWIP_HDR_DEBUG_H */ diff --git a/sys/include/net/def.h b/sys/include/net/def.h new file mode 100644 index 0000000..cf33beb --- /dev/null +++ b/sys/include/net/def.h @@ -0,0 +1,141 @@ +/** + * @file + * various utility macros + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_DEF_H +#define LWIP_HDR_DEF_H + +/* arch.h might define NULL already */ +#include +#include +#if LWIP_PERF +#include +#else /* LWIP_PERF */ +#define PERF_START /* null definition */ +#define PERF_STOP(x) /* null definition */ +#endif /* LWIP_PERF */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) +#define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) + +/* Get the number of entries in an array ('x' must NOT be a pointer!) */ +#define LWIP_ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0])) + +/** Create u32_t value from bytes */ +#define LWIP_MAKEU32(a,b,c,d) (((u32_t)((a) & 0xff) << 24) | \ + ((u32_t)((b) & 0xff) << 16) | \ + ((u32_t)((c) & 0xff) << 8) | \ + (u32_t)((d) & 0xff)) + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#if BYTE_ORDER == BIG_ENDIAN +#define lwip_htons(x) (x) +#define lwip_ntohs(x) (x) +#define lwip_htonl(x) (x) +#define lwip_ntohl(x) (x) +#define PP_HTONS(x) (x) +#define PP_NTOHS(x) (x) +#define PP_HTONL(x) (x) +#define PP_NTOHL(x) (x) +#else /* BYTE_ORDER != BIG_ENDIAN */ +#ifndef lwip_htons +u16_t lwip_htons(u16_t x); +#endif +#define lwip_ntohs(x) lwip_htons(x) + +#ifndef lwip_htonl +u32_t lwip_htonl(u32_t x); +#endif +#define lwip_ntohl(x) lwip_htonl(x) + +/* These macros should be calculated by the preprocessor and are used + with compile-time constants only (so that there is no little-endian + overhead at runtime). */ +#define PP_HTONS(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8)) +#define PP_NTOHS(x) PP_HTONS(x) +#define PP_HTONL(x) ((((x) & 0x000000ffUL) << 24) | \ + (((x) & 0x0000ff00UL) << 8) | \ + (((x) & 0x00ff0000UL) >> 8) | \ + (((x) & 0xff000000UL) >> 24)) +#define PP_NTOHL(x) PP_HTONL(x) +#endif /* BYTE_ORDER == BIG_ENDIAN */ + +/* Provide usual function names as macros for users, but this can be turned off */ +#ifndef LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS +#define htons(x) lwip_htons(x) +#define ntohs(x) lwip_ntohs(x) +#define htonl(x) lwip_htonl(x) +#define ntohl(x) lwip_ntohl(x) +#endif + +/* Functions that are not available as standard implementations. + * In cc.h, you can #define these to implementations available on + * your platform to save some code bytes if you use these functions + * in your application, too. + */ + +#ifndef lwip_itoa +/* This can be #defined to itoa() or snprintf(result, bufsize, "%d", number) depending on your platform */ +void lwip_itoa(char* result, size_t bufsize, int number); +#endif +#ifndef lwip_strnicmp +/* This can be #defined to strnicmp() or strncasecmp() depending on your platform */ +int lwip_strnicmp(const char* str1, const char* str2, size_t len); +#endif +#ifndef lwip_stricmp +/* This can be #defined to stricmp() or strcasecmp() depending on your platform */ +int lwip_stricmp(const char* str1, const char* str2); +#endif +#ifndef lwip_strnstr +/* This can be #defined to strnstr() depending on your platform */ +char* lwip_strnstr(const char* buffer, const char* token, size_t n); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_DEF_H */ diff --git a/sys/include/net/dhcp.h b/sys/include/net/dhcp.h new file mode 100644 index 0000000..9f972b7 --- /dev/null +++ b/sys/include/net/dhcp.h @@ -0,0 +1,143 @@ +/** + * @file + * DHCP client API + */ + +/* + * Copyright (c) 2001-2004 Leon Woestenberg + * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Leon Woestenberg + * + */ +#ifndef LWIP_HDR_DHCP_H +#define LWIP_HDR_DHCP_H + +#include "net/opt.h" + +#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ + +#include "net/netif.h" +#include "net/udp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** period (in seconds) of the application calling dhcp_coarse_tmr() */ +#define DHCP_COARSE_TIMER_SECS 60 +/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ +#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) +/** period (in milliseconds) of the application calling dhcp_fine_tmr() */ +#define DHCP_FINE_TIMER_MSECS 500 + +#define DHCP_BOOT_FILE_LEN 128U + +/* AutoIP cooperation flags (struct dhcp.autoip_coop_state) */ +typedef enum { + DHCP_AUTOIP_COOP_STATE_OFF = 0, + DHCP_AUTOIP_COOP_STATE_ON = 1 +} dhcp_autoip_coop_state_enum_t; + +struct dhcp +{ + /** transaction identifier of last sent request */ + u32_t xid; + /** incoming msg */ + struct dhcp_msg *msg_in; + /** track PCB allocation state */ + u8_t pcb_allocated; + /** current DHCP state machine state */ + u8_t state; + /** retries of current request */ + u8_t tries; +#if LWIP_DHCP_AUTOIP_COOP + u8_t autoip_coop_state; +#endif + u8_t subnet_mask_given; + + struct pbuf *p_out; /* pbuf of outcoming msg */ + struct dhcp_msg *msg_out; /* outgoing msg */ + u16_t options_out_len; /* outgoing msg options length */ + u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ + u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ + u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ + u16_t t1_renew_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next renew try */ + u16_t t2_rebind_time; /* #ticks with period DHCP_COARSE_TIMER_SECS until next rebind try */ + u16_t lease_used; /* #ticks with period DHCP_COARSE_TIMER_SECS since last received DHCP ack */ + u16_t t0_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for lease time */ + ip_addr_t server_ip_addr; /* dhcp server address that offered this lease (ip_addr_t because passed to UDP) */ + ip4_addr_t offered_ip_addr; + ip4_addr_t offered_sn_mask; + ip4_addr_t offered_gw_addr; + + u32_t offered_t0_lease; /* lease period (in seconds) */ + u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ + u32_t offered_t2_rebind; /* recommended rebind time (usually 87.5 of lease period) */ +#if LWIP_DHCP_BOOTP_FILE + ip4_addr_t offered_si_addr; + char boot_file_name[DHCP_BOOT_FILE_LEN]; +#endif /* LWIP_DHCP_BOOTPFILE */ +}; + + +void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); +/** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */ +#define dhcp_remove_struct(netif) netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, NULL) +void dhcp_cleanup(struct netif *netif); +err_t dhcp_start(struct netif *netif); +err_t dhcp_renew(struct netif *netif); +err_t dhcp_release(struct netif *netif); +void dhcp_stop(struct netif *netif); +void dhcp_inform(struct netif *netif); +void dhcp_network_changed(struct netif *netif); +#if DHCP_DOES_ARP_CHECK +void dhcp_arp_reply(struct netif *netif, const ip4_addr_t *addr); +#endif +u8_t dhcp_supplied_address(const struct netif *netif); +/* to be called every minute */ +void dhcp_coarse_tmr(void); +/* to be called every half second */ +void dhcp_fine_tmr(void); + +#if LWIP_DHCP_GET_NTP_SRV +/** This function must exist, in other to add offered NTP servers to + * the NTP (or SNTP) engine. + * See LWIP_DHCP_MAX_NTP_SERVERS */ +extern void dhcp_set_ntp_servers(u8_t num_ntp_servers, const ip4_addr_t* ntp_server_addrs); +#endif /* LWIP_DHCP_GET_NTP_SRV */ + +#define netif_dhcp_data(netif) ((struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP)) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_DHCP */ + +#endif /*LWIP_HDR_DHCP_H*/ diff --git a/sys/include/net/dns.h b/sys/include/net/dns.h new file mode 100644 index 0000000..e09d812 --- /dev/null +++ b/sys/include/net/dns.h @@ -0,0 +1,130 @@ +/** + * @file + * DNS API + */ + +/** + * lwip DNS resolver header file. + + * Author: Jim Pettinato + * April 2007 + + * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef LWIP_HDR_DNS_H +#define LWIP_HDR_DNS_H + +#include "net/opt.h" + +#if LWIP_DNS + +#include "net/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** DNS timer period */ +#define DNS_TMR_INTERVAL 1000 + +/* DNS resolve types: */ +#define LWIP_DNS_ADDRTYPE_IPV4 0 +#define LWIP_DNS_ADDRTYPE_IPV6 1 +#define LWIP_DNS_ADDRTYPE_IPV4_IPV6 2 /* try to resolve IPv4 first, try IPv6 if IPv4 fails only */ +#define LWIP_DNS_ADDRTYPE_IPV6_IPV4 3 /* try to resolve IPv6 first, try IPv4 if IPv6 fails only */ +#if LWIP_IPV4 && LWIP_IPV6 +#ifndef LWIP_DNS_ADDRTYPE_DEFAULT +#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4_IPV6 +#endif +#elif LWIP_IPV4 +#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV4 +#else +#define LWIP_DNS_ADDRTYPE_DEFAULT LWIP_DNS_ADDRTYPE_IPV6 +#endif + +#if DNS_LOCAL_HOSTLIST +/** struct used for local host-list */ +struct local_hostlist_entry { + /** static hostname */ + const char *name; + /** static host address in network byteorder */ + ip_addr_t addr; + struct local_hostlist_entry *next; +}; +#define DNS_LOCAL_HOSTLIST_ELEM(name, addr_init) {name, addr_init, NULL} +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC +#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN +#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH +#endif +#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ +#endif /* DNS_LOCAL_HOSTLIST */ + +#if LWIP_IPV4 +extern const ip_addr_t dns_mquery_v4group; +#endif /* LWIP_IPV4 */ +#if LWIP_IPV6 +extern const ip_addr_t dns_mquery_v6group; +#endif /* LWIP_IPV6 */ + +/** Callback which is invoked when a hostname is found. + * A function of this type must be implemented by the application using the DNS resolver. + * @param name pointer to the name that was looked up. + * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, + * or NULL if the name could not be found (or on any other error). + * @param callback_arg a user-specified callback argument passed to dns_gethostbyname +*/ +typedef void (*dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg); + +void dns_init(void); +void dns_tmr(void); +void dns_setserver(u8_t numdns, const ip_addr_t *dnsserver); +const ip_addr_t* dns_getserver(u8_t numdns); +err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, + dns_found_callback found, void *callback_arg); +err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr, + dns_found_callback found, void *callback_arg, + u8_t dns_addrtype); + + +#if DNS_LOCAL_HOSTLIST +size_t dns_local_iterate(dns_found_callback iterator_fn, void *iterator_arg); +err_t dns_local_lookup(const char *hostname, ip_addr_t *addr, u8_t dns_addrtype); +#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC +int dns_local_removehost(const char *hostname, const ip_addr_t *addr); +err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); +#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ +#endif /* DNS_LOCAL_HOSTLIST */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_DNS */ + +#endif /* LWIP_HDR_DNS_H */ diff --git a/sys/include/net/err.h b/sys/include/net/err.h new file mode 100644 index 0000000..fc982bb --- /dev/null +++ b/sys/include/net/err.h @@ -0,0 +1,119 @@ +/** + * @file + * lwIP Error codes + */ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_ERR_H +#define LWIP_HDR_ERR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup infrastructure_errors Error codes + * @ingroup infrastructure + * @{ + */ + +/** Define LWIP_ERR_T in cc.h if you want to use + * a different type for your platform (must be signed). */ +#ifdef LWIP_ERR_T +typedef LWIP_ERR_T err_t; +#else /* LWIP_ERR_T */ +typedef s8_t err_t; +#endif /* LWIP_ERR_T*/ + +/** Definitions for error constants. */ +typedef enum { +/** No error, everything OK. */ + ERR_OK = 0, +/** Out of memory error. */ + ERR_MEM = -1, +/** Buffer error. */ + ERR_BUF = -2, +/** Timeout. */ + ERR_TIMEOUT = -3, +/** Routing problem. */ + ERR_RTE = -4, +/** Operation in progress */ + ERR_INPROGRESS = -5, +/** Illegal value. */ + ERR_VAL = -6, +/** Operation would block. */ + ERR_WOULDBLOCK = -7, +/** Address in use. */ + ERR_USE = -8, +/** Already connecting. */ + ERR_ALREADY = -9, +/** Conn already established.*/ + ERR_ISCONN = -10, +/** Not connected. */ + ERR_CONN = -11, +/** Low-level netif error */ + ERR_IF = -12, + +/** Connection aborted. */ + ERR_ABRT = -13, +/** Connection reset. */ + ERR_RST = -14, +/** Connection closed. */ + ERR_CLSD = -15, +/** Illegal argument. */ + ERR_ARG = -16 +} err_enum_t; + +#define ERR_IS_FATAL(e) ((e) <= ERR_ABRT) + +/** + * @} + */ + +#ifdef LWIP_DEBUG +extern const char *lwip_strerr(err_t err); +#else +#define lwip_strerr(x) "" +#endif /* LWIP_DEBUG */ + +#if !NO_SYS +int err_to_errno(err_t err); +#endif /* !NO_SYS */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_ERR_H */ diff --git a/sys/include/net/errno.h b/sys/include/net/errno.h new file mode 100644 index 0000000..1ee024d --- /dev/null +++ b/sys/include/net/errno.h @@ -0,0 +1,193 @@ +/** + * @file + * Posix Errno defines + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_ERRNO_H +#define LWIP_HDR_ERRNO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LWIP_PROVIDE_ERRNO + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ + +#ifndef errno +extern int errno; +#endif + +#else /* LWIP_PROVIDE_ERRNO */ + +/* Define LWIP_ERRNO_INCLUDE to to include the error defines here */ +#ifdef LWIP_ERRNO_INCLUDE +#include LWIP_ERRNO_INCLUDE +#endif /* LWIP_ERRNO_INCLUDE */ + +#endif /* LWIP_PROVIDE_ERRNO */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_ERRNO_H */ diff --git a/sys/include/net/ethip6.h b/sys/include/net/ethip6.h new file mode 100644 index 0000000..f2d0dfd --- /dev/null +++ b/sys/include/net/ethip6.h @@ -0,0 +1,68 @@ +/** + * @file + * + * Ethernet output for IPv6. Uses ND tables for link-layer addressing. + */ + +/* + * Copyright (c) 2010 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * + * Please coordinate changes and requests with Ivan Delamer + * + */ + +#ifndef LWIP_HDR_ETHIP6_H +#define LWIP_HDR_ETHIP6_H + +#include "net/opt.h" + +#if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ + +#include "net/pbuf.h" +#include "net/ip6.h" +#include "net/ip6_addr.h" +#include "net/netif.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +err_t ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV6 && LWIP_ETHERNET */ + +#endif /* LWIP_HDR_ETHIP6_H */ diff --git a/sys/include/net/icmp.h b/sys/include/net/icmp.h new file mode 100644 index 0000000..844a611 --- /dev/null +++ b/sys/include/net/icmp.h @@ -0,0 +1,110 @@ +/** + * @file + * ICMP API + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_ICMP_H +#define LWIP_HDR_ICMP_H + +#include "net/opt.h" +#include "net/pbuf.h" +#include "net/ip_addr.h" +#include "net/netif.h" +#include "net/prot/icmp.h" + +#if LWIP_IPV6 && LWIP_ICMP6 +#include "net/icmp6.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** ICMP destination unreachable codes */ +enum icmp_dur_type { + /** net unreachable */ + ICMP_DUR_NET = 0, + /** host unreachable */ + ICMP_DUR_HOST = 1, + /** protocol unreachable */ + ICMP_DUR_PROTO = 2, + /** port unreachable */ + ICMP_DUR_PORT = 3, + /** fragmentation needed and DF set */ + ICMP_DUR_FRAG = 4, + /** source route failed */ + ICMP_DUR_SR = 5 +}; + +/** ICMP time exceeded codes */ +enum icmp_te_type { + /** time to live exceeded in transit */ + ICMP_TE_TTL = 0, + /** fragment reassembly time exceeded */ + ICMP_TE_FRAG = 1 +}; + +#if LWIP_IPV4 && LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ + +void icmp_input(struct pbuf *p, struct netif *inp); +void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); +void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); + +#endif /* LWIP_IPV4 && LWIP_ICMP */ + +#if LWIP_IPV4 && LWIP_IPV6 +#if LWIP_ICMP && LWIP_ICMP6 +#define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \ + icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \ + icmp_dest_unreach(pbuf, ICMP_DUR_PORT)) +#elif LWIP_ICMP +#define icmp_port_unreach(isipv6, pbuf) do{ if(!(isipv6)) { icmp_dest_unreach(pbuf, ICMP_DUR_PORT);}}while(0) +#elif LWIP_ICMP6 +#define icmp_port_unreach(isipv6, pbuf) do{ if(isipv6) { icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT);}}while(0) +#else +#define icmp_port_unreach(isipv6, pbuf) +#endif +#elif LWIP_IPV6 && LWIP_ICMP6 +#define icmp_port_unreach(isipv6, pbuf) icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) +#elif LWIP_IPV4 && LWIP_ICMP +#define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT) +#else /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) */ +#define icmp_port_unreach(isipv6, pbuf) +#endif /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) LWIP_IPV4*/ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_ICMP_H */ diff --git a/sys/include/net/inet_chksum.h b/sys/include/net/inet_chksum.h new file mode 100644 index 0000000..a00ab6d --- /dev/null +++ b/sys/include/net/inet_chksum.h @@ -0,0 +1,105 @@ +/** + * @file + * IP checksum calculation functions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_INET_CHKSUM_H +#define LWIP_HDR_INET_CHKSUM_H + +#include "net/opt.h" + +#include "net/pbuf.h" +#include "net/ip_addr.h" + +/** Swap the bytes in an u16_t: much like lwip_htons() for little-endian */ +#ifndef SWAP_BYTES_IN_WORD +#define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) +#endif /* SWAP_BYTES_IN_WORD */ + +/** Split an u32_t in two u16_ts and add them up */ +#ifndef FOLD_U32T +#define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) +#endif + +#if LWIP_CHECKSUM_ON_COPY +/** Function-like macro: same as MEMCPY but returns the checksum of copied data + as u16_t */ +# ifndef LWIP_CHKSUM_COPY +# define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) +# ifndef LWIP_CHKSUM_COPY_ALGORITHM +# define LWIP_CHKSUM_COPY_ALGORITHM 1 +# endif /* LWIP_CHKSUM_COPY_ALGORITHM */ +# else /* LWIP_CHKSUM_COPY */ +# define LWIP_CHKSUM_COPY_ALGORITHM 0 +# endif /* LWIP_CHKSUM_COPY */ +#else /* LWIP_CHECKSUM_ON_COPY */ +# define LWIP_CHKSUM_COPY_ALGORITHM 0 +#endif /* LWIP_CHECKSUM_ON_COPY */ + +#ifdef __cplusplus +extern "C" { +#endif + +u16_t inet_chksum(const void *dataptr, u16_t len); +u16_t inet_chksum_pbuf(struct pbuf *p); +#if LWIP_CHKSUM_COPY_ALGORITHM +u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); +#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ + +#if LWIP_IPV4 +u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, + const ip4_addr_t *src, const ip4_addr_t *dest); +u16_t inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, + u16_t proto_len, u16_t chksum_len, const ip4_addr_t *src, const ip4_addr_t *dest); +#endif /* LWIP_IPV4 */ + +#if LWIP_IPV6 +u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, + const ip6_addr_t *src, const ip6_addr_t *dest); +u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, + u16_t chksum_len, const ip6_addr_t *src, const ip6_addr_t *dest); +#endif /* LWIP_IPV6 */ + + +u16_t ip_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, + const ip_addr_t *src, const ip_addr_t *dest); +u16_t ip_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, + u16_t chksum_len, const ip_addr_t *src, const ip_addr_t *dest); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_INET_H */ + diff --git a/sys/include/net/init.h b/sys/include/net/init.h new file mode 100644 index 0000000..11a57d8 --- /dev/null +++ b/sys/include/net/init.h @@ -0,0 +1,100 @@ +/** + * @file + * lwIP initialization API + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_INIT_H +#define LWIP_HDR_INIT_H + +#include "net/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup lwip_version Version + * @ingroup lwip + * @{ + */ + +/** X.x.x: Major version of the stack */ +#define LWIP_VERSION_MAJOR 2 +/** x.X.x: Minor version of the stack */ +#define LWIP_VERSION_MINOR 0 +/** x.x.X: Revision of the stack */ +#define LWIP_VERSION_REVISION 3 +/** For release candidates, this is set to 1..254 + * For official releases, this is set to 255 (LWIP_RC_RELEASE) + * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ +#define LWIP_VERSION_RC LWIP_RC_RELEASE + +/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ +#define LWIP_RC_RELEASE 255 +/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions */ +#define LWIP_RC_DEVELOPMENT 0 + +#define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) +#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) +#define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) + +/* Some helper defines to get a version string */ +#define LWIP_VERSTR2(x) #x +#define LWIP_VERSTR(x) LWIP_VERSTR2(x) +#if LWIP_VERSION_IS_RELEASE +#define LWIP_VERSION_STRING_SUFFIX "" +#elif LWIP_VERSION_IS_DEVELOPMENT +#define LWIP_VERSION_STRING_SUFFIX "d" +#else +#define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) +#endif + +/** Provides the version of the stack */ +#define LWIP_VERSION (((u32_t)LWIP_VERSION_MAJOR) << 24 | ((u32_t)LWIP_VERSION_MINOR) << 16 | \ + ((u32_t)LWIP_VERSION_REVISION) << 8 | ((u32_t)LWIP_VERSION_RC)) +/** Provides the version of the stack as string */ +#define LWIP_VERSION_STRING LWIP_VERSTR(LWIP_VERSION_MAJOR) "." LWIP_VERSTR(LWIP_VERSION_MINOR) "." LWIP_VERSTR(LWIP_VERSION_REVISION) LWIP_VERSION_STRING_SUFFIX + +/** + * @} + */ + +/* Modules initialization */ +void lwip_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_INIT_H */ diff --git a/sys/include/net/ip4_addr.h b/sys/include/net/ip4_addr.h new file mode 100644 index 0000000..52d3c96 --- /dev/null +++ b/sys/include/net/ip4_addr.h @@ -0,0 +1,227 @@ +/** + * @file + * IPv4 address API + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_IP4_ADDR_H +#define LWIP_HDR_IP4_ADDR_H + +#include +#include + +#if LWIP_IPV4 + +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the aligned version of ip4_addr_t, + used as local variable, on the stack, etc. */ +struct ip4_addr { + u32_t addr; +}; + +/** ip4_addr_t uses a struct for convenience only, so that the same defines can + * operate both on ip4_addr_t as well as on ip4_addr_p_t. */ +typedef struct ip4_addr ip4_addr_t; + +/** + * struct ipaddr2 is used in the definition of the ARP packet format in + * order to support compilers that don't have structure packing. + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip4_addr2 { + PACK_STRUCT_FIELD(u16_t addrw[2]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* Forward declaration to not include netif.h */ +struct netif; + +/** 255.255.255.255 */ +#define IPADDR_NONE ((u32_t)0xffffffffUL) +/** 127.0.0.1 */ +#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) +/** 0.0.0.0 */ +#define IPADDR_ANY ((u32_t)0x00000000UL) +/** 255.255.255.255 */ +#define IPADDR_BROADCAST ((u32_t)0xffffffffUL) + +/* Definitions of the bits in an Internet address integer. + + On subnets, host and network parts are found according to + the subnet mask, not these masks. */ +#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) +#define IP_CLASSA_NET 0xff000000 +#define IP_CLASSA_NSHIFT 24 +#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) +#define IP_CLASSA_MAX 128 + +#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) +#define IP_CLASSB_NET 0xffff0000 +#define IP_CLASSB_NSHIFT 16 +#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET) +#define IP_CLASSB_MAX 65536 + +#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) +#define IP_CLASSC_NET 0xffffff00 +#define IP_CLASSC_NSHIFT 8 +#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET) + +#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) +#define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */ +#define IP_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */ +#define IP_MULTICAST(a) IP_CLASSD(a) + +#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) +#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) + +#define IP_LOOPBACKNET 127 /* official! */ + +/** Set an IP address given by the four byte-parts */ +#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) + +/** MEMCPY-like copying of IP addresses where addresses are known to be + * 16-bit-aligned if the port is correctly configured (so a port could define + * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ +#ifndef IPADDR2_COPY +#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip4_addr_t)) +#endif + +/** Copy IP address - faster than ip4_addr_set: no NULL check */ +#define ip4_addr_copy(dest, src) ((dest).addr = (src).addr) +/** Safely copy one IP address to another (src may be NULL) */ +#define ip4_addr_set(dest, src) ((dest)->addr = \ + ((src) == NULL ? 0 : \ + (src)->addr)) +/** Set complete address to zero */ +#define ip4_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) +/** Set address to IPADDR_ANY (no need for lwip_htonl()) */ +#define ip4_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) +/** Set address to loopback address */ +#define ip4_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) +/** Check if an address is in the loopback region */ +#define ip4_addr_isloopback(ipaddr) (((ipaddr)->addr & PP_HTONL(IP_CLASSA_NET)) == PP_HTONL(((u32_t)IP_LOOPBACKNET) << 24)) +/** Safely copy one IP address to another and change byte order + * from host- to network-order. */ +#define ip4_addr_set_hton(dest, src) ((dest)->addr = \ + ((src) == NULL ? 0:\ + lwip_htonl((src)->addr))) +/** IPv4 only: set the IP address given as an u32_t */ +#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) +/** IPv4 only: get the IP address as an u32_t */ +#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) + +/** Get the network address by combining host address with netmask */ +#define ip4_addr_get_network(target, host, netmask) do { ((target)->addr = ((host)->addr) & ((netmask)->addr)); } while(0) + +/** + * Determine if two address are on the same network. + * + * @arg addr1 IP address 1 + * @arg addr2 IP address 2 + * @arg mask network identifier mask + * @return !0 if the network identifiers of both address match + */ +#define ip4_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ + (mask)->addr) == \ + ((addr2)->addr & \ + (mask)->addr)) +#define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) + +#define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY) +#define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1))) + +#define ip4_addr_isbroadcast(addr1, netif) ip4_addr_isbroadcast_u32((addr1)->addr, netif) +u8_t ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif); + +#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr) +u8_t ip4_addr_netmask_valid(u32_t netmask); + +#define ip4_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL)) + +#define ip4_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) + +#define ip4_addr_debug_print_parts(debug, a, b, c, d) \ + LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d)) +#define ip4_addr_debug_print(debug, ipaddr) \ + ip4_addr_debug_print_parts(debug, \ + (u16_t)((ipaddr) != NULL ? ip4_addr1_16(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? ip4_addr2_16(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? ip4_addr3_16(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? ip4_addr4_16(ipaddr) : 0)) +#define ip4_addr_debug_print_val(debug, ipaddr) \ + ip4_addr_debug_print_parts(debug, \ + ip4_addr1_16(&(ipaddr)), \ + ip4_addr2_16(&(ipaddr)), \ + ip4_addr3_16(&(ipaddr)), \ + ip4_addr4_16(&(ipaddr))) + +/* Get one byte from the 4-byte address */ +#define ip4_addr1(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[0]) +#define ip4_addr2(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[1]) +#define ip4_addr3(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[2]) +#define ip4_addr4(ipaddr) (((const u8_t*)(&(ipaddr)->addr))[3]) +/* These are cast to u16_t, with the intent that they are often arguments + * to printf using the U16_F format from cc.h. */ +#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) +#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) +#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) +#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) + +#define IP4ADDR_STRLEN_MAX 16 + +/** For backwards compatibility */ +#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) + +u32_t ipaddr_addr(const char *cp); +int ip4addr_aton(const char *cp, ip4_addr_t *addr); +/** returns ptr to static buffer; not reentrant! */ +char *ip4addr_ntoa(const ip4_addr_t *addr); +char *ip4addr_ntoa_r(const ip4_addr_t *addr, char *buf, int buflen); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV4 */ + +#endif /* LWIP_HDR_IP_ADDR_H */ diff --git a/sys/include/net/ip6.h b/sys/include/net/ip6.h new file mode 100644 index 0000000..acc6b4b --- /dev/null +++ b/sys/include/net/ip6.h @@ -0,0 +1,93 @@ +/** + * @file + * + * IPv6 layer. + */ + +/* + * Copyright (c) 2010 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * + * Please coordinate changes and requests with Ivan Delamer + * + */ +#ifndef LWIP_HDR_IP6_H +#define LWIP_HDR_IP6_H + +#include "net/opt.h" + +#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ + +#include "net/ip6_addr.h" +#include "net/prot/ip6.h" +#include "net/def.h" +#include "net/pbuf.h" +#include "net/netif.h" + +#include "net/err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest); +const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest); +err_t ip6_input(struct pbuf *p, struct netif *inp); +err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, + u8_t hl, u8_t tc, u8_t nexth); +err_t ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, + u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); +err_t ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, + u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); +#if LWIP_NETIF_HWADDRHINT +err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, + u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint); +#endif /* LWIP_NETIF_HWADDRHINT */ +#if LWIP_IPV6_MLD +err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value); +#endif /* LWIP_IPV6_MLD */ + +#define ip6_netif_get_local_ip(netif, dest) (((netif) != NULL) ? \ + ip6_select_source_address(netif, dest) : NULL) + +#if IP6_DEBUG +void ip6_debug_print(struct pbuf *p); +#else +#define ip6_debug_print(p) +#endif /* IP6_DEBUG */ + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV6 */ + +#endif /* LWIP_HDR_IP6_H */ diff --git a/sys/include/net/ip6_addr.h b/sys/include/net/ip6_addr.h new file mode 100644 index 0000000..845a60c --- /dev/null +++ b/sys/include/net/ip6_addr.h @@ -0,0 +1,285 @@ +/** + * @file + * + * IPv6 addresses. + */ + +/* + * Copyright (c) 2010 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * Structs and macros for handling IPv6 addresses. + * + * Please coordinate changes and requests with Ivan Delamer + * + */ +#ifndef LWIP_HDR_IP6_ADDR_H +#define LWIP_HDR_IP6_ADDR_H + +#include +#include + +#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** This is the aligned version of ip6_addr_t, + used as local variable, on the stack, etc. */ +struct ip6_addr { + u32_t addr[4]; +}; + +/** IPv6 address */ +typedef struct ip6_addr ip6_addr_t; + +/** Set an IPv6 partial address given by byte-parts */ +#define IP6_ADDR_PART(ip6addr, index, a,b,c,d) \ + (ip6addr)->addr[index] = PP_HTONL(LWIP_MAKEU32(a,b,c,d)) + +/** Set a full IPv6 address by passing the 4 u32_t indices in network byte order + (use PP_HTONL() for constants) */ +#define IP6_ADDR(ip6addr, idx0, idx1, idx2, idx3) do { \ + (ip6addr)->addr[0] = idx0; \ + (ip6addr)->addr[1] = idx1; \ + (ip6addr)->addr[2] = idx2; \ + (ip6addr)->addr[3] = idx3; } while(0) + +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[0])) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1]) >> 16) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[1])) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2]) >> 16) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[2])) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3]) >> 16) & 0xffff)) +/** Access address in 16-bit block */ +#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)((lwip_htonl((ip6addr)->addr[3])) & 0xffff)) + +/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */ +#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \ + (dest).addr[1] = (src).addr[1]; \ + (dest).addr[2] = (src).addr[2]; \ + (dest).addr[3] = (src).addr[3];}while(0) +/** Safely copy one IPv6 address to another (src may be NULL) */ +#define ip6_addr_set(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \ + (dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \ + (dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \ + (dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3];}while(0) + +/** Set complete address to zero */ +#define ip6_addr_set_zero(ip6addr) do{(ip6addr)->addr[0] = 0; \ + (ip6addr)->addr[1] = 0; \ + (ip6addr)->addr[2] = 0; \ + (ip6addr)->addr[3] = 0;}while(0) + +/** Set address to ipv6 'any' (no need for lwip_htonl()) */ +#define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr) +/** Set address to ipv6 loopback address */ +#define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \ + (ip6addr)->addr[1] = 0; \ + (ip6addr)->addr[2] = 0; \ + (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) +/** Safely copy one IPv6 address to another and change byte order + * from host- to network-order. */ +#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : lwip_htonl((src)->addr[0]); \ + (dest)->addr[1] = (src) == NULL ? 0 : lwip_htonl((src)->addr[1]); \ + (dest)->addr[2] = (src) == NULL ? 0 : lwip_htonl((src)->addr[2]); \ + (dest)->addr[3] = (src) == NULL ? 0 : lwip_htonl((src)->addr[3]);}while(0) + + +/** + * Determine if two IPv6 address are on the same network. + * + * @arg addr1 IPv6 address 1 + * @arg addr2 IPv6 address 2 + * @return !0 if the network identifiers of both address match + */ +#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ + ((addr1)->addr[1] == (addr2)->addr[1])) + +#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ + ((addr1)->addr[1] == (addr2)->addr[1]) && \ + ((addr1)->addr[2] == (addr2)->addr[2]) && \ + ((addr1)->addr[3] == (addr2)->addr[3])) + +#define ip6_get_subnet_id(ip6addr) (lwip_htonl((ip6addr)->addr[2]) & 0x0000ffffUL) + +#define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \ + ((ip6addr).addr[1] == 0) && \ + ((ip6addr).addr[2] == 0) && \ + ((ip6addr).addr[3] == 0)) +#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || ip6_addr_isany_val(*(ip6addr))) + +#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \ + ((ip6addr)->addr[1] == 0UL) && \ + ((ip6addr)->addr[2] == 0UL) && \ + ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) + +#define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL)) + +#define ip6_addr_islinklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfe800000UL)) + +#define ip6_addr_issitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfec00000UL)) + +#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL)) + +#define ip6_addr_isipv4mappedipv6(ip6addr) (((ip6addr)->addr[0] == 0) && ((ip6addr)->addr[1] == 0) && (((ip6addr)->addr[2]) == PP_HTONL(0x0000FFFFUL))) + +#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) +#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL)) +#define ip6_addr_multicast_prefix_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00200000UL)) +#define ip6_addr_multicast_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL)) +#define ip6_addr_multicast_scope(ip6addr) ((lwip_htonl((ip6addr)->addr[0]) >> 16) & 0xf) +#define IP6_MULTICAST_SCOPE_RESERVED 0x0 +#define IP6_MULTICAST_SCOPE_RESERVED0 0x0 +#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1 +#define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2 +#define IP6_MULTICAST_SCOPE_RESERVED3 0x3 +#define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4 +#define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5 +#define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8 +#define IP6_MULTICAST_SCOPE_GLOBAL 0xe +#define IP6_MULTICAST_SCOPE_RESERVEDF 0xf +#define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff010000UL)) +#define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff020000UL)) +#define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff040000UL)) +#define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff050000UL)) +#define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff080000UL)) +#define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff8f0000UL)) == PP_HTONL(0xff0e0000UL)) + +/* @todo define get/set for well-know multicast addresses, e.g. ff02::1 */ +#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \ + ((ip6addr)->addr[1] == 0UL) && \ + ((ip6addr)->addr[2] == 0UL) && \ + ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) + +#define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ + ((ip6addr)->addr[1] == 0UL) && \ + ((ip6addr)->addr[2] == 0UL) && \ + ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) +#define ip6_addr_set_allnodes_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ + (ip6addr)->addr[1] = 0; \ + (ip6addr)->addr[2] = 0; \ + (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) + +#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ + ((ip6addr)->addr[1] == 0UL) && \ + ((ip6addr)->addr[2] == 0UL) && \ + ((ip6addr)->addr[3] == PP_HTONL(0x00000002UL))) +#define ip6_addr_set_allrouters_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ + (ip6addr)->addr[1] = 0; \ + (ip6addr)->addr[2] = 0; \ + (ip6addr)->addr[3] = PP_HTONL(0x00000002UL);}while(0) + +#define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ + ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ + (((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) ) + +#define ip6_addr_set_solicitednode(ip6addr, if_id) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ + (ip6addr)->addr[1] = 0; \ + (ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \ + (ip6addr)->addr[3] = (PP_HTONL(0xff000000UL) | (if_id));}while(0) + +#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ + ((ip6addr)->addr[1] == 0) && \ + ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ + ((ip6addr)->addr[3] == (PP_HTONL(0xff000000UL) | (sn_addr)->addr[3]))) + +/* IPv6 address states. */ +#define IP6_ADDR_INVALID 0x00 +#define IP6_ADDR_TENTATIVE 0x08 +#define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */ +#define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */ +#define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */ +#define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */ +#define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */ +#define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */ +#define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */ +#define IP6_ADDR_VALID 0x10 /* This bit marks an address as valid (preferred or deprecated) */ +#define IP6_ADDR_PREFERRED 0x30 +#define IP6_ADDR_DEPRECATED 0x10 /* Same as VALID (valid but not preferred) */ + +#define IP6_ADDR_TENTATIVE_COUNT_MASK 0x07 /* 1-7 probes sent */ + +#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID) +#define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE) +#define ip6_addr_isvalid(addr_state) (addr_state & IP6_ADDR_VALID) /* Include valid, preferred, and deprecated. */ +#define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED) +#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED) + +#define ip6_addr_debug_print_parts(debug, a, b, c, d, e, f, g, h) \ + LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \ + a, b, c, d, e, f, g, h)) +#define ip6_addr_debug_print(debug, ipaddr) \ + ip6_addr_debug_print_parts(debug, \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0), \ + (u16_t)((ipaddr) != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)) +#define ip6_addr_debug_print_val(debug, ipaddr) \ + ip6_addr_debug_print_parts(debug, \ + IP6_ADDR_BLOCK1(&(ipaddr)), \ + IP6_ADDR_BLOCK2(&(ipaddr)), \ + IP6_ADDR_BLOCK3(&(ipaddr)), \ + IP6_ADDR_BLOCK4(&(ipaddr)), \ + IP6_ADDR_BLOCK5(&(ipaddr)), \ + IP6_ADDR_BLOCK6(&(ipaddr)), \ + IP6_ADDR_BLOCK7(&(ipaddr)), \ + IP6_ADDR_BLOCK8(&(ipaddr))) + +#define IP6ADDR_STRLEN_MAX 46 + +int ip6addr_aton(const char *cp, ip6_addr_t *addr); +/** returns ptr to static buffer; not reentrant! */ +char *ip6addr_ntoa(const ip6_addr_t *addr); +char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen); + + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV6 */ + +#endif /* LWIP_HDR_IP6_ADDR_H */ diff --git a/sys/include/net/ip6_frag.h b/sys/include/net/ip6_frag.h new file mode 100644 index 0000000..8e65edc --- /dev/null +++ b/sys/include/net/ip6_frag.h @@ -0,0 +1,120 @@ +/** + * @file + * + * IPv6 fragmentation and reassembly. + */ + +/* + * Copyright (c) 2010 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * + * Please coordinate changes and requests with Ivan Delamer + * + */ +#ifndef LWIP_HDR_IP6_FRAG_H +#define LWIP_HDR_IP6_FRAG_H + +#include "net/opt.h" +#include "net/pbuf.h" +#include "net/ip6_addr.h" +#include "net/ip6.h" +#include "net/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ + +/** IP6_FRAG_COPYHEADER==1: for platforms where sizeof(void*) > 4, this needs to + * be enabled (to not overwrite part of the data). When enabled, the IPv6 header + * is copied instead of referencing it, which gives more room for struct ip6_reass_helper */ +#ifndef IPV6_FRAG_COPYHEADER +#define IPV6_FRAG_COPYHEADER 0 +#endif + +/** The IPv6 reassembly timer interval in milliseconds. */ +#define IP6_REASS_TMR_INTERVAL 1000 + +/* Copy the complete header of the first fragment to struct ip6_reassdata + or just point to its original location in the first pbuf? */ +#if IPV6_FRAG_COPYHEADER +#define IPV6_FRAG_HDRPTR +#define IPV6_FRAG_HDRREF(hdr) (&(hdr)) +#else /* IPV6_FRAG_COPYHEADER */ +#define IPV6_FRAG_HDRPTR * +#define IPV6_FRAG_HDRREF(hdr) (hdr) +#endif /* IPV6_FRAG_COPYHEADER */ + +/** IPv6 reassembly helper struct. + * This is exported because memp needs to know the size. + */ +struct ip6_reassdata { + struct ip6_reassdata *next; + struct pbuf *p; + struct ip6_hdr IPV6_FRAG_HDRPTR iphdr; + u32_t identification; + u16_t datagram_len; + u8_t nexth; + u8_t timer; +}; + +#define ip6_reass_init() /* Compatibility define */ +void ip6_reass_tmr(void); +struct pbuf *ip6_reass(struct pbuf *p); + +#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ + +#if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */ + +#ifndef LWIP_PBUF_CUSTOM_REF_DEFINED +#define LWIP_PBUF_CUSTOM_REF_DEFINED +/** A custom pbuf that holds a reference to another pbuf, which is freed + * when this custom pbuf is freed. This is used to create a custom PBUF_REF + * that points into the original pbuf. */ +struct pbuf_custom_ref { + /** 'base class' */ + struct pbuf_custom pc; + /** pointer to the original pbuf that is referenced */ + struct pbuf *original; +}; +#endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ + +err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest); + +#endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_IP6_FRAG_H */ diff --git a/sys/include/net/ip_addr.h b/sys/include/net/ip_addr.h new file mode 100644 index 0000000..2abb791 --- /dev/null +++ b/sys/include/net/ip_addr.h @@ -0,0 +1,407 @@ +/** + * @file + * IP address API (common IPv4 and IPv6) + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_IP_ADDR_H +#define LWIP_HDR_IP_ADDR_H + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup ipaddr + * IP address types for use in ip_addr_t.type member. + * @see tcp_new_ip_type(), udp_new_ip_type(), raw_new_ip_type(). + */ +enum lwip_ip_addr_type { + /** IPv4 */ + IPADDR_TYPE_V4 = 0U, + /** IPv6 */ + IPADDR_TYPE_V6 = 6U, + /** IPv4+IPv6 ("dual-stack") */ + IPADDR_TYPE_ANY = 46U +}; + +#if LWIP_IPV4 && LWIP_IPV6 +/** + * @ingroup ipaddr + * A union struct for both IP version's addresses. + * ATTENTION: watch out for its size when adding IPv6 address scope! + */ +typedef struct ip_addr { + union { + ip6_addr_t ip6; + ip4_addr_t ip4; + } u_addr; + /** @ref lwip_ip_addr_type */ + u8_t type; +} ip_addr_t; + +extern const ip_addr_t ip_addr_any_type; + +/** @ingroup ip4addr */ +#define IPADDR4_INIT(u32val) { { { { u32val, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_V4 } +/** @ingroup ip4addr */ +#define IPADDR4_INIT_BYTES(a,b,c,d) IPADDR4_INIT(PP_HTONL(LWIP_MAKEU32(a,b,c,d))) +/** @ingroup ip6addr */ +#define IPADDR6_INIT(a, b, c, d) { { { { a, b, c, d } } }, IPADDR_TYPE_V6 } +/** @ingroup ip6addr */ +#define IPADDR6_INIT_HOST(a, b, c, d) { { { { PP_HTONL(a), PP_HTONL(b), PP_HTONL(c), PP_HTONL(d) } } }, IPADDR_TYPE_V6 } + +/** @ingroup ipaddr */ +#define IP_IS_ANY_TYPE_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_ANY) +/** @ingroup ipaddr */ +#define IPADDR_ANY_TYPE_INIT { { { { 0ul, 0ul, 0ul, 0ul } } }, IPADDR_TYPE_ANY } + +/** @ingroup ip4addr */ +#define IP_IS_V4_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V4) +/** @ingroup ip6addr */ +#define IP_IS_V6_VAL(ipaddr) (IP_GET_TYPE(&ipaddr) == IPADDR_TYPE_V6) +/** @ingroup ip4addr */ +#define IP_IS_V4(ipaddr) (((ipaddr) == NULL) || IP_IS_V4_VAL(*(ipaddr))) +/** @ingroup ip6addr */ +#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr))) + +#define IP_SET_TYPE_VAL(ipaddr, iptype) do { (ipaddr).type = (iptype); }while(0) +#define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0) +#define IP_GET_TYPE(ipaddr) ((ipaddr)->type) + +#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) (IP_GET_TYPE(&pcb->local_ip) == IP_GET_TYPE(ipaddr)) +#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (IP_IS_ANY_TYPE_VAL(pcb->local_ip) || IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr)) + +/** @ingroup ip6addr + * Convert generic ip address to specific protocol version + */ +#define ip_2_ip6(ipaddr) (&((ipaddr)->u_addr.ip6)) +/** @ingroup ip4addr + * Convert generic ip address to specific protocol version + */ +#define ip_2_ip4(ipaddr) (&((ipaddr)->u_addr.ip4)) + +/** @ingroup ip4addr */ +#define IP_ADDR4(ipaddr,a,b,c,d) do { IP4_ADDR(ip_2_ip4(ipaddr),a,b,c,d); \ + IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V4); } while(0) +/** @ingroup ip6addr */ +#define IP_ADDR6(ipaddr,i0,i1,i2,i3) do { IP6_ADDR(ip_2_ip6(ipaddr),i0,i1,i2,i3); \ + IP_SET_TYPE_VAL(*(ipaddr), IPADDR_TYPE_V6); } while(0) +/** @ingroup ip6addr */ +#define IP_ADDR6_HOST(ipaddr,i0,i1,i2,i3) IP_ADDR6(ipaddr,PP_HTONL(i0),PP_HTONL(i1),PP_HTONL(i2),PP_HTONL(i3)) + +/** @ingroup ipaddr */ +#define ip_addr_copy(dest, src) do{ IP_SET_TYPE_VAL(dest, IP_GET_TYPE(&src)); if(IP_IS_V6_VAL(src)){ \ + ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); }else{ \ + ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); }}while(0) +/** @ingroup ip6addr */ +#define ip_addr_copy_from_ip6(dest, src) do{ \ + ip6_addr_copy(*ip_2_ip6(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V6); }while(0) +/** @ingroup ip4addr */ +#define ip_addr_copy_from_ip4(dest, src) do{ \ + ip4_addr_copy(*ip_2_ip4(&(dest)), src); IP_SET_TYPE_VAL(dest, IPADDR_TYPE_V4); }while(0) +/** @ingroup ip4addr */ +#define ip_addr_set_ip4_u32(ipaddr, val) do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \ + IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0) +/** @ingroup ip4addr */ +#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && IP_IS_V4(ipaddr)) ? \ + ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0) +/** @ingroup ipaddr */ +#define ip_addr_set(dest, src) do{ IP_SET_TYPE(dest, IP_GET_TYPE(src)); if(IP_IS_V6(src)){ \ + ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); }else{ \ + ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); }}while(0) +/** @ingroup ipaddr */ +#define ip_addr_set_ipaddr(dest, src) ip_addr_set(dest, src) +/** @ingroup ipaddr */ +#define ip_addr_set_zero(ipaddr) do{ \ + ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); }while(0) +/** @ingroup ip5addr */ +#define ip_addr_set_zero_ip4(ipaddr) do{ \ + ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }while(0) +/** @ingroup ip6addr */ +#define ip_addr_set_zero_ip6(ipaddr) do{ \ + ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }while(0) +/** @ingroup ipaddr */ +#define ip_addr_set_any(is_ipv6, ipaddr) do{if(is_ipv6){ \ + ip6_addr_set_any(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }else{ \ + ip4_addr_set_any(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0) +/** @ingroup ipaddr */ +#define ip_addr_set_loopback(is_ipv6, ipaddr) do{if(is_ipv6){ \ + ip6_addr_set_loopback(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V6); }else{ \ + ip4_addr_set_loopback(ip_2_ip4(ipaddr)); IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0) +/** @ingroup ipaddr */ +#define ip_addr_set_hton(dest, src) do{if(IP_IS_V6(src)){ \ + ip6_addr_set_hton(ip_2_ip6(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \ + ip4_addr_set_hton(ip_2_ip4(ipaddr), (src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0) +/** @ingroup ipaddr */ +#define ip_addr_get_network(target, host, netmask) do{if(IP_IS_V6(host)){ \ + ip4_addr_set_zero(ip_2_ip4(target)); IP_SET_TYPE(target, IPADDR_TYPE_V6); } else { \ + ip4_addr_get_network(ip_2_ip4(target), ip_2_ip4(host), ip_2_ip4(netmask)); IP_SET_TYPE(target, IPADDR_TYPE_V4); }}while(0) +/** @ingroup ipaddr */ +#define ip_addr_netcmp(addr1, addr2, mask) ((IP_IS_V6(addr1) && IP_IS_V6(addr2)) ? \ + 0 : \ + ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask)) +/** @ingroup ipaddr */ +#define ip_addr_cmp(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \ + ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \ + ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2)))) +/** @ingroup ipaddr */ +#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \ + ip6_addr_isany(ip_2_ip6(ipaddr)) : \ + ip4_addr_isany(ip_2_ip4(ipaddr))) +/** @ingroup ipaddr */ +#define ip_addr_isany_val(ipaddr) ((IP_IS_V6_VAL(ipaddr)) ? \ + ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \ + ip4_addr_isany_val(*ip_2_ip4(&(ipaddr)))) +/** @ingroup ipaddr */ +#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \ + 0 : \ + ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif)) +/** @ingroup ipaddr */ +#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \ + ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \ + ip4_addr_ismulticast(ip_2_ip4(ipaddr))) +/** @ingroup ipaddr */ +#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \ + ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \ + ip4_addr_isloopback(ip_2_ip4(ipaddr))) +/** @ingroup ipaddr */ +#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \ + ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \ + ip4_addr_islinklocal(ip_2_ip4(ipaddr))) +#define ip_addr_debug_print(debug, ipaddr) do { if(IP_IS_V6(ipaddr)) { \ + ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); } else { \ + ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); }}while(0) +#define ip_addr_debug_print_val(debug, ipaddr) do { if(IP_IS_V6_VAL(ipaddr)) { \ + ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); } else { \ + ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); }}while(0) +/** @ingroup ipaddr */ +#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \ + ((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr)))) +/** @ingroup ipaddr */ +#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \ + ((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen))) +int ipaddr_aton(const char *cp, ip_addr_t *addr); + +/** @ingroup ipaddr */ +#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX + +/** @ingroup ipaddr */ +#define ip4_2_ipv4_mapped_ipv6(ip6addr, ip4addr) do { \ + (ip6addr)->addr[3] = (ip4addr)->addr; \ + (ip6addr)->addr[2] = PP_HTONL(0x0000FFFFUL); \ + (ip6addr)->addr[1] = 0; \ + (ip6addr)->addr[0] = 0; } while(0); + +/** @ingroup ipaddr */ +#define unmap_ipv4_mapped_ipv6(ip4addr, ip6addr) \ + (ip4addr)->addr = (ip6addr)->addr[3]; + +#define IP46_ADDR_ANY(type) (((type) == IPADDR_TYPE_V6)? IP6_ADDR_ANY : IP4_ADDR_ANY) + +#else /* LWIP_IPV4 && LWIP_IPV6 */ + +#define IP_ADDR_PCB_VERSION_MATCH(addr, pcb) 1 +#define IP_ADDR_PCB_VERSION_MATCH_EXACT(pcb, ipaddr) 1 + +#if LWIP_IPV4 + +typedef ip4_addr_t ip_addr_t; +#define IPADDR4_INIT(u32val) { u32val } +#define IPADDR4_INIT_BYTES(a,b,c,d) IPADDR4_INIT(PP_HTONL(LWIP_MAKEU32(a,b,c,d))) +#define IP_IS_V4_VAL(ipaddr) 1 +#define IP_IS_V6_VAL(ipaddr) 0 +#define IP_IS_V4(ipaddr) 1 +#define IP_IS_V6(ipaddr) 0 +#define IP_IS_ANY_TYPE_VAL(ipaddr) 0 +#define IP_SET_TYPE_VAL(ipaddr, iptype) +#define IP_SET_TYPE(ipaddr, iptype) +#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V4 +#define ip_2_ip4(ipaddr) (ipaddr) +#define IP_ADDR4(ipaddr,a,b,c,d) IP4_ADDR(ipaddr,a,b,c,d) + +#define ip_addr_copy(dest, src) ip4_addr_copy(dest, src) +#define ip_addr_copy_from_ip4(dest, src) ip4_addr_copy(dest, src) +#define ip_addr_set_ip4_u32(ipaddr, val) ip4_addr_set_u32(ip_2_ip4(ipaddr), val) +#define ip_addr_get_ip4_u32(ipaddr) ip4_addr_get_u32(ip_2_ip4(ipaddr)) +#define ip_addr_set(dest, src) ip4_addr_set(dest, src) +#define ip_addr_set_ipaddr(dest, src) ip4_addr_set(dest, src) +#define ip_addr_set_zero(ipaddr) ip4_addr_set_zero(ipaddr) +#define ip_addr_set_zero_ip4(ipaddr) ip4_addr_set_zero(ipaddr) +#define ip_addr_set_any(is_ipv6, ipaddr) ip4_addr_set_any(ipaddr) +#define ip_addr_set_loopback(is_ipv6, ipaddr) ip4_addr_set_loopback(ipaddr) +#define ip_addr_set_hton(dest, src) ip4_addr_set_hton(dest, src) +#define ip_addr_get_network(target, host, mask) ip4_addr_get_network(target, host, mask) +#define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_netcmp(addr1, addr2, mask) +#define ip_addr_cmp(addr1, addr2) ip4_addr_cmp(addr1, addr2) +#define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr) +#define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr) +#define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr) +#define ip_addr_islinklocal(ipaddr) ip4_addr_islinklocal(ipaddr) +#define ip_addr_isbroadcast(addr, netif) ip4_addr_isbroadcast(addr, netif) +#define ip_addr_ismulticast(ipaddr) ip4_addr_ismulticast(ipaddr) +#define ip_addr_debug_print(debug, ipaddr) ip4_addr_debug_print(debug, ipaddr) +#define ip_addr_debug_print_val(debug, ipaddr) ip4_addr_debug_print_val(debug, ipaddr) +#define ipaddr_ntoa(ipaddr) ip4addr_ntoa(ipaddr) +#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip4addr_ntoa_r(ipaddr, buf, buflen) +#define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr) + +#define IPADDR_STRLEN_MAX IP4ADDR_STRLEN_MAX + +#define IP46_ADDR_ANY(type) (IP4_ADDR_ANY) + +#else /* LWIP_IPV4 */ + +typedef ip6_addr_t ip_addr_t; +#define IPADDR6_INIT(a, b, c, d) { { a, b, c, d } } +#define IPADDR6_INIT_HOST(a, b, c, d) { { PP_HTONL(a), PP_HTONL(b), PP_HTONL(c), PP_HTONL(d) } } +#define IP_IS_V4_VAL(ipaddr) 0 +#define IP_IS_V6_VAL(ipaddr) 1 +#define IP_IS_V4(ipaddr) 0 +#define IP_IS_V6(ipaddr) 1 +#define IP_IS_ANY_TYPE_VAL(ipaddr) 0 +#define IP_SET_TYPE_VAL(ipaddr, iptype) +#define IP_SET_TYPE(ipaddr, iptype) +#define IP_GET_TYPE(ipaddr) IPADDR_TYPE_V6 +#define ip_2_ip6(ipaddr) (ipaddr) +#define IP_ADDR6(ipaddr,i0,i1,i2,i3) IP6_ADDR(ipaddr,i0,i1,i2,i3) +#define IP_ADDR6_HOST(ipaddr,i0,i1,i2,i3) IP_ADDR6(ipaddr,PP_HTONL(i0),PP_HTONL(i1),PP_HTONL(i2),PP_HTONL(i3)) + +#define ip_addr_copy(dest, src) ip6_addr_copy(dest, src) +#define ip_addr_copy_from_ip6(dest, src) ip6_addr_copy(dest, src) +#define ip_addr_set(dest, src) ip6_addr_set(dest, src) +#define ip_addr_set_ipaddr(dest, src) ip6_addr_set(dest, src) +#define ip_addr_set_zero(ipaddr) ip6_addr_set_zero(ipaddr) +#define ip_addr_set_zero_ip6(ipaddr) ip6_addr_set_zero(ipaddr) +#define ip_addr_set_any(is_ipv6, ipaddr) ip6_addr_set_any(ipaddr) +#define ip_addr_set_loopback(is_ipv6, ipaddr) ip6_addr_set_loopback(ipaddr) +#define ip_addr_set_hton(dest, src) ip6_addr_set_hton(dest, src) +#define ip_addr_get_network(target, host, mask) ip6_addr_set_zero(target) +#define ip_addr_netcmp(addr1, addr2, mask) 0 +#define ip_addr_cmp(addr1, addr2) ip6_addr_cmp(addr1, addr2) +#define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr) +#define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr) +#define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr) +#define ip_addr_islinklocal(ipaddr) ip6_addr_islinklocal(ipaddr) +#define ip_addr_isbroadcast(addr, netif) 0 +#define ip_addr_ismulticast(ipaddr) ip6_addr_ismulticast(ipaddr) +#define ip_addr_debug_print(debug, ipaddr) ip6_addr_debug_print(debug, ipaddr) +#define ip_addr_debug_print_val(debug, ipaddr) ip6_addr_debug_print_val(debug, ipaddr) +#define ipaddr_ntoa(ipaddr) ip6addr_ntoa(ipaddr) +#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip6addr_ntoa_r(ipaddr, buf, buflen) +#define ipaddr_aton(cp, addr) ip6addr_aton(cp, addr) + +#define IPADDR_STRLEN_MAX IP6ADDR_STRLEN_MAX + +#define IP46_ADDR_ANY(type) (IP6_ADDR_ANY) + +#endif /* LWIP_IPV4 */ +#endif /* LWIP_IPV4 && LWIP_IPV6 */ + +#if LWIP_IPV4 + +extern const ip_addr_t ip_addr_any; +extern const ip_addr_t ip_addr_broadcast; + +/** + * @ingroup ip4addr + * Can be used as a fixed/const ip_addr_t + * for the IP wildcard. + * Defined to @ref IP4_ADDR_ANY when IPv4 is enabled. + * Defined to @ref IP6_ADDR_ANY in IPv6 only systems. + * Use this if you can handle IPv4 _AND_ IPv6 addresses. + * Use @ref IP4_ADDR_ANY or @ref IP6_ADDR_ANY when the IP + * type matters. + */ +#define IP_ADDR_ANY IP4_ADDR_ANY +/** + * @ingroup ip4addr + * Can be used as a fixed/const ip_addr_t + * for the IPv4 wildcard and the broadcast address + */ +#define IP4_ADDR_ANY (&ip_addr_any) +/** + * @ingroup ip4addr + * Can be used as a fixed/const ip4_addr_t + * for the wildcard and the broadcast address + */ +#define IP4_ADDR_ANY4 (ip_2_ip4(&ip_addr_any)) + +/** @ingroup ip4addr */ +#define IP_ADDR_BROADCAST (&ip_addr_broadcast) +/** @ingroup ip4addr */ +#define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast)) + +#endif /* LWIP_IPV4*/ + +#if LWIP_IPV6 + +extern const ip_addr_t ip6_addr_any; + +/** + * @ingroup ip6addr + * IP6_ADDR_ANY can be used as a fixed ip_addr_t + * for the IPv6 wildcard address + */ +#define IP6_ADDR_ANY (&ip6_addr_any) +/** + * @ingroup ip6addr + * IP6_ADDR_ANY6 can be used as a fixed ip6_addr_t + * for the IPv6 wildcard address + */ +#define IP6_ADDR_ANY6 (ip_2_ip6(&ip6_addr_any)) + +#if !LWIP_IPV4 +/** IPv6-only configurations */ +#define IP_ADDR_ANY IP6_ADDR_ANY +#endif /* !LWIP_IPV4 */ + +#endif + +#if LWIP_IPV4 && LWIP_IPV6 +/** @ingroup ipaddr */ +#define IP_ANY_TYPE (&ip_addr_any_type) +#else +#define IP_ANY_TYPE IP_ADDR_ANY +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_IP_ADDR_H */ diff --git a/sys/include/net/lwipopts.h b/sys/include/net/lwipopts.h new file mode 100644 index 0000000..f648244 --- /dev/null +++ b/sys/include/net/lwipopts.h @@ -0,0 +1,497 @@ +/* + * Copyright (c) 2001-2003 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Simon Goldschmidt + * + */ + +#ifndef LWIP_HDR_LWIPOPTS_H +#define LWIP_HDR_LWIPOPTS_H + +/* NEVER Set To 1, 1 Will Remove OS Abstraction */ +#define NO_SYS 0 + +/* Timer Settings */ +#define LWIP_TIMERS 1 +#define LWIP_TIMERS_CUSTOM 0 + +#define MEMCPY(dst, src, len) memcpy(dst,src,len) +#define SMEMCPY(dst, src, len) memcpy(dst,src,len) + +/* Core locking and MPU */ +#define LWIP_MPU_COMPATIBLE 0 +#define LWIP_TCPIP_CORE_LOCKING 1 +#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 +#define SYS_LIGHTWEIGHT_PROT 0 + + +#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 +#define MEM_ALIGNMENT 1 +#define MEM_LIBC_MALLOC 0 +#define MEM_SIZE 1600 +#define MEM_USE_POOLS 0 +#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 + +#define MEMP_MEM_MALLOC 0 +#define MEMP_SANITY_CHECK 0 +#define MEMP_USE_CUSTOM_POOLS 0 +#define MEMP_OVERFLOW_CHECK 0 + +#define MEMP_NUM_API_MSG MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_ARP_QUEUE 30 +#define MEMP_NUM_DNS_API_MSG MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_FRAG_PBUF 15 +#define MEMP_NUM_IGMP_GROUP 8 +#define MEMP_NUM_LOCALHOSTLIST 1 +#define MEMP_NUM_NETBUF 2 +#define MEMP_NUM_NETCONN 4 +#define MEMP_NUM_NETDB 1 +#define MEMP_NUM_NETIFAPI_MSG MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_PBUF 16 +#define MEMP_NUM_RAW_PCB 4 +#define MEMP_NUM_REASSDATA 5 +#define MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA MEMP_NUM_TCPIP_MSG_API +#define MEMP_NUM_TCP_PCB 5 +#define MEMP_NUM_TCP_PCB_LISTEN 8 +#define MEMP_NUM_TCP_SEG 16 +#define MEMP_NUM_TCPIP_MSG_API 8 +#define MEMP_NUM_TCPIP_MSG_INPKT 8 +#define MEMP_NUM_UDP_PCB 4 +#define PBUF_POOL_SIZE 16 + +#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) + +#define LWIP_ARP 1 + +#define ARP_TABLE_SIZE 10 + +#define ARP_MAXAGE 300 + +#define ARP_QUEUEING 0 + +#define ARP_QUEUE_LEN 3 + +#define ETHARP_SUPPORT_VLAN 0 + +#define LWIP_ETHERNET LWIP_ARP + +#define ETH_PAD_SIZE 0 + +#define ETHARP_SUPPORT_STATIC_ENTRIES 0 + +#define ETHARP_TABLE_MATCH_NETIF 0 + +#define LWIP_IPV4 1 + +#define IP_FORWARD 0 + +#define IP_REASSEMBLY 1 + +#define IP_FRAG 1 + +#define IP_OPTIONS_ALLOWED 1 + +#define IP_REASS_MAXAGE 3 + +#define IP_REASS_MAX_PBUFS 10 + +#define IP_DEFAULT_TTL 255 + +#define IP_SOF_BROADCAST 0 + +#define IP_SOF_BROADCAST_RECV 0 + +#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0 + +#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0 + +#define LWIP_ICMP 1 + +#define ICMP_TTL (IP_DEFAULT_TTL) + +#define LWIP_BROADCAST_PING 1 + +#define LWIP_MULTICAST_PING 0 + +#define LWIP_RAW 1 + +#define RAW_TTL (IP_DEFAULT_TTL) + +#define LWIP_DHCP 0 +#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP)) +#define LWIP_DHCP_BOOTP_FILE 0 +#define LWIP_DHCP_GET_NTP_SRV 0 +#define LWIP_DHCP_MAX_NTP_SERVERS 1 +#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS +#define LWIP_AUTOIP 0 +#define LWIP_DHCP_AUTOIP_COOP 0 +#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 +#define LWIP_MIB2_CALLBACKS 0 +#define LWIP_IGMP 0 +#define LWIP_MULTICAST_TX_OPTIONS (LWIP_IGMP && LWIP_UDP) +#define LWIP_DNS 0 +#define DNS_TABLE_SIZE 4 +#define DNS_MAX_NAME_LENGTH 256 +#define DNS_MAX_SERVERS 2 +#define DNS_DOES_NAME_CHECK 1 +#define LWIP_DNS_SECURE (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) +#define DNS_LOCAL_HOSTLIST 0 +#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0 +#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0 +#define LWIP_UDP 1 +#define LWIP_UDPLITE 0 +#define UDP_TTL (IP_DEFAULT_TTL) +#define LWIP_NETBUF_RECVINFO 0 +#define LWIP_TCP 1 +#define TCP_TTL (IP_DEFAULT_TTL) +#define TCP_WND (4 * TCP_MSS) + +#define TCP_MAXRTX 12 + +#define TCP_SYNMAXRTX 6 + +#define TCP_QUEUE_OOSEQ (LWIP_TCP) + +#define TCP_MSS 536 + +#define TCP_CALCULATE_EFF_SEND_MSS 1 + +#define TCP_SND_BUF (2 * TCP_MSS) + +#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) + +#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) + +#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5) + +#define TCP_OOSEQ_MAX_BYTES 0 + +#define TCP_OOSEQ_MAX_PBUFS 0 + +#define TCP_LISTEN_BACKLOG 0 + +#define TCP_DEFAULT_LISTEN_BACKLOG 0xff + +#define TCP_OVERSIZE TCP_MSS + +#define LWIP_TCP_TIMESTAMPS 1 + +#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4)) + +#define LWIP_EVENT_API 0 +#define LWIP_WND_SCALE 0 + +#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) + +#define PBUF_LINK_ENCAPSULATION_HLEN 0u + +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS + 40 + PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN) + +#define LWIP_NETIF_HOSTNAME 0 + +#define LWIP_NETIF_API 0 + +#define LWIP_NETIF_STATUS_CALLBACK 0 + +#define LWIP_NETIF_LINK_CALLBACK 0 + +#define LWIP_NETIF_REMOVE_CALLBACK 0 + +#define LWIP_NETIF_HWADDRHINT 0 + +#define LWIP_NETIF_TX_SINGLE_PBUF 0 + +#define LWIP_NUM_NETIF_CLIENT_DATA 0 + +#define LWIP_HAVE_LOOPIF LWIP_NETIF_LOOPBACK + +#define LWIP_LOOPIF_MULTICAST 0 + +#define LWIP_NETIF_LOOPBACK 1 + +#define LWIP_LOOPBACK_MAX_PBUFS 0 + +#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) + +#define TCPIP_THREAD_NAME "tcpip_thread" + +#define TCPIP_THREAD_STACKSIZE 0 + +#define TCPIP_THREAD_PRIO 1 + +#define TCPIP_MBOX_SIZE 6 + +#define LWIP_TCPIP_THREAD_ALIVE() + +#define SLIPIF_THREAD_NAME "slipif_loop" + +#define SLIPIF_THREAD_STACKSIZE 0 + +#define SLIPIF_THREAD_PRIO 1 + +#define DEFAULT_THREAD_NAME "lwIP" + +#define DEFAULT_THREAD_STACKSIZE 0 + +#define DEFAULT_THREAD_PRIO 1 + +#define DEFAULT_RAW_RECVMBOX_SIZE 0 + +#define DEFAULT_UDP_RECVMBOX_SIZE 0 + +#define DEFAULT_TCP_RECVMBOX_SIZE 0 + +#define DEFAULT_ACCEPTMBOX_SIZE 0 + +#define LWIP_NETCONN 1 + +#define LWIP_TCPIP_TIMEOUT 1 + +#define LWIP_NETCONN_SEM_PER_THREAD 0 + +#define LWIP_NETCONN_FULLDUPLEX 0 + +#define LWIP_SOCKET 1 + +#define LWIP_COMPAT_SOCKETS 1 + +#define LWIP_POSIX_SOCKETS_IO_NAMES 1 + +#define LWIP_SOCKET_OFFSET 0 + +#define LWIP_TCP_KEEPALIVE 0 + +#define LWIP_SO_SNDTIMEO 1 + +#define LWIP_SO_RCVTIMEO 1 + +#define LWIP_SO_SNDRCVTIMEO_NONSTANDARD 0 + +#define LWIP_SO_RCVBUF 0 + +#define LWIP_SO_LINGER 0 + +#define RECV_BUFSIZE_DEFAULT INT_MAX + +#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000 + +#define SO_REUSE 0 + +#define SO_REUSE_RXTOALL 0 + +#define LWIP_FIONREAD_LINUXMODE 0 + +#define LWIP_STATS 1 + +#define LWIP_STATS_DISPLAY 0 + +#define LINK_STATS 1 + +#define ETHARP_STATS (LWIP_ARP) + +#define IP_STATS 1 + +#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG) + +#define ICMP_STATS 1 + +#define IGMP_STATS (LWIP_IGMP) + +#define UDP_STATS (LWIP_UDP) + +#define TCP_STATS (LWIP_TCP) + +#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0)) + +#define MEMP_STATS (MEMP_MEM_MALLOC == 0) + +#define SYS_STATS (NO_SYS == 0) + +#define IP6_STATS (LWIP_IPV6) + +#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6) + +#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS)) + +#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD) + +#define ND6_STATS (LWIP_IPV6) + +#define MIB2_STATS 0 + +#define LWIP_CHECKSUM_CTRL_PER_NETIF 0 + +#define CHECKSUM_GEN_IP 1 + +#define CHECKSUM_GEN_UDP 1 + +#define CHECKSUM_GEN_TCP 1 + +#define CHECKSUM_GEN_ICMP 1 + +#define CHECKSUM_GEN_ICMP6 1 + +#define CHECKSUM_CHECK_IP 1 +#define CHECKSUM_CHECK_UDP 1 + +#define CHECKSUM_CHECK_TCP 1 +#define CHECKSUM_CHECK_ICMP 1 +#define CHECKSUM_CHECK_ICMP6 1 +#define LWIP_CHECKSUM_ON_COPY 0 +#define LWIP_IPV6 0 +#define LWIP_IPV6_NUM_ADDRESSES 3 +#define LWIP_IPV6_FORWARD 0 +#define LWIP_IPV6_FRAG 0 +#define LWIP_IPV6_REASS (LWIP_IPV6) +#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1 +#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6) +#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1 +#define LWIP_ICMP6 (LWIP_IPV6) +#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_HL 255 +#define LWIP_IPV6_MLD (LWIP_IPV6) +#define MEMP_NUM_MLD6_GROUP 4 +#define LWIP_ND6_QUEUEING (LWIP_IPV6) +#define MEMP_NUM_ND6_QUEUE 20 +#define LWIP_ND6_NUM_NEIGHBORS 10 +#define LWIP_ND6_NUM_DESTINATIONS 10 +#define LWIP_ND6_NUM_PREFIXES 5 +#define LWIP_ND6_NUM_ROUTERS 3 +#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3 +#define LWIP_ND6_MAX_UNICAST_SOLICIT 3 +#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000 +#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3 +#define LWIP_ND6_REACHABLE_TIME 30000 +#define LWIP_ND6_RETRANS_TIMER 1000 + +#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000 + +#define LWIP_ND6_ALLOW_RA_UPDATES 1 + +#define LWIP_ND6_TCP_REACHABILITY_HINTS 1 + +#define LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 + +#define LWIP_IPV6_DHCP6 0 + +//#define LWIP_HOOK_FILENAME "path/to/my/lwip_hooks.h" + +//#define LWIP_HOOK_TCP_ISN(local_ip, local_port, remote_ip, remote_port) + +//#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif) + +//#define LWIP_HOOK_IP4_ROUTE() + +//#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src) + +//#define LWIP_HOOK_ETHARP_GET_GW(netif, dest) + +//#define LWIP_HOOK_IP6_INPUT(pbuf, input_netif) + +//#define LWIP_HOOK_IP6_ROUTE(src, dest) + +///#define LWIP_HOOK_ND6_GET_GW(netif, dest) + +//#define LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr) + +//#define LWIP_HOOK_VLAN_SET(netif, p, src, dst, eth_type) + +//#define LWIP_HOOK_MEMP_AVAILABLE(memp_t_type) + +//#define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif) + +#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL +#define LWIP_DBG_TYPES_ON LWIP_DBG_ON + +#define ETHARP_DEBUG LWIP_DBG_OFF + +#define NETIF_DEBUG LWIP_DBG_OFF + +#define PBUF_DEBUG LWIP_DBG_OFF + +#define API_LIB_DEBUG LWIP_DBG_OFF + +#define API_MSG_DEBUG LWIP_DBG_OFF + +#define SOCKETS_DEBUG LWIP_DBG_OFF + +#define ICMP_DEBUG LWIP_DBG_OFF + +#define IGMP_DEBUG LWIP_DBG_OFF + +#define INET_DEBUG LWIP_DBG_OFF + +#define IP_DEBUG LWIP_DBG_ON + +#define IP_REASS_DEBUG LWIP_DBG_OFF + +#define RAW_DEBUG LWIP_DBG_OFF + +#define MEM_DEBUG LWIP_DBG_OFF + +#define MEMP_DEBUG LWIP_DBG_OFF + +#define SYS_DEBUG LWIP_DBG_OFF + +#define TIMERS_DEBUG LWIP_DBG_OFF + +#define TCP_DEBUG LWIP_DBG_OFF + +#define TCP_INPUT_DEBUG LWIP_DBG_OFF + +#define TCP_FR_DEBUG LWIP_DBG_OFF + +#define TCP_RTO_DEBUG LWIP_DBG_OFF + +#define TCP_CWND_DEBUG LWIP_DBG_OFF + +#define TCP_WND_DEBUG LWIP_DBG_OFF + +#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF + +#define TCP_RST_DEBUG LWIP_DBG_OFF + +#define TCP_QLEN_DEBUG LWIP_DBG_OFF + +#define UDP_DEBUG LWIP_DBG_OFF +#define TCPIP_DEBUG LWIP_DBG_OFF +#define SLIP_DEBUG LWIP_DBG_OFF +#define DHCP_DEBUG LWIP_DBG_OFF +#define AUTOIP_DEBUG LWIP_DBG_OFF +#define DNS_DEBUG LWIP_DBG_OFF +#define IP6_DEBUG LWIP_DBG_OFF +#define LWIP_PERF 0 + +//#define TCP_RCV_SCALE 0 +//#define PBUF_POOL_SIZE 400 /* pbuf tests need ~200KByte */ +#define LWIP_COMPAT_MUTEX 0 +#define LWIP_COMPAT_MUTEX_ALLOWED 1 +#define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_CALLBACK_API 1 +#define LWIP_PROVIDE_ERRNO 1 +#endif diff --git a/sys/include/net/netifapi.h b/sys/include/net/netifapi.h new file mode 100644 index 0000000..82cb80e --- /dev/null +++ b/sys/include/net/netifapi.h @@ -0,0 +1,140 @@ +/** + * @file + * netif API (to be used from non-TCPIP threads) + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ +#ifndef LWIP_HDR_NETIFAPI_H +#define LWIP_HDR_NETIFAPI_H + +#include "net/opt.h" + +#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ + +#include "net/sys.h" +#include "net/netif.h" +#include "net/dhcp.h" +#include "net/autoip.h" +#include "net/priv/tcpip_priv.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_MPU_COMPATIBLE +#define NETIFAPI_IPADDR_DEF(type, m) type m +#else /* LWIP_MPU_COMPATIBLE */ +#define NETIFAPI_IPADDR_DEF(type, m) const type * m +#endif /* LWIP_MPU_COMPATIBLE */ + +typedef void (*netifapi_void_fn)(struct netif *netif); +typedef err_t (*netifapi_errt_fn)(struct netif *netif); + +struct netifapi_msg { + struct tcpip_api_call_data call; + struct netif *netif; + union { + struct { +#if LWIP_IPV4 + NETIFAPI_IPADDR_DEF(ip4_addr_t, ipaddr); + NETIFAPI_IPADDR_DEF(ip4_addr_t, netmask); + NETIFAPI_IPADDR_DEF(ip4_addr_t, gw); +#endif /* LWIP_IPV4 */ + void *state; + netif_init_fn init; + netif_input_fn input; + } add; + struct { + netifapi_void_fn voidfunc; + netifapi_errt_fn errtfunc; + } common; + } msg; +}; + + +/* API for application */ +err_t netifapi_netif_add(struct netif *netif, +#if LWIP_IPV4 + const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw, +#endif /* LWIP_IPV4 */ + void *state, netif_init_fn init, netif_input_fn input); + +#if LWIP_IPV4 +err_t netifapi_netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, + const ip4_addr_t *netmask, const ip4_addr_t *gw); +#endif /* LWIP_IPV4*/ + +err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc, + netifapi_errt_fn errtfunc); + +/** @ingroup netifapi_netif */ +#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) +/** @ingroup netifapi_netif */ +#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) +/** @ingroup netifapi_netif */ +#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) +/** @ingroup netifapi_netif */ +#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) +/** @ingroup netifapi_netif */ +#define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL) +/** @ingroup netifapi_netif */ +#define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL) + +/** + * @defgroup netifapi_dhcp4 DHCPv4 + * @ingroup netifapi + * To be called from non-TCPIP threads + */ +/** @ingroup netifapi_dhcp4 */ +#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) +/** @ingroup netifapi_dhcp4 */ +#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) +/** @ingroup netifapi_dhcp4 */ +#define netifapi_dhcp_inform(n) netifapi_netif_common(n, dhcp_inform, NULL) +/** @ingroup netifapi_dhcp4 */ +#define netifapi_dhcp_renew(n) netifapi_netif_common(n, NULL, dhcp_renew) +/** @ingroup netifapi_dhcp4 */ +#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL, dhcp_release) + +/** + * @defgroup netifapi_autoip AUTOIP + * @ingroup netifapi + * To be called from non-TCPIP threads + */ +/** @ingroup netifapi_autoip */ +#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) +/** @ingroup netifapi_autoip */ +#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETIF_API */ + +#endif /* LWIP_HDR_NETIFAPI_H */ diff --git a/sys/include/net/pbuf.h b/sys/include/net/pbuf.h new file mode 100644 index 0000000..850c0c5 --- /dev/null +++ b/sys/include/net/pbuf.h @@ -0,0 +1,263 @@ +/** + * @file + * pbuf API + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +#ifndef LWIP_HDR_PBUF_H +#define LWIP_HDR_PBUF_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** LWIP_SUPPORT_CUSTOM_PBUF==1: Custom pbufs behave much like their pbuf type + * but they are allocated by external code (initialised by calling + * pbuf_alloced_custom()) and when pbuf_free gives up their last reference, they + * are freed by calling pbuf_custom->custom_free_function(). + * Currently, the pbuf_custom code is only needed for one specific configuration + * of IP_FRAG, unless required by external driver/application code. */ +#ifndef LWIP_SUPPORT_CUSTOM_PBUF +#define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)) +#endif + +/* @todo: We need a mechanism to prevent wasting memory in every pbuf + (TCP vs. UDP, IPv4 vs. IPv6: UDP/IPv4 packets may waste up to 28 bytes) */ + +#define PBUF_TRANSPORT_HLEN 20 +#if LWIP_IPV6 +#define PBUF_IP_HLEN 40 +#else +#define PBUF_IP_HLEN 20 +#endif + +/** + * @ingroup pbuf + * Enumeration of pbuf layers + */ +typedef enum { + /** Includes spare room for transport layer header, e.g. UDP header. + * Use this if you intend to pass the pbuf to functions like udp_send(). + */ + PBUF_TRANSPORT, + /** Includes spare room for IP header. + * Use this if you intend to pass the pbuf to functions like raw_send(). + */ + PBUF_IP, + /** Includes spare room for link layer header (ethernet header). + * Use this if you intend to pass the pbuf to functions like ethernet_output(). + * @see PBUF_LINK_HLEN + */ + PBUF_LINK, + /** Includes spare room for additional encapsulation header before ethernet + * headers (e.g. 802.11). + * Use this if you intend to pass the pbuf to functions like netif->linkoutput(). + * @see PBUF_LINK_ENCAPSULATION_HLEN + */ + PBUF_RAW_TX, + /** Use this for input packets in a netif driver when calling netif->input() + * in the most common case - ethernet-layer netif driver. */ + PBUF_RAW +} pbuf_layer; + +/** + * @ingroup pbuf + * Enumeration of pbuf types + */ +typedef enum { + /** pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload + are allocated in one piece of contiguous memory (so the first payload byte + can be calculated from struct pbuf). + pbuf_alloc() allocates PBUF_RAM pbufs as unchained pbufs (although that might + change in future versions). + This should be used for all OUTGOING packets (TX).*/ + PBUF_RAM, + /** pbuf data is stored in ROM, i.e. struct pbuf and its payload are located in + totally different memory areas. Since it points to ROM, payload does not + have to be copied when queued for transmission. */ + PBUF_ROM, + /** pbuf comes from the pbuf pool. Much like PBUF_ROM but payload might change + so it has to be duplicated when queued before transmitting, depending on + who has a 'ref' to it. */ + PBUF_REF, + /** pbuf payload refers to RAM. This one comes from a pool and should be used + for RX. Payload can be chained (scatter-gather RX) but like PBUF_RAM, struct + pbuf and its payload are allocated in one piece of contiguous memory (so + the first payload byte can be calculated from struct pbuf). + Don't use this for TX, if the pool becomes empty e.g. because of TCP queuing, + you are unable to receive TCP acks! */ + PBUF_POOL +} pbuf_type; + + +/** indicates this packet's data should be immediately passed to the application */ +#define PBUF_FLAG_PUSH 0x01U +/** indicates this is a custom pbuf: pbuf_free calls pbuf_custom->custom_free_function() + when the last reference is released (plus custom PBUF_RAM cannot be trimmed) */ +#define PBUF_FLAG_IS_CUSTOM 0x02U +/** indicates this pbuf is UDP multicast to be looped back */ +#define PBUF_FLAG_MCASTLOOP 0x04U +/** indicates this pbuf was received as link-level broadcast */ +#define PBUF_FLAG_LLBCAST 0x08U +/** indicates this pbuf was received as link-level multicast */ +#define PBUF_FLAG_LLMCAST 0x10U +/** indicates this pbuf includes a TCP FIN flag */ +#define PBUF_FLAG_TCP_FIN 0x20U + +/** Main packet buffer struct */ +struct pbuf { + /** next pbuf in singly linked pbuf chain */ + struct pbuf *next; + + /** pointer to the actual data in the buffer */ + void *payload; + + /** + * total length of this buffer and all next buffers in chain + * belonging to the same packet. + * + * For non-queue packet chains this is the invariant: + * p->tot_len == p->len + (p->next? p->next->tot_len: 0) + */ + u16_t tot_len; + + /** length of this buffer */ + u16_t len; + + /** pbuf_type as u8_t instead of enum to save space */ + u8_t /*pbuf_type*/ type; + + /** misc flags */ + u8_t flags; + + /** + * the reference count always equals the number of pointers + * that refer to this pbuf. This can be pointers from an application, + * the stack itself, or pbuf->next pointers from a chain. + */ + u16_t ref; +}; + + +/** Helper struct for const-correctness only. + * The only meaning of this one is to provide a const payload pointer + * for PBUF_ROM type. + */ +struct pbuf_rom { + /** next pbuf in singly linked pbuf chain */ + struct pbuf *next; + + /** pointer to the actual data in the buffer */ + const void *payload; +}; + +#if LWIP_SUPPORT_CUSTOM_PBUF +/** Prototype for a function to free a custom pbuf */ +typedef void (*pbuf_free_custom_fn)(struct pbuf *p); + +/** A custom pbuf: like a pbuf, but following a function pointer to free it. */ +struct pbuf_custom { + /** The actual pbuf */ + struct pbuf pbuf; + /** This function is called when pbuf_free deallocates this pbuf(_custom) */ + pbuf_free_custom_fn custom_free_function; +}; +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ + +/** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */ +#ifndef PBUF_POOL_FREE_OOSEQ +#define PBUF_POOL_FREE_OOSEQ 1 +#endif /* PBUF_POOL_FREE_OOSEQ */ +#if LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ +extern volatile u8_t pbuf_free_ooseq_pending; +void pbuf_free_ooseq(void); +/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() + at regular intervals from main level to check if ooseq pbufs need to be + freed! */ +#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \ + /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \ + ooseq queued pbufs now */ \ + pbuf_free_ooseq(); }}while(0) +#else /* LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ */ + /* Otherwise declare an empty PBUF_CHECK_FREE_OOSEQ */ + #define PBUF_CHECK_FREE_OOSEQ() +#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ*/ + +/* Initializes the pbuf module. This call is empty for now, but may not be in future. */ +#define pbuf_init() + +struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); +#if LWIP_SUPPORT_CUSTOM_PBUF +struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, + struct pbuf_custom *p, void *payload_mem, + u16_t payload_mem_len); +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ +void pbuf_realloc(struct pbuf *p, u16_t size); +u8_t pbuf_header(struct pbuf *p, s16_t header_size); +u8_t pbuf_header_force(struct pbuf *p, s16_t header_size); +void pbuf_ref(struct pbuf *p); +u8_t pbuf_free(struct pbuf *p); +u16_t pbuf_clen(const struct pbuf *p); +void pbuf_cat(struct pbuf *head, struct pbuf *tail); +void pbuf_chain(struct pbuf *head, struct pbuf *tail); +struct pbuf *pbuf_dechain(struct pbuf *p); +err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); +u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); +err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); +err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset); +struct pbuf *pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset); +struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); +#if LWIP_CHECKSUM_ON_COPY +err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, + u16_t len, u16_t *chksum); +#endif /* LWIP_CHECKSUM_ON_COPY */ +#if LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE +void pbuf_split_64k(struct pbuf *p, struct pbuf **rest); +#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE */ + +u8_t pbuf_get_at(const struct pbuf* p, u16_t offset); +int pbuf_try_get_at(const struct pbuf* p, u16_t offset); +void pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data); +u16_t pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n); +u16_t pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset); +u16_t pbuf_strstr(const struct pbuf* p, const char* substr); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PBUF_H */ diff --git a/sys/include/net/priv/api_msg.h b/sys/include/net/priv/api_msg.h new file mode 100644 index 0000000..631379d --- /dev/null +++ b/sys/include/net/priv/api_msg.h @@ -0,0 +1,216 @@ +/** + * @file + * netconn API lwIP internal implementations (do not use in application code) + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_API_MSG_H +#define LWIP_HDR_API_MSG_H + +#include "net/opt.h" + +#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ +/* Note: Netconn API is always available when sockets are enabled - + * sockets are implemented on top of them */ + +#include "net/arch.h" +#include "net/ip_addr.h" +#include "net/err.h" +#include "net/sys.h" +#include "net/igmp.h" +#include "net/api.h" +#include "net/priv/tcpip_priv.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_MPU_COMPATIBLE +#if LWIP_NETCONN_SEM_PER_THREAD +#define API_MSG_M_DEF_SEM(m) *m +#else +#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m) +#endif +#else /* LWIP_MPU_COMPATIBLE */ +#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m) +#endif /* LWIP_MPU_COMPATIBLE */ + +/* For the netconn API, these values are use as a bitmask! */ +#define NETCONN_SHUT_RD 1 +#define NETCONN_SHUT_WR 2 +#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) + +/* IP addresses and port numbers are expected to be in + * the same byte order as in the corresponding pcb. + */ +/** This struct includes everything that is necessary to execute a function + for a netconn in another thread context (mainly used to process netconns + in the tcpip_thread context to be thread safe). */ +struct api_msg { + /** The netconn which to process - always needed: it includes the semaphore + which is used to block the application thread until the function finished. */ + struct netconn *conn; + /** The return value of the function executed in tcpip_thread. */ + err_t err; + /** Depending on the executed function, one of these union members is used */ + union { + /** used for lwip_netconn_do_send */ + struct netbuf *b; + /** used for lwip_netconn_do_newconn */ + struct { + u8_t proto; + } n; + /** used for lwip_netconn_do_bind and lwip_netconn_do_connect */ + struct { + API_MSG_M_DEF_C(ip_addr_t, ipaddr); + u16_t port; + } bc; + /** used for lwip_netconn_do_getaddr */ + struct { + ip_addr_t API_MSG_M_DEF(ipaddr); + u16_t API_MSG_M_DEF(port); + u8_t local; + } ad; + /** used for lwip_netconn_do_write */ + struct { + const void *dataptr; + size_t len; + u8_t apiflags; +#if LWIP_SO_SNDTIMEO + u32_t time_started; +#endif /* LWIP_SO_SNDTIMEO */ + } w; + /** used for lwip_netconn_do_recv */ + struct { + u32_t len; + } r; +#if LWIP_TCP + /** used for lwip_netconn_do_close (/shutdown) */ + struct { + u8_t shut; +#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER + u32_t time_started; +#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */ + u8_t polls_left; +#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */ + } sd; +#endif /* LWIP_TCP */ +#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) + /** used for lwip_netconn_do_join_leave_group */ + struct { + API_MSG_M_DEF_C(ip_addr_t, multiaddr); + API_MSG_M_DEF_C(ip_addr_t, netif_addr); + enum netconn_igmp join_or_leave; + } jl; +#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ +#if TCP_LISTEN_BACKLOG + struct { + u8_t backlog; + } lb; +#endif /* TCP_LISTEN_BACKLOG */ + } msg; +#if LWIP_NETCONN_SEM_PER_THREAD + sys_sem_t* op_completed_sem; +#endif /* LWIP_NETCONN_SEM_PER_THREAD */ +}; + +#if LWIP_NETCONN_SEM_PER_THREAD +#define LWIP_API_MSG_SEM(msg) ((msg)->op_completed_sem) +#else /* LWIP_NETCONN_SEM_PER_THREAD */ +#define LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed) +#endif /* LWIP_NETCONN_SEM_PER_THREAD */ + + +#if LWIP_DNS +/** As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn, + it has its own struct (to avoid struct api_msg getting bigger than necessary). + lwip_netconn_do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg + (see netconn_gethostbyname). */ +struct dns_api_msg { + /** Hostname to query or dotted IP address string */ +#if LWIP_MPU_COMPATIBLE + char name[DNS_MAX_NAME_LENGTH]; +#else /* LWIP_MPU_COMPATIBLE */ + const char *name; +#endif /* LWIP_MPU_COMPATIBLE */ + /** The resolved address is stored here */ + ip_addr_t API_MSG_M_DEF(addr); +#if LWIP_IPV4 && LWIP_IPV6 + /** Type of resolve call */ + u8_t dns_addrtype; +#endif /* LWIP_IPV4 && LWIP_IPV6 */ + /** This semaphore is posted when the name is resolved, the application thread + should wait on it. */ + sys_sem_t API_MSG_M_DEF_SEM(sem); + /** Errors are given back here */ + err_t API_MSG_M_DEF(err); +}; +#endif /* LWIP_DNS */ + +#if LWIP_TCP +extern u8_t netconn_aborted; +#endif /* LWIP_TCP */ + +void lwip_netconn_do_newconn (void *m); +void lwip_netconn_do_delconn (void *m); +void lwip_netconn_do_bind (void *m); +void lwip_netconn_do_connect (void *m); +void lwip_netconn_do_disconnect (void *m); +void lwip_netconn_do_listen (void *m); +void lwip_netconn_do_send (void *m); +void lwip_netconn_do_recv (void *m); +#if TCP_LISTEN_BACKLOG +void lwip_netconn_do_accepted (void *m); +#endif /* TCP_LISTEN_BACKLOG */ +void lwip_netconn_do_write (void *m); +void lwip_netconn_do_getaddr (void *m); +void lwip_netconn_do_close (void *m); +void lwip_netconn_do_shutdown (void *m); +#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) +void lwip_netconn_do_join_leave_group(void *m); +#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ + +#if LWIP_DNS +void lwip_netconn_do_gethostbyname(void *arg); +#endif /* LWIP_DNS */ + +struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); +void netconn_free(struct netconn *conn); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETCONN || LWIP_SOCKET */ + +#endif /* LWIP_HDR_API_MSG_H */ diff --git a/sys/include/net/priv/memp_std.h b/sys/include/net/priv/memp_std.h new file mode 100644 index 0000000..ce9fd50 --- /dev/null +++ b/sys/include/net/priv/memp_std.h @@ -0,0 +1,146 @@ +/** + * @file + * lwIP internal memory pools (do not use in application code) + * This file is deliberately included multiple times: once with empty + * definition of LWIP_MEMPOOL() to handle all includes and multiple times + * to build up various lists of mem pools. + */ + +/* + * SETUP: Make sure we define everything we will need. + * + * We have create three types of pools: + * 1) MEMPOOL - standard pools + * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c + * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct + * + * If the include'r doesn't require any special treatment of each of the types + * above, then will declare #2 & #3 to be just standard mempools. + */ +#ifndef LWIP_MALLOC_MEMPOOL +/* This treats "malloc pools" just like any other pool. + The pools are a little bigger to provide 'size' as the amount of user data. */ +#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size) +#define LWIP_MALLOC_MEMPOOL_START +#define LWIP_MALLOC_MEMPOOL_END +#endif /* LWIP_MALLOC_MEMPOOL */ + +#ifndef LWIP_PBUF_MEMPOOL +/* This treats "pbuf pools" just like any other pool. + * Allocates buffers for a pbuf struct AND a payload size */ +#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc) +#endif /* LWIP_PBUF_MEMPOOL */ + + +/* + * A list of internal pools used by LWIP. + * + * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description) + * creates a pool name MEMP_pool_name. description is used in stats.c + */ +#if LWIP_RAW +LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB") +#endif /* LWIP_RAW */ + +#if LWIP_UDP +LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB") +#endif /* LWIP_UDP */ + +#if LWIP_TCP +LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") +LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN") +LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG") +#endif /* LWIP_TCP */ + +#if LWIP_IPV4 && IP_REASSEMBLY +LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA") +#endif /* LWIP_IPV4 && IP_REASSEMBLY */ +#if (IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG) +LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF") +#endif /* IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF || (LWIP_IPV6 && LWIP_IPV6_FRAG) */ + +#if LWIP_NETCONN || LWIP_SOCKET +LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF") +LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN") +#endif /* LWIP_NETCONN || LWIP_SOCKET */ + +#if NO_SYS==0 +LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API") +#if LWIP_MPU_COMPATIBLE +LWIP_MEMPOOL(API_MSG, MEMP_NUM_API_MSG, sizeof(struct api_msg), "API_MSG") +#if LWIP_DNS +LWIP_MEMPOOL(DNS_API_MSG, MEMP_NUM_DNS_API_MSG, sizeof(struct dns_api_msg), "DNS_API_MSG") +#endif +#if LWIP_SOCKET && !LWIP_TCPIP_CORE_LOCKING +LWIP_MEMPOOL(SOCKET_SETGETSOCKOPT_DATA, MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA, sizeof(struct lwip_setgetsockopt_data), "SOCKET_SETGETSOCKOPT_DATA") +#endif +#if LWIP_NETIF_API +LWIP_MEMPOOL(NETIFAPI_MSG, MEMP_NUM_NETIFAPI_MSG, sizeof(struct netifapi_msg), "NETIFAPI_MSG") +#endif +#endif /* LWIP_MPU_COMPATIBLE */ +#if !LWIP_TCPIP_CORE_LOCKING_INPUT +LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT") +#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ +#endif /* NO_SYS==0 */ + +#if LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING +LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE") +#endif /* LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING */ + +#if LWIP_IGMP +LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP") +#endif /* LWIP_IGMP */ + +#if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM +LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT") +#endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */ + +#if LWIP_DNS && LWIP_SOCKET +LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB") +#endif /* LWIP_DNS && LWIP_SOCKET */ +#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC +LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST") +#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ + +#if LWIP_IPV6 && LWIP_ND6_QUEUEING +LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE") +#endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */ + +#if LWIP_IPV6 && LWIP_IPV6_REASS +LWIP_MEMPOOL(IP6_REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip6_reassdata), "IP6_REASSDATA") +#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ + +#if LWIP_IPV6 && LWIP_IPV6_MLD +LWIP_MEMPOOL(MLD6_GROUP, MEMP_NUM_MLD6_GROUP, sizeof(struct mld_group), "MLD6_GROUP") +#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ + + +/* + * A list of pools of pbuf's used by LWIP. + * + * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description) + * creates a pool name MEMP_pool_name. description is used in stats.c + * This allocates enough space for the pbuf struct and a payload. + * (Example: pbuf_payload_size=0 allocates only size for the struct) + */ +LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM") +LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL") + + +/* + * Allow for user-defined pools; this must be explicitly set in lwipopts.h + * since the default is to NOT look for lwippools.h + */ +#if MEMP_USE_CUSTOM_POOLS +#include "lwippools.h" +#endif /* MEMP_USE_CUSTOM_POOLS */ + +/* + * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later + * (#undef is ignored for something that is not defined) + */ +#undef LWIP_MEMPOOL +#undef LWIP_MALLOC_MEMPOOL +#undef LWIP_MALLOC_MEMPOOL_START +#undef LWIP_MALLOC_MEMPOOL_END +#undef LWIP_PBUF_MEMPOOL diff --git a/sys/include/net/priv/nd6_priv.h b/sys/include/net/priv/nd6_priv.h new file mode 100644 index 0000000..a057a4d --- /dev/null +++ b/sys/include/net/priv/nd6_priv.h @@ -0,0 +1,144 @@ +/** + * @file + * + * Neighbor discovery and stateless address autoconfiguration for IPv6. + * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 + * (Address autoconfiguration). + */ + +/* + * Copyright (c) 2010 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * + * Please coordinate changes and requests with Ivan Delamer + * + */ + +#ifndef LWIP_HDR_ND6_PRIV_H +#define LWIP_HDR_ND6_PRIV_H + +#include "net/opt.h" + +#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ + +#include "net/pbuf.h" +#include "net/ip6_addr.h" +#include "net/netif.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_ND6_QUEUEING +/** struct for queueing outgoing packets for unknown address + * defined here to be accessed by memp.h + */ +struct nd6_q_entry { + struct nd6_q_entry *next; + struct pbuf *p; +}; +#endif /* LWIP_ND6_QUEUEING */ + +/** Struct for tables. */ +struct nd6_neighbor_cache_entry { + ip6_addr_t next_hop_address; + struct netif *netif; + u8_t lladdr[NETIF_MAX_HWADDR_LEN]; + /*u32_t pmtu;*/ +#if LWIP_ND6_QUEUEING + /** Pointer to queue of pending outgoing packets on this entry. */ + struct nd6_q_entry *q; +#else /* LWIP_ND6_QUEUEING */ + /** Pointer to a single pending outgoing packet on this entry. */ + struct pbuf *q; +#endif /* LWIP_ND6_QUEUEING */ + u8_t state; + u8_t isrouter; + union { + u32_t reachable_time; /* in ms since value may originate from network packet */ + u32_t delay_time; /* ticks (ND6_TMR_INTERVAL) */ + u32_t probes_sent; + u32_t stale_time; /* ticks (ND6_TMR_INTERVAL) */ + } counter; +}; + +struct nd6_destination_cache_entry { + ip6_addr_t destination_addr; + ip6_addr_t next_hop_addr; + u16_t pmtu; + u32_t age; +}; + +struct nd6_prefix_list_entry { + ip6_addr_t prefix; + struct netif *netif; + u32_t invalidation_timer; /* in ms since value may originate from network packet */ +#if LWIP_IPV6_AUTOCONFIG + u8_t flags; +#define ND6_PREFIX_AUTOCONFIG_AUTONOMOUS 0x01 +#define ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED 0x02 +#define ND6_PREFIX_AUTOCONFIG_ADDRESS_DUPLICATE 0x04 +#endif /* LWIP_IPV6_AUTOCONFIG */ +}; + +struct nd6_router_list_entry { + struct nd6_neighbor_cache_entry *neighbor_entry; + u32_t invalidation_timer; /* in ms since value may originate from network packet */ + u8_t flags; +}; + +enum nd6_neighbor_cache_entry_state { + ND6_NO_ENTRY = 0, + ND6_INCOMPLETE, + ND6_REACHABLE, + ND6_STALE, + ND6_DELAY, + ND6_PROBE +}; + +/* Router tables. */ +/* @todo make these static? and entries accessible through API? */ +extern struct nd6_neighbor_cache_entry neighbor_cache[]; +extern struct nd6_destination_cache_entry destination_cache[]; +extern struct nd6_prefix_list_entry prefix_list[]; +extern struct nd6_router_list_entry default_router_list[]; + +/* Default values, can be updated by a RA message. */ +extern u32_t reachable_time; +extern u32_t retrans_timer; + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV6 */ + +#endif /* LWIP_HDR_ND6_PRIV_H */ diff --git a/sys/include/net/priv/tcp_priv.h b/sys/include/net/priv/tcp_priv.h new file mode 100644 index 0000000..3c8cf67 --- /dev/null +++ b/sys/include/net/priv/tcp_priv.h @@ -0,0 +1,507 @@ +/** + * @file + * TCP internal implementations (do not use in application code) + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_TCP_PRIV_H +#define LWIP_HDR_TCP_PRIV_H + +#include "net/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "net/tcp.h" +#include "net/mem.h" +#include "net/pbuf.h" +#include "net/ip.h" +#include "net/icmp.h" +#include "net/err.h" +#include "net/ip6.h" +#include "net/ip6_addr.h" +#include "net/prot/tcp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Functions for interfacing with TCP: */ + +/* Lower layer interface to TCP: */ +void tcp_init (void); /* Initialize this module. */ +void tcp_tmr (void); /* Must be called every + TCP_TMR_INTERVAL + ms. (Typically 250 ms). */ +/* It is also possible to call these two functions at the right + intervals (instead of calling tcp_tmr()). */ +void tcp_slowtmr (void); +void tcp_fasttmr (void); + +/* Call this from a netif driver (watch out for threading issues!) that has + returned a memory error on transmit and now has free buffers to send more. + This iterates all active pcbs that had an error and tries to call + tcp_output, so use this with care as it might slow down the system. */ +void tcp_txnow (void); + +/* Only used by IP to pass a TCP segment to TCP: */ +void tcp_input (struct pbuf *p, struct netif *inp); +/* Used within the TCP code only: */ +struct tcp_pcb * tcp_alloc (u8_t prio); +void tcp_abandon (struct tcp_pcb *pcb, int reset); +err_t tcp_send_empty_ack(struct tcp_pcb *pcb); +void tcp_rexmit (struct tcp_pcb *pcb); +void tcp_rexmit_rto (struct tcp_pcb *pcb); +void tcp_rexmit_fast (struct tcp_pcb *pcb); +u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); +err_t tcp_process_refused_data(struct tcp_pcb *pcb); + +/** + * This is the Nagle algorithm: try to combine user data to send as few TCP + * segments as possible. Only send if + * - no previously transmitted data on the connection remains unacknowledged or + * - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or + * - the only unsent segment is at least pcb->mss bytes long (or there is more + * than one unsent segment - with lwIP, this can happen although unsent->len < mss) + * - or if we are in fast-retransmit (TF_INFR) + */ +#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ + ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \ + (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ + ((tpcb)->unsent->len >= (tpcb)->mss))) || \ + ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \ + ) ? 1 : 0) +#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) + + +#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) +#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) +#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) +#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) +/* is b<=a<=c? */ +#if 0 /* see bug #10548 */ +#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) +#endif +#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) + +#ifndef TCP_TMR_INTERVAL +#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ +#endif /* TCP_TMR_INTERVAL */ + +#ifndef TCP_FAST_INTERVAL +#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ +#endif /* TCP_FAST_INTERVAL */ + +#ifndef TCP_SLOW_INTERVAL +#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ +#endif /* TCP_SLOW_INTERVAL */ + +#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ +#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ + +#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ + +#ifndef TCP_MSL +#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */ +#endif + +/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ +#ifndef TCP_KEEPIDLE_DEFAULT +#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ +#endif + +#ifndef TCP_KEEPINTVL_DEFAULT +#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ +#endif + +#ifndef TCP_KEEPCNT_DEFAULT +#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ +#endif + +#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */ + +#define TCP_TCPLEN(seg) ((seg)->len + (((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0) ? 1U : 0U)) + +/** Flags used on input processing, not on pcb->flags +*/ +#define TF_RESET (u8_t)0x08U /* Connection was reset. */ +#define TF_CLOSED (u8_t)0x10U /* Connection was successfully closed. */ +#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ + + +#if LWIP_EVENT_API + +#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) ret = lwip_tcp_event(arg, (pcb),\ + LWIP_EVENT_ACCEPT, NULL, 0, err) +#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_SENT, NULL, space, ERR_OK) +#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_RECV, (p), 0, (err)) +#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_RECV, NULL, 0, ERR_OK) +#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ + LWIP_EVENT_CONNECTED, NULL, 0, (err)) +#define TCP_EVENT_POLL(pcb,ret) do { if ((pcb)->state != SYN_RCVD) { \ + ret = lwip_tcp_event((pcb)->callback_arg, (pcb), LWIP_EVENT_POLL, NULL, 0, ERR_OK); \ + } else { \ + ret = ERR_ARG; } } while(0) +#define TCP_EVENT_ERR(last_state,errf,arg,err) do { if (last_state != SYN_RCVD) { \ + lwip_tcp_event((arg), NULL, LWIP_EVENT_ERR, NULL, 0, (err)); } } while(0) + +#else /* LWIP_EVENT_API */ + +#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \ + do { \ + if((lpcb)->accept != NULL) \ + (ret) = (lpcb)->accept((arg),(pcb),(err)); \ + else (ret) = ERR_ARG; \ + } while (0) + +#define TCP_EVENT_SENT(pcb,space,ret) \ + do { \ + if((pcb)->sent != NULL) \ + (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \ + else (ret) = ERR_OK; \ + } while (0) + +#define TCP_EVENT_RECV(pcb,p,err,ret) \ + do { \ + if((pcb)->recv != NULL) { \ + (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\ + } else { \ + (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \ + } \ + } while (0) + +#define TCP_EVENT_CLOSED(pcb,ret) \ + do { \ + if(((pcb)->recv != NULL)) { \ + (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\ + } else { \ + (ret) = ERR_OK; \ + } \ + } while (0) + +#define TCP_EVENT_CONNECTED(pcb,err,ret) \ + do { \ + if((pcb)->connected != NULL) \ + (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \ + else (ret) = ERR_OK; \ + } while (0) + +#define TCP_EVENT_POLL(pcb,ret) \ + do { \ + if((pcb)->poll != NULL) \ + (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \ + else (ret) = ERR_OK; \ + } while (0) + +#define TCP_EVENT_ERR(last_state,errf,arg,err) \ + do { \ + LWIP_UNUSED_ARG(last_state); \ + if((errf) != NULL) \ + (errf)((arg),(err)); \ + } while (0) + +#endif /* LWIP_EVENT_API */ + +/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */ +#if TCP_OVERSIZE && defined(LWIP_DEBUG) +#define TCP_OVERSIZE_DBGCHECK 1 +#else +#define TCP_OVERSIZE_DBGCHECK 0 +#endif + +/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ +#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) + +/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */ +struct tcp_seg { + struct tcp_seg *next; /* used when putting segments on a queue */ + struct pbuf *p; /* buffer containing data + TCP header */ + u16_t len; /* the TCP length of this segment */ +#if TCP_OVERSIZE_DBGCHECK + u16_t oversize_left; /* Extra bytes available at the end of the last + pbuf in unsent (used for asserting vs. + tcp_pcb.unsent_oversize only) */ +#endif /* TCP_OVERSIZE_DBGCHECK */ +#if TCP_CHECKSUM_ON_COPY + u16_t chksum; + u8_t chksum_swapped; +#endif /* TCP_CHECKSUM_ON_COPY */ + u8_t flags; +#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */ +#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */ +#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is + checksummed into 'chksum' */ +#define TF_SEG_OPTS_WND_SCALE (u8_t)0x08U /* Include WND SCALE option */ + struct tcp_hdr *tcphdr; /* the TCP header */ +}; + +#define LWIP_TCP_OPT_EOL 0 +#define LWIP_TCP_OPT_NOP 1 +#define LWIP_TCP_OPT_MSS 2 +#define LWIP_TCP_OPT_WS 3 +#define LWIP_TCP_OPT_TS 8 + +#define LWIP_TCP_OPT_LEN_MSS 4 +#if LWIP_TCP_TIMESTAMPS +#define LWIP_TCP_OPT_LEN_TS 10 +#define LWIP_TCP_OPT_LEN_TS_OUT 12 /* aligned for output (includes NOP padding) */ +#else +#define LWIP_TCP_OPT_LEN_TS_OUT 0 +#endif +#if LWIP_WND_SCALE +#define LWIP_TCP_OPT_LEN_WS 3 +#define LWIP_TCP_OPT_LEN_WS_OUT 4 /* aligned for output (includes NOP padding) */ +#else +#define LWIP_TCP_OPT_LEN_WS_OUT 0 +#endif + +#define LWIP_TCP_OPT_LENGTH(flags) \ + (flags & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \ + (flags & TF_SEG_OPTS_TS ? LWIP_TCP_OPT_LEN_TS_OUT : 0) + \ + (flags & TF_SEG_OPTS_WND_SCALE ? LWIP_TCP_OPT_LEN_WS_OUT : 0) + +/** This returns a TCP header option for MSS in an u32_t */ +#define TCP_BUILD_MSS_OPTION(mss) lwip_htonl(0x02040000 | ((mss) & 0xFFFF)) + +#if LWIP_WND_SCALE +#define TCPWNDSIZE_F U32_F +#define TCPWND_MAX 0xFFFFFFFFU +#define TCPWND_CHECK16(x) LWIP_ASSERT("window size > 0xFFFF", (x) <= 0xFFFF) +#define TCPWND_MIN16(x) ((u16_t)LWIP_MIN((x), 0xFFFF)) +#else /* LWIP_WND_SCALE */ +#define TCPWNDSIZE_F U16_F +#define TCPWND_MAX 0xFFFFU +#define TCPWND_CHECK16(x) +#define TCPWND_MIN16(x) x +#endif /* LWIP_WND_SCALE */ + +/* Global variables: */ +extern struct tcp_pcb *tcp_input_pcb; +extern u32_t tcp_ticks; +extern u8_t tcp_active_pcbs_changed; + +/* The TCP PCB lists. */ +union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ + struct tcp_pcb_listen *listen_pcbs; + struct tcp_pcb *pcbs; +}; +extern struct tcp_pcb *tcp_bound_pcbs; +extern union tcp_listen_pcbs_t tcp_listen_pcbs; +extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a + state in which they accept or send + data. */ +extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ + +#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 +#define NUM_TCP_PCB_LISTS 4 +extern struct tcp_pcb ** const tcp_pcb_lists[NUM_TCP_PCB_LISTS]; + +/* Axioms about the above lists: + 1) Every TCP PCB that is not CLOSED is in one of the lists. + 2) A PCB is only in one of the lists. + 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. + 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. +*/ +/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB + with a PCB list or removes a PCB from a list, respectively. */ +#ifndef TCP_DEBUG_PCB_LISTS +#define TCP_DEBUG_PCB_LISTS 0 +#endif +#if TCP_DEBUG_PCB_LISTS +#define TCP_REG(pcbs, npcb) do {\ + struct tcp_pcb *tcp_tmp_pcb; \ + LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \ + for (tcp_tmp_pcb = *(pcbs); \ + tcp_tmp_pcb != NULL; \ + tcp_tmp_pcb = tcp_tmp_pcb->next) { \ + LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \ + } \ + LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \ + (npcb)->next = *(pcbs); \ + LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \ + *(pcbs) = (npcb); \ + LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ + tcp_timer_needed(); \ + } while(0) +#define TCP_RMV(pcbs, npcb) do { \ + struct tcp_pcb *tcp_tmp_pcb; \ + LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \ + LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \ + if(*(pcbs) == (npcb)) { \ + *(pcbs) = (*pcbs)->next; \ + } else for (tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ + if(tcp_tmp_pcb->next == (npcb)) { \ + tcp_tmp_pcb->next = (npcb)->next; \ + break; \ + } \ + } \ + (npcb)->next = NULL; \ + LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ + LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \ + } while(0) + +#else /* LWIP_DEBUG */ + +#define TCP_REG(pcbs, npcb) \ + do { \ + (npcb)->next = *pcbs; \ + *(pcbs) = (npcb); \ + tcp_timer_needed(); \ + } while (0) + +#define TCP_RMV(pcbs, npcb) \ + do { \ + if(*(pcbs) == (npcb)) { \ + (*(pcbs)) = (*pcbs)->next; \ + } \ + else { \ + struct tcp_pcb *tcp_tmp_pcb; \ + for (tcp_tmp_pcb = *pcbs; \ + tcp_tmp_pcb != NULL; \ + tcp_tmp_pcb = tcp_tmp_pcb->next) { \ + if(tcp_tmp_pcb->next == (npcb)) { \ + tcp_tmp_pcb->next = (npcb)->next; \ + break; \ + } \ + } \ + } \ + (npcb)->next = NULL; \ + } while(0) + +#endif /* LWIP_DEBUG */ + +#define TCP_REG_ACTIVE(npcb) \ + do { \ + TCP_REG(&tcp_active_pcbs, npcb); \ + tcp_active_pcbs_changed = 1; \ + } while (0) + +#define TCP_RMV_ACTIVE(npcb) \ + do { \ + TCP_RMV(&tcp_active_pcbs, npcb); \ + tcp_active_pcbs_changed = 1; \ + } while (0) + +#define TCP_PCB_REMOVE_ACTIVE(pcb) \ + do { \ + tcp_pcb_remove(&tcp_active_pcbs, pcb); \ + tcp_active_pcbs_changed = 1; \ + } while (0) + + +/* Internal functions: */ +struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); +void tcp_pcb_purge(struct tcp_pcb *pcb); +void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); + +void tcp_segs_free(struct tcp_seg *seg); +void tcp_seg_free(struct tcp_seg *seg); +struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); + +#define tcp_ack(pcb) \ + do { \ + if((pcb)->flags & TF_ACK_DELAY) { \ + (pcb)->flags &= ~TF_ACK_DELAY; \ + (pcb)->flags |= TF_ACK_NOW; \ + } \ + else { \ + (pcb)->flags |= TF_ACK_DELAY; \ + } \ + } while (0) + +#define tcp_ack_now(pcb) \ + do { \ + (pcb)->flags |= TF_ACK_NOW; \ + } while (0) + +err_t tcp_send_fin(struct tcp_pcb *pcb); +err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags); + +void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); + +void tcp_rst(u32_t seqno, u32_t ackno, + const ip_addr_t *local_ip, const ip_addr_t *remote_ip, + u16_t local_port, u16_t remote_port); + +u32_t tcp_next_iss(struct tcp_pcb *pcb); + +err_t tcp_keepalive(struct tcp_pcb *pcb); +err_t tcp_zero_window_probe(struct tcp_pcb *pcb); +void tcp_trigger_input_pcb_close(void); + +#if TCP_CALCULATE_EFF_SEND_MSS +u16_t tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest +#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING + , const ip_addr_t *src +#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ + ); +#if LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING +#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest, src) +#else /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ +#define tcp_eff_send_mss(sendmss, src, dest) tcp_eff_send_mss_impl(sendmss, dest) +#endif /* LWIP_IPV6 || LWIP_IPV4_SRC_ROUTING */ +#endif /* TCP_CALCULATE_EFF_SEND_MSS */ + +#if LWIP_CALLBACK_API +err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); +#endif /* LWIP_CALLBACK_API */ + +#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG +void tcp_debug_print(struct tcp_hdr *tcphdr); +void tcp_debug_print_flags(u8_t flags); +void tcp_debug_print_state(enum tcp_state s); +void tcp_debug_print_pcbs(void); +s16_t tcp_pcbs_sane(void); +#else +# define tcp_debug_print(tcphdr) +# define tcp_debug_print_flags(flags) +# define tcp_debug_print_state(s) +# define tcp_debug_print_pcbs() +# define tcp_pcbs_sane() 1 +#endif /* TCP_DEBUG */ + +/** External function (implemented in timers.c), called when TCP detects + * that a timer is needed (i.e. active- or time-wait-pcb found). */ +void tcp_timer_needed(void); + +void tcp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_TCP */ + +#endif /* LWIP_HDR_TCP_PRIV_H */ diff --git a/sys/include/net/prot/autoip.h b/sys/include/net/prot/autoip.h new file mode 100644 index 0000000..fd3af8a --- /dev/null +++ b/sys/include/net/prot/autoip.h @@ -0,0 +1,78 @@ +/** + * @file + * AutoIP protocol definitions + */ + +/* + * + * Copyright (c) 2007 Dominik Spies + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * Author: Dominik Spies + * + * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform + * with RFC 3927. + * + */ + +#ifndef LWIP_HDR_PROT_AUTOIP_H +#define LWIP_HDR_PROT_AUTOIP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* 169.254.0.0 */ +#define AUTOIP_NET 0xA9FE0000 +/* 169.254.1.0 */ +#define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100) +/* 169.254.254.255 */ +#define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF) + +/* RFC 3927 Constants */ +#define PROBE_WAIT 1 /* second (initial random delay) */ +#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ +#define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ +#define PROBE_NUM 3 /* (number of probe packets) */ +#define ANNOUNCE_NUM 2 /* (number of announcement packets) */ +#define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ +#define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ +#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ +#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ +#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ + +/* AutoIP client states */ +typedef enum { + AUTOIP_STATE_OFF = 0, + AUTOIP_STATE_PROBING = 1, + AUTOIP_STATE_ANNOUNCING = 2, + AUTOIP_STATE_BOUND = 3 +} autoip_state_enum_t; + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_AUTOIP_H */ diff --git a/sys/include/net/prot/etharp.h b/sys/include/net/prot/etharp.h new file mode 100644 index 0000000..6f5c5eb --- /dev/null +++ b/sys/include/net/prot/etharp.h @@ -0,0 +1,91 @@ +/** + * @file + * ARP protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_ETHARP_H +#define LWIP_HDR_PROT_ETHARP_H + +#include "net/arch.h" +#include "net/prot/ethernet.h" +#include "net/ip4_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ETHARP_HWADDR_LEN +#define ETHARP_HWADDR_LEN ETH_HWADDR_LEN +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** the ARP message, see RFC 826 ("Packet format") */ +struct etharp_hdr { + PACK_STRUCT_FIELD(u16_t hwtype); + PACK_STRUCT_FIELD(u16_t proto); + PACK_STRUCT_FLD_8(u8_t hwlen); + PACK_STRUCT_FLD_8(u8_t protolen); + PACK_STRUCT_FIELD(u16_t opcode); + PACK_STRUCT_FLD_S(struct eth_addr shwaddr); + PACK_STRUCT_FLD_S(struct ip4_addr2 sipaddr); + PACK_STRUCT_FLD_S(struct eth_addr dhwaddr); + PACK_STRUCT_FLD_S(struct ip4_addr2 dipaddr); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define SIZEOF_ETHARP_HDR 28 + +/* ARP hwtype values */ +enum etharp_hwtype { + HWTYPE_ETHERNET = 1 + /* others not used */ +}; + +/* ARP message types (opcodes) */ +enum etharp_opcode { + ARP_REQUEST = 1, + ARP_REPLY = 2 +}; + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_ETHARP_H */ diff --git a/sys/include/net/prot/ethernet.h b/sys/include/net/prot/ethernet.h new file mode 100644 index 0000000..d4e8b1c --- /dev/null +++ b/sys/include/net/prot/ethernet.h @@ -0,0 +1,170 @@ +/** + * @file + * Ethernet protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_ETHERNET_H +#define LWIP_HDR_PROT_ETHERNET_H + +#include "net/arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ETH_HWADDR_LEN +#ifdef ETHARP_HWADDR_LEN +#define ETH_HWADDR_LEN ETHARP_HWADDR_LEN /* compatibility mode */ +#else +#define ETH_HWADDR_LEN 6 +#endif +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct eth_addr { + PACK_STRUCT_FLD_8(u8_t addr[ETH_HWADDR_LEN]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** Ethernet header */ +struct eth_hdr { +#if ETH_PAD_SIZE + PACK_STRUCT_FLD_8(u8_t padding[ETH_PAD_SIZE]); +#endif + PACK_STRUCT_FLD_S(struct eth_addr dest); + PACK_STRUCT_FLD_S(struct eth_addr src); + PACK_STRUCT_FIELD(u16_t type); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE) + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/** VLAN header inserted between ethernet header and payload + * if 'type' in ethernet header is ETHTYPE_VLAN. + * See IEEE802.Q */ +struct eth_vlan_hdr { + PACK_STRUCT_FIELD(u16_t prio_vid); + PACK_STRUCT_FIELD(u16_t tpid); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define SIZEOF_VLAN_HDR 4 +#define VLAN_ID(vlan_hdr) (lwip_htons((vlan_hdr)->prio_vid) & 0xFFF) + +/** + * @ingroup ethernet + * A list of often ethtypes (although lwIP does not use all of them): */ +enum eth_type { + /** Internet protocol v4 */ + ETHTYPE_IP = 0x0800U, + /** Address resolution protocol */ + ETHTYPE_ARP = 0x0806U, + /** Wake on lan */ + ETHTYPE_WOL = 0x0842U, + /** RARP */ + ETHTYPE_RARP = 0x8035U, + /** Virtual local area network */ + ETHTYPE_VLAN = 0x8100U, + /** Internet protocol v6 */ + ETHTYPE_IPV6 = 0x86DDU, + /** PPP Over Ethernet Discovery Stage */ + ETHTYPE_PPPOEDISC = 0x8863U, + /** PPP Over Ethernet Session Stage */ + ETHTYPE_PPPOE = 0x8864U, + /** Jumbo Frames */ + ETHTYPE_JUMBO = 0x8870U, + /** Process field network */ + ETHTYPE_PROFINET = 0x8892U, + /** Ethernet for control automation technology */ + ETHTYPE_ETHERCAT = 0x88A4U, + /** Link layer discovery protocol */ + ETHTYPE_LLDP = 0x88CCU, + /** Serial real-time communication system */ + ETHTYPE_SERCOS = 0x88CDU, + /** Media redundancy protocol */ + ETHTYPE_MRP = 0x88E3U, + /** Precision time protocol */ + ETHTYPE_PTP = 0x88F7U, + /** Q-in-Q, 802.1ad */ + ETHTYPE_QINQ = 0x9100U +}; + +/** The 24-bit IANA IPv4-multicast OUI is 01-00-5e: */ +#define LL_IP4_MULTICAST_ADDR_0 0x01 +#define LL_IP4_MULTICAST_ADDR_1 0x00 +#define LL_IP4_MULTICAST_ADDR_2 0x5e + +/** IPv6 multicast uses this prefix */ +#define LL_IP6_MULTICAST_ADDR_0 0x33 +#define LL_IP6_MULTICAST_ADDR_1 0x33 + +/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables + * or known to be 32-bit aligned within the protocol header. */ +#ifndef ETHADDR32_COPY +#define ETHADDR32_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN) +#endif + +/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local + * variables and known to be 16-bit aligned within the protocol header. */ +#ifndef ETHADDR16_COPY +#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN) +#endif + +#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETH_HWADDR_LEN) == 0) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_ETHERNET_H */ diff --git a/sys/include/net/prot/icmp.h b/sys/include/net/prot/icmp.h new file mode 100644 index 0000000..8a6fbd5 --- /dev/null +++ b/sys/include/net/prot/icmp.h @@ -0,0 +1,91 @@ +/** + * @file + * ICMP protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_ICMP_H +#define LWIP_HDR_PROT_ICMP_H + +#include "net/arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ICMP_ER 0 /* echo reply */ +#define ICMP_DUR 3 /* destination unreachable */ +#define ICMP_SQ 4 /* source quench */ +#define ICMP_RD 5 /* redirect */ +#define ICMP_ECHO 8 /* echo */ +#define ICMP_TE 11 /* time exceeded */ +#define ICMP_PP 12 /* parameter problem */ +#define ICMP_TS 13 /* timestamp */ +#define ICMP_TSR 14 /* timestamp reply */ +#define ICMP_IRQ 15 /* information request */ +#define ICMP_IR 16 /* information reply */ +#define ICMP_AM 17 /* address mask request */ +#define ICMP_AMR 18 /* address mask reply */ + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +/** This is the standard ICMP header only that the u32_t data + * is split to two u16_t like ICMP echo needs it. + * This header is also used for other ICMP types that do not + * use the data part. + */ +PACK_STRUCT_BEGIN +struct icmp_echo_hdr { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u16_t id); + PACK_STRUCT_FIELD(u16_t seqno); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* Compatibility defines, old versions used to combine type and code to an u16_t */ +#define ICMPH_TYPE(hdr) ((hdr)->type) +#define ICMPH_CODE(hdr) ((hdr)->code) +#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) +#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_ICMP_H */ diff --git a/sys/include/net/prot/icmp6.h b/sys/include/net/prot/icmp6.h new file mode 100644 index 0000000..3cd7327 --- /dev/null +++ b/sys/include/net/prot/icmp6.h @@ -0,0 +1,170 @@ +/** + * @file + * ICMP6 protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_ICMP6_H +#define LWIP_HDR_PROT_ICMP6_H + +#include "net/arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** ICMP type */ +enum icmp6_type { + /** Destination unreachable */ + ICMP6_TYPE_DUR = 1, + /** Packet too big */ + ICMP6_TYPE_PTB = 2, + /** Time exceeded */ + ICMP6_TYPE_TE = 3, + /** Parameter problem */ + ICMP6_TYPE_PP = 4, + /** Private experimentation */ + ICMP6_TYPE_PE1 = 100, + /** Private experimentation */ + ICMP6_TYPE_PE2 = 101, + /** Reserved for expansion of error messages */ + ICMP6_TYPE_RSV_ERR = 127, + + /** Echo request */ + ICMP6_TYPE_EREQ = 128, + /** Echo reply */ + ICMP6_TYPE_EREP = 129, + /** Multicast listener query */ + ICMP6_TYPE_MLQ = 130, + /** Multicast listener report */ + ICMP6_TYPE_MLR = 131, + /** Multicast listener done */ + ICMP6_TYPE_MLD = 132, + /** Router solicitation */ + ICMP6_TYPE_RS = 133, + /** Router advertisement */ + ICMP6_TYPE_RA = 134, + /** Neighbor solicitation */ + ICMP6_TYPE_NS = 135, + /** Neighbor advertisement */ + ICMP6_TYPE_NA = 136, + /** Redirect */ + ICMP6_TYPE_RD = 137, + /** Multicast router advertisement */ + ICMP6_TYPE_MRA = 151, + /** Multicast router solicitation */ + ICMP6_TYPE_MRS = 152, + /** Multicast router termination */ + ICMP6_TYPE_MRT = 153, + /** Private experimentation */ + ICMP6_TYPE_PE3 = 200, + /** Private experimentation */ + ICMP6_TYPE_PE4 = 201, + /** Reserved for expansion of informational messages */ + ICMP6_TYPE_RSV_INF = 255 +}; + +/** ICMP destination unreachable codes */ +enum icmp6_dur_code { + /** No route to destination */ + ICMP6_DUR_NO_ROUTE = 0, + /** Communication with destination administratively prohibited */ + ICMP6_DUR_PROHIBITED = 1, + /** Beyond scope of source address */ + ICMP6_DUR_SCOPE = 2, + /** Address unreachable */ + ICMP6_DUR_ADDRESS = 3, + /** Port unreachable */ + ICMP6_DUR_PORT = 4, + /** Source address failed ingress/egress policy */ + ICMP6_DUR_POLICY = 5, + /** Reject route to destination */ + ICMP6_DUR_REJECT_ROUTE = 6 +}; + +/** ICMP time exceeded codes */ +enum icmp6_te_code { + /** Hop limit exceeded in transit */ + ICMP6_TE_HL = 0, + /** Fragment reassembly time exceeded */ + ICMP6_TE_FRAG = 1 +}; + +/** ICMP parameter code */ +enum icmp6_pp_code { + /** Erroneous header field encountered */ + ICMP6_PP_FIELD = 0, + /** Unrecognized next header type encountered */ + ICMP6_PP_HEADER = 1, + /** Unrecognized IPv6 option encountered */ + ICMP6_PP_OPTION = 2 +}; + +/** This is the standard ICMP6 header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct icmp6_hdr { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u32_t data); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** This is the ICMP6 header adapted for echo req/resp. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct icmp6_echo_hdr { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u16_t id); + PACK_STRUCT_FIELD(u16_t seqno); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_ICMP6_H */ diff --git a/sys/include/net/prot/ip4.h b/sys/include/net/prot/ip4.h new file mode 100644 index 0000000..9d4a5bd --- /dev/null +++ b/sys/include/net/prot/ip4.h @@ -0,0 +1,127 @@ +/** + * @file + * IPv4 protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_IP4_H +#define LWIP_HDR_PROT_IP4_H + +#include "net/arch.h" +#include "net/ip4_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the packed version of ip4_addr_t, + used in network headers that are itself packed */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip4_addr_packed { + PACK_STRUCT_FIELD(u32_t addr); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +typedef struct ip4_addr_packed ip4_addr_p_t; + +/* Size of the IPv4 header. Same as 'sizeof(struct ip_hdr)'. */ +#define IP_HLEN 20 + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +/* The IPv4 header */ +struct ip_hdr { + /* version / header length */ + PACK_STRUCT_FLD_8(u8_t _v_hl); + /* type of service */ + PACK_STRUCT_FLD_8(u8_t _tos); + /* total length */ + PACK_STRUCT_FIELD(u16_t _len); + /* identification */ + PACK_STRUCT_FIELD(u16_t _id); + /* fragment offset field */ + PACK_STRUCT_FIELD(u16_t _offset); +#define IP_RF 0x8000U /* reserved fragment flag */ +#define IP_DF 0x4000U /* don't fragment flag */ +#define IP_MF 0x2000U /* more fragments flag */ +#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */ + /* time to live */ + PACK_STRUCT_FLD_8(u8_t _ttl); + /* protocol*/ + PACK_STRUCT_FLD_8(u8_t _proto); + /* checksum */ + PACK_STRUCT_FIELD(u16_t _chksum); + /* source and destination IP addresses */ + PACK_STRUCT_FLD_S(ip4_addr_p_t src); + PACK_STRUCT_FLD_S(ip4_addr_p_t dest); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* Macros to get struct ip_hdr fields: */ +#define IPH_V(hdr) ((hdr)->_v_hl >> 4) +#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f) +#define IPH_TOS(hdr) ((hdr)->_tos) +#define IPH_LEN(hdr) ((hdr)->_len) +#define IPH_ID(hdr) ((hdr)->_id) +#define IPH_OFFSET(hdr) ((hdr)->_offset) +#define IPH_TTL(hdr) ((hdr)->_ttl) +#define IPH_PROTO(hdr) ((hdr)->_proto) +#define IPH_CHKSUM(hdr) ((hdr)->_chksum) + +/* Macros to set struct ip_hdr fields: */ +#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (u8_t)((((v) << 4) | (hl))) +#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos) +#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len) +#define IPH_ID_SET(hdr, id) (hdr)->_id = (id) +#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off) +#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl) +#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) +#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_IP4_H */ diff --git a/sys/include/net/prot/ip6.h b/sys/include/net/prot/ip6.h new file mode 100644 index 0000000..066bdb2 --- /dev/null +++ b/sys/include/net/prot/ip6.h @@ -0,0 +1,169 @@ +/** + * @file + * IPv6 protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_IP6_H +#define LWIP_HDR_PROT_IP6_H + +#include "lwip/arch.h" +#include "lwip/ip6_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the packed version of ip6_addr_t, + used in network headers that are itself packed */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip6_addr_packed { + PACK_STRUCT_FIELD(u32_t addr[4]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif +typedef struct ip6_addr_packed ip6_addr_p_t; + +#define IP6_HLEN 40 + +#define IP6_NEXTH_HOPBYHOP 0 +#define IP6_NEXTH_TCP 6 +#define IP6_NEXTH_UDP 17 +#define IP6_NEXTH_ENCAPS 41 +#define IP6_NEXTH_ROUTING 43 +#define IP6_NEXTH_FRAGMENT 44 +#define IP6_NEXTH_ICMP6 58 +#define IP6_NEXTH_NONE 59 +#define IP6_NEXTH_DESTOPTS 60 +#define IP6_NEXTH_UDPLITE 136 + +/** The IPv6 header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip6_hdr { + /** version / traffic class / flow label */ + PACK_STRUCT_FIELD(u32_t _v_tc_fl); + /** payload length */ + PACK_STRUCT_FIELD(u16_t _plen); + /** next header */ + PACK_STRUCT_FLD_8(u8_t _nexth); + /** hop limit */ + PACK_STRUCT_FLD_8(u8_t _hoplim); + /** source and destination IP addresses */ + PACK_STRUCT_FLD_S(ip6_addr_p_t src); + PACK_STRUCT_FLD_S(ip6_addr_p_t dest); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* Hop-by-hop router alert option. */ +#define IP6_HBH_HLEN 8 +#define IP6_PAD1_OPTION 0 +#define IP6_PADN_ALERT_OPTION 1 +#define IP6_ROUTER_ALERT_OPTION 5 +#define IP6_ROUTER_ALERT_VALUE_MLD 0 +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip6_hbh_hdr { + /* next header */ + PACK_STRUCT_FLD_8(u8_t _nexth); + /* header length */ + PACK_STRUCT_FLD_8(u8_t _hlen); + /* router alert option type */ + PACK_STRUCT_FLD_8(u8_t _ra_opt_type); + /* router alert option data len */ + PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen); + /* router alert option data */ + PACK_STRUCT_FIELD(u16_t _ra_opt_data); + /* PadN option type */ + PACK_STRUCT_FLD_8(u8_t _padn_opt_type); + /* PadN option data len */ + PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* Fragment header. */ +#define IP6_FRAG_HLEN 8 +#define IP6_FRAG_OFFSET_MASK 0xfff8 +#define IP6_FRAG_MORE_FLAG 0x0001 +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ip6_frag_hdr { + /* next header */ + PACK_STRUCT_FLD_8(u8_t _nexth); + /* reserved */ + PACK_STRUCT_FLD_8(u8_t reserved); + /* fragment offset */ + PACK_STRUCT_FIELD(u16_t _fragment_offset); + /* fragmented packet identification */ + PACK_STRUCT_FIELD(u32_t _identification); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) +#define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) +#define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff) +#define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen)) +#define IP6H_NEXTH(hdr) ((hdr)->_nexth) +#define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) +#define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) + +#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) +#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen) +#define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) +#define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_IP6_H */ diff --git a/sys/include/net/prot/mld6.h b/sys/include/net/prot/mld6.h index be3a006..8989a57 100644 --- a/sys/include/net/prot/mld6.h +++ b/sys/include/net/prot/mld6.h @@ -1,70 +1,70 @@ -/** - * @file - * MLD6 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_MLD6_H -#define LWIP_HDR_PROT_MLD6_H - -#include "lwip/arch.h" -#include "lwip/prot/ip6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Multicast listener report/query/done message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct mld_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t max_resp_delay); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_MLD6_H */ +/** + * @file + * MLD6 protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_MLD6_H +#define LWIP_HDR_PROT_MLD6_H + +#include "lwip/arch.h" +#include "lwip/prot/ip6.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Multicast listener report/query/done message header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct mld_header { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u16_t max_resp_delay); + PACK_STRUCT_FIELD(u16_t reserved); + PACK_STRUCT_FLD_S(ip6_addr_p_t multicast_address); + /* Options follow. */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_MLD6_H */ diff --git a/sys/include/net/prot/nd6.h b/sys/include/net/prot/nd6.h index 2d4903d..e6999df 100644 --- a/sys/include/net/prot/nd6.h +++ b/sys/include/net/prot/nd6.h @@ -1,277 +1,277 @@ -/** - * @file - * ND6 protocol definitions - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef LWIP_HDR_PROT_ND6_H -#define LWIP_HDR_PROT_ND6_H - -#include "lwip/arch.h" -#include "lwip/ip6_addr.h" -#include "lwip/prot/ip6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Neighbor solicitation message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ns_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Neighbor advertisement message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct na_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FLD_8(u8_t flags); - PACK_STRUCT_FLD_8(u8_t reserved[3]); - PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif -#define ND6_FLAG_ROUTER (0x80) -#define ND6_FLAG_SOLICITED (0x40) -#define ND6_FLAG_OVERRIDE (0x20) - -/** Router solicitation message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct rs_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Router advertisement message header. */ -#define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80) -#define ND6_RA_FLAG_OTHER_CONFIG (0x40) -#define ND6_RA_FLAG_HOME_AGENT (0x20) -#define ND6_RA_PREFERENCE_MASK (0x18) -#define ND6_RA_PREFERENCE_HIGH (0x08) -#define ND6_RA_PREFERENCE_MEDIUM (0x00) -#define ND6_RA_PREFERENCE_LOW (0x18) -#define ND6_RA_PREFERENCE_DISABLED (0x10) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ra_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FLD_8(u8_t current_hop_limit); - PACK_STRUCT_FLD_8(u8_t flags); - PACK_STRUCT_FIELD(u16_t router_lifetime); - PACK_STRUCT_FIELD(u32_t reachable_time); - PACK_STRUCT_FIELD(u32_t retrans_timer); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Redirect message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct redirect_header { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); - PACK_STRUCT_FLD_S(ip6_addr_p_t destination_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Link-layer address option. */ -#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01) -#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct lladdr_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t addr[NETIF_MAX_HWADDR_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Prefix information option. */ -#define ND6_OPTION_TYPE_PREFIX_INFO (0x03) -#define ND6_PREFIX_FLAG_ON_LINK (0x80) -#define ND6_PREFIX_FLAG_AUTONOMOUS (0x40) -#define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20) -#define ND6_PREFIX_FLAG_SITE_PREFIX (0x10) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct prefix_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t prefix_length); - PACK_STRUCT_FLD_8(u8_t flags); - PACK_STRUCT_FIELD(u32_t valid_lifetime); - PACK_STRUCT_FIELD(u32_t preferred_lifetime); - PACK_STRUCT_FLD_8(u8_t reserved2[3]); - PACK_STRUCT_FLD_8(u8_t site_prefix_length); - PACK_STRUCT_FLD_S(ip6_addr_p_t prefix); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Redirected header option. */ -#define ND6_OPTION_TYPE_REDIR_HDR (0x04) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct redirected_header_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t reserved[6]); - /* Portion of redirected packet follows. */ - /* PACK_STRUCT_FLD_8(u8_t redirected[8]); */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** MTU option. */ -#define ND6_OPTION_TYPE_MTU (0x05) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct mtu_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FIELD(u32_t mtu); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Route information option. */ -#define ND6_OPTION_TYPE_ROUTE_INFO (24) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct route_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FLD_8(u8_t prefix_length); - PACK_STRUCT_FLD_8(u8_t preference); - PACK_STRUCT_FIELD(u32_t route_lifetime); - PACK_STRUCT_FLD_S(ip6_addr_p_t prefix); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Recursive DNS Server Option. */ -#if LWIP_ND6_RDNSS_MAX_DNS_SERVERS -#define LWIP_RDNSS_OPTION_MAX_SERVERS LWIP_ND6_RDNSS_MAX_DNS_SERVERS -#else -#define LWIP_RDNSS_OPTION_MAX_SERVERS 1 -#endif -#define ND6_OPTION_TYPE_RDNSS (25) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct rdnss_option { - PACK_STRUCT_FLD_8(u8_t type); - PACK_STRUCT_FLD_8(u8_t length); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FIELD(u32_t lifetime); - PACK_STRUCT_FLD_S(ip6_addr_p_t rdnss_address[LWIP_RDNSS_OPTION_MAX_SERVERS]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_HDR_PROT_ND6_H */ +/** + * @file + * ND6 protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_ND6_H +#define LWIP_HDR_PROT_ND6_H + +#include "lwip/arch.h" +#include "lwip/ip6_addr.h" +#include "lwip/prot/ip6.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Neighbor solicitation message header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ns_header { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u32_t reserved); + PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); + /* Options follow. */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Neighbor advertisement message header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct na_header { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FLD_8(u8_t flags); + PACK_STRUCT_FLD_8(u8_t reserved[3]); + PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); + /* Options follow. */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif +#define ND6_FLAG_ROUTER (0x80) +#define ND6_FLAG_SOLICITED (0x40) +#define ND6_FLAG_OVERRIDE (0x20) + +/** Router solicitation message header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct rs_header { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u32_t reserved); + /* Options follow. */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Router advertisement message header. */ +#define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80) +#define ND6_RA_FLAG_OTHER_CONFIG (0x40) +#define ND6_RA_FLAG_HOME_AGENT (0x20) +#define ND6_RA_PREFERENCE_MASK (0x18) +#define ND6_RA_PREFERENCE_HIGH (0x08) +#define ND6_RA_PREFERENCE_MEDIUM (0x00) +#define ND6_RA_PREFERENCE_LOW (0x18) +#define ND6_RA_PREFERENCE_DISABLED (0x10) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct ra_header { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FLD_8(u8_t current_hop_limit); + PACK_STRUCT_FLD_8(u8_t flags); + PACK_STRUCT_FIELD(u16_t router_lifetime); + PACK_STRUCT_FIELD(u32_t reachable_time); + PACK_STRUCT_FIELD(u32_t retrans_timer); + /* Options follow. */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Redirect message header. */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct redirect_header { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u32_t reserved); + PACK_STRUCT_FLD_S(ip6_addr_p_t target_address); + PACK_STRUCT_FLD_S(ip6_addr_p_t destination_address); + /* Options follow. */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Link-layer address option. */ +#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01) +#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct lladdr_option { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FLD_8(u8_t addr[NETIF_MAX_HWADDR_LEN]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Prefix information option. */ +#define ND6_OPTION_TYPE_PREFIX_INFO (0x03) +#define ND6_PREFIX_FLAG_ON_LINK (0x80) +#define ND6_PREFIX_FLAG_AUTONOMOUS (0x40) +#define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20) +#define ND6_PREFIX_FLAG_SITE_PREFIX (0x10) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct prefix_option { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FLD_8(u8_t prefix_length); + PACK_STRUCT_FLD_8(u8_t flags); + PACK_STRUCT_FIELD(u32_t valid_lifetime); + PACK_STRUCT_FIELD(u32_t preferred_lifetime); + PACK_STRUCT_FLD_8(u8_t reserved2[3]); + PACK_STRUCT_FLD_8(u8_t site_prefix_length); + PACK_STRUCT_FLD_S(ip6_addr_p_t prefix); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Redirected header option. */ +#define ND6_OPTION_TYPE_REDIR_HDR (0x04) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct redirected_header_option { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FLD_8(u8_t reserved[6]); + /* Portion of redirected packet follows. */ + /* PACK_STRUCT_FLD_8(u8_t redirected[8]); */ +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** MTU option. */ +#define ND6_OPTION_TYPE_MTU (0x05) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct mtu_option { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FIELD(u16_t reserved); + PACK_STRUCT_FIELD(u32_t mtu); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Route information option. */ +#define ND6_OPTION_TYPE_ROUTE_INFO (24) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct route_option { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FLD_8(u8_t prefix_length); + PACK_STRUCT_FLD_8(u8_t preference); + PACK_STRUCT_FIELD(u32_t route_lifetime); + PACK_STRUCT_FLD_S(ip6_addr_p_t prefix); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/** Recursive DNS Server Option. */ +#if LWIP_ND6_RDNSS_MAX_DNS_SERVERS +#define LWIP_RDNSS_OPTION_MAX_SERVERS LWIP_ND6_RDNSS_MAX_DNS_SERVERS +#else +#define LWIP_RDNSS_OPTION_MAX_SERVERS 1 +#endif +#define ND6_OPTION_TYPE_RDNSS (25) +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct rdnss_option { + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FIELD(u16_t reserved); + PACK_STRUCT_FIELD(u32_t lifetime); + PACK_STRUCT_FLD_S(ip6_addr_p_t rdnss_address[LWIP_RDNSS_OPTION_MAX_SERVERS]); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_ND6_H */ diff --git a/sys/include/net/prot/tcp.h b/sys/include/net/prot/tcp.h new file mode 100644 index 0000000..3c4444a --- /dev/null +++ b/sys/include/net/prot/tcp.h @@ -0,0 +1,97 @@ +/** + * @file + * TCP protocol definitions + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_PROT_TCP_H +#define LWIP_HDR_PROT_TCP_H + +#include "net/arch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Length of the TCP header, excluding options. */ +#define TCP_HLEN 20 + +/* Fields are (of course) in network byte order. + * Some fields are converted to host byte order in tcp_input(). + */ +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct tcp_hdr { + PACK_STRUCT_FIELD(u16_t src); + PACK_STRUCT_FIELD(u16_t dest); + PACK_STRUCT_FIELD(u32_t seqno); + PACK_STRUCT_FIELD(u32_t ackno); + PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); + PACK_STRUCT_FIELD(u16_t wnd); + PACK_STRUCT_FIELD(u16_t chksum); + PACK_STRUCT_FIELD(u16_t urgp); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +/* TCP header flags bits */ +#define TCP_FIN 0x01U +#define TCP_SYN 0x02U +#define TCP_RST 0x04U +#define TCP_PSH 0x08U +#define TCP_ACK 0x10U +#define TCP_URG 0x20U +#define TCP_ECE 0x40U +#define TCP_CWR 0x80U +/* Valid TCP header flags */ +#define TCP_FLAGS 0x3fU + +#define TCPH_HDRLEN(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)) +#define TCPH_FLAGS(phdr) ((u16_t)(lwip_ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)) + +#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = lwip_htons(((len) << 12) | TCPH_FLAGS(phdr)) +#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | lwip_htons(flags)) +#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = (u16_t)(lwip_htons((u16_t)((len) << 12) | (flags))) + +#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | lwip_htons(flags)) +#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags & ~lwip_htons(flags)) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_PROT_TCP_H */ diff --git a/sys/include/net/sio.h b/sys/include/net/sio.h new file mode 100644 index 0000000..fff6d25 --- /dev/null +++ b/sys/include/net/sio.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + */ + +/* + * This is the interface to the platform specific serial IO module + * It needs to be implemented by those platforms which need SLIP or PPP + */ + +#ifndef SIO_H +#define SIO_H + +#include "net/arch.h" +#include "net/opt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* If you want to define sio_fd_t elsewhere or differently, + define this in your cc.h file. */ +#ifndef __sio_fd_t_defined +typedef void * sio_fd_t; +#endif + +/* The following functions can be defined to something else in your cc.h file + or be implemented in your custom sio.c file. */ + +#ifndef sio_open +/** + * Opens a serial device for communication. + * + * @param devnum device number + * @return handle to serial device if successful, NULL otherwise + */ +sio_fd_t sio_open(u8_t devnum); +#endif + +#ifndef sio_send +/** + * Sends a single character to the serial device. + * + * @param c character to send + * @param fd serial device handle + * + * @note This function will block until the character can be sent. + */ +void sio_send(u8_t c, sio_fd_t fd); +#endif + +#ifndef sio_recv +/** + * Receives a single character from the serial device. + * + * @param fd serial device handle + * + * @note This function will block until a character is received. + */ +u8_t sio_recv(sio_fd_t fd); +#endif + +#ifndef sio_read +/** + * Reads from the serial device. + * + * @param fd serial device handle + * @param data pointer to data buffer for receiving + * @param len maximum length (in bytes) of data to receive + * @return number of bytes actually received - may be 0 if aborted by sio_read_abort + * + * @note This function will block until data can be received. The blocking + * can be cancelled by calling sio_read_abort(). + */ +u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); +#endif + +#ifndef sio_tryread +/** + * Tries to read from the serial device. Same as sio_read but returns + * immediately if no data is available and never blocks. + * + * @param fd serial device handle + * @param data pointer to data buffer for receiving + * @param len maximum length (in bytes) of data to receive + * @return number of bytes actually received + */ +u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); +#endif + +#ifndef sio_write +/** + * Writes to the serial device. + * + * @param fd serial device handle + * @param data pointer to data to send + * @param len length (in bytes) of data to send + * @return number of bytes actually sent + * + * @note This function will block until all data can be sent. + */ +u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); +#endif + +#ifndef sio_read_abort +/** + * Aborts a blocking sio_read() call. + * + * @param fd serial device handle + */ +void sio_read_abort(sio_fd_t fd); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* SIO_H */ diff --git a/sys/include/net/snmp.h b/sys/include/net/snmp.h new file mode 100644 index 0000000..ba2dd54 --- /dev/null +++ b/sys/include/net/snmp.h @@ -0,0 +1,213 @@ +/** + * @file + * SNMP support API for implementing netifs and statitics for MIB2 + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Dirk Ziegelmeier + * + */ +#ifndef LWIP_HDR_SNMP_H +#define LWIP_HDR_SNMP_H + +#include "net/opt.h" +#include "net/ip_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct udp_pcb; +struct netif; + +/** + * @defgroup netif_mib2 MIB2 statistics + * @ingroup netif + */ + +/* MIB2 statistics functions */ +#if MIB2_STATS /* don't build if not configured for use in lwipopts.h */ +/** + * @ingroup netif_mib2 + * @see RFC1213, "MIB-II, 6. Definitions" + */ +enum snmp_ifType { + snmp_ifType_other=1, /* none of the following */ + snmp_ifType_regular1822, + snmp_ifType_hdh1822, + snmp_ifType_ddn_x25, + snmp_ifType_rfc877_x25, + snmp_ifType_ethernet_csmacd, + snmp_ifType_iso88023_csmacd, + snmp_ifType_iso88024_tokenBus, + snmp_ifType_iso88025_tokenRing, + snmp_ifType_iso88026_man, + snmp_ifType_starLan, + snmp_ifType_proteon_10Mbit, + snmp_ifType_proteon_80Mbit, + snmp_ifType_hyperchannel, + snmp_ifType_fddi, + snmp_ifType_lapb, + snmp_ifType_sdlc, + snmp_ifType_ds1, /* T-1 */ + snmp_ifType_e1, /* european equiv. of T-1 */ + snmp_ifType_basicISDN, + snmp_ifType_primaryISDN, /* proprietary serial */ + snmp_ifType_propPointToPointSerial, + snmp_ifType_ppp, + snmp_ifType_softwareLoopback, + snmp_ifType_eon, /* CLNP over IP [11] */ + snmp_ifType_ethernet_3Mbit, + snmp_ifType_nsip, /* XNS over IP */ + snmp_ifType_slip, /* generic SLIP */ + snmp_ifType_ultra, /* ULTRA technologies */ + snmp_ifType_ds3, /* T-3 */ + snmp_ifType_sip, /* SMDS */ + snmp_ifType_frame_relay +}; + +/** This macro has a precision of ~49 days because sys_now returns u32_t. \#define your own if you want ~490 days. */ +#ifndef MIB2_COPY_SYSUPTIME_TO +#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) (*(ptrToVal) = (sys_now() / 10)) +#endif + +/** + * @ingroup netif_mib2 + * Increment stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs) + */ +#define MIB2_STATS_NETIF_INC(n, x) do { ++(n)->mib2_counters.x; } while(0) +/** + * @ingroup netif_mib2 + * Add value to stats member for SNMP MIB2 stats (struct stats_mib2_netif_ctrs) + */ +#define MIB2_STATS_NETIF_ADD(n, x, val) do { (n)->mib2_counters.x += (val); } while(0) + +/** + * @ingroup netif_mib2 + * Init MIB2 statistic counters in netif + * @param netif Netif to init + * @param type one of enum @ref snmp_ifType + * @param speed your link speed here (units: bits per second) + */ +#define MIB2_INIT_NETIF(netif, type, speed) do { \ + (netif)->link_type = (type); \ + (netif)->link_speed = (speed);\ + (netif)->ts = 0; \ + (netif)->mib2_counters.ifinoctets = 0; \ + (netif)->mib2_counters.ifinucastpkts = 0; \ + (netif)->mib2_counters.ifinnucastpkts = 0; \ + (netif)->mib2_counters.ifindiscards = 0; \ + (netif)->mib2_counters.ifinerrors = 0; \ + (netif)->mib2_counters.ifinunknownprotos = 0; \ + (netif)->mib2_counters.ifoutoctets = 0; \ + (netif)->mib2_counters.ifoutucastpkts = 0; \ + (netif)->mib2_counters.ifoutnucastpkts = 0; \ + (netif)->mib2_counters.ifoutdiscards = 0; \ + (netif)->mib2_counters.ifouterrors = 0; } while(0) +#else /* MIB2_STATS */ +#ifndef MIB2_COPY_SYSUPTIME_TO +#define MIB2_COPY_SYSUPTIME_TO(ptrToVal) +#endif +#define MIB2_INIT_NETIF(netif, type, speed) +#define MIB2_STATS_NETIF_INC(n, x) +#define MIB2_STATS_NETIF_ADD(n, x, val) +#endif /* MIB2_STATS */ + +/* LWIP MIB2 callbacks */ +#if LWIP_MIB2_CALLBACKS /* don't build if not configured for use in lwipopts.h */ +/* network interface */ +void mib2_netif_added(struct netif *ni); +void mib2_netif_removed(struct netif *ni); + +#if LWIP_IPV4 && LWIP_ARP +/* ARP (for atTable and ipNetToMediaTable) */ +void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip); +void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip); +#else /* LWIP_IPV4 && LWIP_ARP */ +#define mib2_add_arp_entry(ni,ip) +#define mib2_remove_arp_entry(ni,ip) +#endif /* LWIP_IPV4 && LWIP_ARP */ + +/* IP */ +#if LWIP_IPV4 +void mib2_add_ip4(struct netif *ni); +void mib2_remove_ip4(struct netif *ni); +void mib2_add_route_ip4(u8_t dflt, struct netif *ni); +void mib2_remove_route_ip4(u8_t dflt, struct netif *ni); +#endif /* LWIP_IPV4 */ + +/* UDP */ +#if LWIP_UDP +void mib2_udp_bind(struct udp_pcb *pcb); +void mib2_udp_unbind(struct udp_pcb *pcb); +#endif /* LWIP_UDP */ + +#else /* LWIP_MIB2_CALLBACKS */ +/* LWIP_MIB2_CALLBACKS support not available */ +/* define everything to be empty */ + +/* network interface */ +#define mib2_netif_added(ni) +#define mib2_netif_removed(ni) + +/* ARP */ +#define mib2_add_arp_entry(ni,ip) +#define mib2_remove_arp_entry(ni,ip) + +/* IP */ +#define mib2_add_ip4(ni) +#define mib2_remove_ip4(ni) +#define mib2_add_route_ip4(dflt, ni) +#define mib2_remove_route_ip4(dflt, ni) + +/* UDP */ +#define mib2_udp_bind(pcb) +#define mib2_udp_unbind(pcb) +#endif /* LWIP_MIB2_CALLBACKS */ + +/* for source-code compatibility reasons only, can be removed (not used internally) */ +#define NETIF_INIT_SNMP MIB2_INIT_NETIF +#define snmp_add_ifinoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifinoctets, value) +#define snmp_inc_ifinucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinucastpkts) +#define snmp_inc_ifinnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifinnucastpkts) +#define snmp_inc_ifindiscards(ni) MIB2_STATS_NETIF_INC(ni, ifindiscards) +#define snmp_inc_ifinerrors(ni) MIB2_STATS_NETIF_INC(ni, ifinerrors) +#define snmp_inc_ifinunknownprotos(ni) MIB2_STATS_NETIF_INC(ni, ifinunknownprotos) +#define snmp_add_ifoutoctets(ni,value) MIB2_STATS_NETIF_ADD(ni, ifoutoctets, value) +#define snmp_inc_ifoutucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutucastpkts) +#define snmp_inc_ifoutnucastpkts(ni) MIB2_STATS_NETIF_INC(ni, ifoutnucastpkts) +#define snmp_inc_ifoutdiscards(ni) MIB2_STATS_NETIF_INC(ni, ifoutdiscards) +#define snmp_inc_ifouterrors(ni) MIB2_STATS_NETIF_INC(ni, ifouterrors) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_SNMP_H */ diff --git a/sys/include/net/stats.h b/sys/include/net/stats.h new file mode 100644 index 0000000..6cec14a --- /dev/null +++ b/sys/include/net/stats.h @@ -0,0 +1,491 @@ +/** + * @file + * Statistics API (to be used from TCPIP thread) + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_STATS_H +#define LWIP_HDR_STATS_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if LWIP_STATS + +#ifndef LWIP_STATS_LARGE +#define LWIP_STATS_LARGE 0 +#endif + +#if LWIP_STATS_LARGE +#define STAT_COUNTER u32_t +#define STAT_COUNTER_F U32_F +#else +#define STAT_COUNTER u16_t +#define STAT_COUNTER_F U16_F +#endif + +/** Protocol related stats */ +struct stats_proto { + STAT_COUNTER xmit; /* Transmitted packets. */ + STAT_COUNTER recv; /* Received packets. */ + STAT_COUNTER fw; /* Forwarded packets. */ + STAT_COUNTER drop; /* Dropped packets. */ + STAT_COUNTER chkerr; /* Checksum error. */ + STAT_COUNTER lenerr; /* Invalid length error. */ + STAT_COUNTER memerr; /* Out of memory error. */ + STAT_COUNTER rterr; /* Routing error. */ + STAT_COUNTER proterr; /* Protocol error. */ + STAT_COUNTER opterr; /* Error in options. */ + STAT_COUNTER err; /* Misc error. */ + STAT_COUNTER cachehit; +}; + +/** IGMP stats */ +struct stats_igmp { + STAT_COUNTER xmit; /* Transmitted packets. */ + STAT_COUNTER recv; /* Received packets. */ + STAT_COUNTER drop; /* Dropped packets. */ + STAT_COUNTER chkerr; /* Checksum error. */ + STAT_COUNTER lenerr; /* Invalid length error. */ + STAT_COUNTER memerr; /* Out of memory error. */ + STAT_COUNTER proterr; /* Protocol error. */ + STAT_COUNTER rx_v1; /* Received v1 frames. */ + STAT_COUNTER rx_group; /* Received group-specific queries. */ + STAT_COUNTER rx_general; /* Received general queries. */ + STAT_COUNTER rx_report; /* Received reports. */ + STAT_COUNTER tx_join; /* Sent joins. */ + STAT_COUNTER tx_leave; /* Sent leaves. */ + STAT_COUNTER tx_report; /* Sent reports. */ +}; + +/** Memory stats */ +struct stats_mem { +#if defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY + const char *name; +#endif /* defined(LWIP_DEBUG) || LWIP_STATS_DISPLAY */ + STAT_COUNTER err; + mem_size_t avail; + mem_size_t used; + mem_size_t max; + STAT_COUNTER illegal; +}; + +/** System element stats */ +struct stats_syselem { + STAT_COUNTER used; + STAT_COUNTER max; + STAT_COUNTER err; +}; + +/** System stats */ +struct stats_sys { + struct stats_syselem sem; + struct stats_syselem mutex; + struct stats_syselem mbox; +}; + +/** SNMP MIB2 stats */ +struct stats_mib2 { + /* IP */ + u32_t ipinhdrerrors; + u32_t ipinaddrerrors; + u32_t ipinunknownprotos; + u32_t ipindiscards; + u32_t ipindelivers; + u32_t ipoutrequests; + u32_t ipoutdiscards; + u32_t ipoutnoroutes; + u32_t ipreasmoks; + u32_t ipreasmfails; + u32_t ipfragoks; + u32_t ipfragfails; + u32_t ipfragcreates; + u32_t ipreasmreqds; + u32_t ipforwdatagrams; + u32_t ipinreceives; + + /* TCP */ + u32_t tcpactiveopens; + u32_t tcppassiveopens; + u32_t tcpattemptfails; + u32_t tcpestabresets; + u32_t tcpoutsegs; + u32_t tcpretranssegs; + u32_t tcpinsegs; + u32_t tcpinerrs; + u32_t tcpoutrsts; + + /* UDP */ + u32_t udpindatagrams; + u32_t udpnoports; + u32_t udpinerrors; + u32_t udpoutdatagrams; + + /* ICMP */ + u32_t icmpinmsgs; + u32_t icmpinerrors; + u32_t icmpindestunreachs; + u32_t icmpintimeexcds; + u32_t icmpinparmprobs; + u32_t icmpinsrcquenchs; + u32_t icmpinredirects; + u32_t icmpinechos; + u32_t icmpinechoreps; + u32_t icmpintimestamps; + u32_t icmpintimestampreps; + u32_t icmpinaddrmasks; + u32_t icmpinaddrmaskreps; + u32_t icmpoutmsgs; + u32_t icmpouterrors; + u32_t icmpoutdestunreachs; + u32_t icmpouttimeexcds; + u32_t icmpoutechos; /* can be incremented by user application ('ping') */ + u32_t icmpoutechoreps; +}; + +/** + * @ingroup netif_mib2 + * SNMP MIB2 interface stats + */ +struct stats_mib2_netif_ctrs { + /** The total number of octets received on the interface, including framing characters */ + u32_t ifinoctets; + /** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were + * not addressed to a multicast or broadcast address at this sub-layer */ + u32_t ifinucastpkts; + /** The number of packets, delivered by this sub-layer to a higher (sub-)layer, which were + * addressed to a multicast or broadcast address at this sub-layer */ + u32_t ifinnucastpkts; + /** The number of inbound packets which were chosen to be discarded even though no errors had + * been detected to prevent their being deliverable to a higher-layer protocol. One possible + * reason for discarding such a packet could be to free up buffer space */ + u32_t ifindiscards; + /** For packet-oriented interfaces, the number of inbound packets that contained errors + * preventing them from being deliverable to a higher-layer protocol. For character- + * oriented or fixed-length interfaces, the number of inbound transmission units that + * contained errors preventing them from being deliverable to a higher-layer protocol. */ + u32_t ifinerrors; + /** For packet-oriented interfaces, the number of packets received via the interface which + * were discarded because of an unknown or unsupported protocol. For character-oriented + * or fixed-length interfaces that support protocol multiplexing the number of transmission + * units received via the interface which were discarded because of an unknown or unsupported + * protocol. For any interface that does not support protocol multiplexing, this counter will + * always be 0 */ + u32_t ifinunknownprotos; + /** The total number of octets transmitted out of the interface, including framing characters. */ + u32_t ifoutoctets; + /** The total number of packets that higher-level protocols requested be transmitted, and + * which were not addressed to a multicast or broadcast address at this sub-layer, including + * those that were discarded or not sent. */ + u32_t ifoutucastpkts; + /** The total number of packets that higher-level protocols requested be transmitted, and which + * were addressed to a multicast or broadcast address at this sub-layer, including + * those that were discarded or not sent. */ + u32_t ifoutnucastpkts; + /** The number of outbound packets which were chosen to be discarded even though no errors had + * been detected to prevent their being transmitted. One possible reason for discarding + * such a packet could be to free up buffer space. */ + u32_t ifoutdiscards; + /** For packet-oriented interfaces, the number of outbound packets that could not be transmitted + * because of errors. For character-oriented or fixed-length interfaces, the number of outbound + * transmission units that could not be transmitted because of errors. */ + u32_t ifouterrors; +}; + +/** lwIP stats container */ +struct stats_ { +#if LINK_STATS + /** Link level */ + struct stats_proto link; +#endif +#if ETHARP_STATS + /** ARP */ + struct stats_proto etharp; +#endif +#if IPFRAG_STATS + /** Fragmentation */ + struct stats_proto ip_frag; +#endif +#if IP_STATS + /** IP */ + struct stats_proto ip; +#endif +#if ICMP_STATS + /** ICMP */ + struct stats_proto icmp; +#endif +#if IGMP_STATS + /** IGMP */ + struct stats_igmp igmp; +#endif +#if UDP_STATS + /** UDP */ + struct stats_proto udp; +#endif +#if TCP_STATS + /** TCP */ + struct stats_proto tcp; +#endif +#if MEM_STATS + /** Heap */ + struct stats_mem mem; +#endif +#if MEMP_STATS + /** Internal memory pools */ + struct stats_mem *memp[MEMP_MAX]; +#endif +#if SYS_STATS + /** System */ + struct stats_sys sys; +#endif +#if IP6_STATS + /** IPv6 */ + struct stats_proto ip6; +#endif +#if ICMP6_STATS + /** ICMP6 */ + struct stats_proto icmp6; +#endif +#if IP6_FRAG_STATS + /** IPv6 fragmentation */ + struct stats_proto ip6_frag; +#endif +#if MLD6_STATS + /** Multicast listener discovery */ + struct stats_igmp mld6; +#endif +#if ND6_STATS + /** Neighbor discovery */ + struct stats_proto nd6; +#endif +#if MIB2_STATS + /** SNMP MIB2 */ + struct stats_mib2 mib2; +#endif +}; + +/** Global variable containing lwIP internal statistics. Add this to your debugger's watchlist. */ +extern struct stats_ lwip_stats; + +/** Init statistics */ +void stats_init(void); + +#define STATS_INC(x) ++lwip_stats.x +#define STATS_DEC(x) --lwip_stats.x +#define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \ + if (lwip_stats.x.max < lwip_stats.x.used) { \ + lwip_stats.x.max = lwip_stats.x.used; \ + } \ + } while(0) +#define STATS_GET(x) lwip_stats.x +#else /* LWIP_STATS */ +#define stats_init() +#define STATS_INC(x) +#define STATS_DEC(x) +#define STATS_INC_USED(x) +#endif /* LWIP_STATS */ + +#if TCP_STATS +#define TCP_STATS_INC(x) STATS_INC(x) +#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP") +#else +#define TCP_STATS_INC(x) +#define TCP_STATS_DISPLAY() +#endif + +#if UDP_STATS +#define UDP_STATS_INC(x) STATS_INC(x) +#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP") +#else +#define UDP_STATS_INC(x) +#define UDP_STATS_DISPLAY() +#endif + +#if ICMP_STATS +#define ICMP_STATS_INC(x) STATS_INC(x) +#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP") +#else +#define ICMP_STATS_INC(x) +#define ICMP_STATS_DISPLAY() +#endif + +#if IGMP_STATS +#define IGMP_STATS_INC(x) STATS_INC(x) +#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp, "IGMP") +#else +#define IGMP_STATS_INC(x) +#define IGMP_STATS_DISPLAY() +#endif + +#if IP_STATS +#define IP_STATS_INC(x) STATS_INC(x) +#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP") +#else +#define IP_STATS_INC(x) +#define IP_STATS_DISPLAY() +#endif + +#if IPFRAG_STATS +#define IPFRAG_STATS_INC(x) STATS_INC(x) +#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG") +#else +#define IPFRAG_STATS_INC(x) +#define IPFRAG_STATS_DISPLAY() +#endif + +#if ETHARP_STATS +#define ETHARP_STATS_INC(x) STATS_INC(x) +#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP") +#else +#define ETHARP_STATS_INC(x) +#define ETHARP_STATS_DISPLAY() +#endif + +#if LINK_STATS +#define LINK_STATS_INC(x) STATS_INC(x) +#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK") +#else +#define LINK_STATS_INC(x) +#define LINK_STATS_DISPLAY() +#endif + +#if MEM_STATS +#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y +#define MEM_STATS_INC(x) SYS_ARCH_INC(lwip_stats.mem.x, 1) +#define MEM_STATS_INC_USED(x, y) SYS_ARCH_INC(lwip_stats.mem.x, y) +#define MEM_STATS_DEC_USED(x, y) SYS_ARCH_DEC(lwip_stats.mem.x, y) +#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP") +#else +#define MEM_STATS_AVAIL(x, y) +#define MEM_STATS_INC(x) +#define MEM_STATS_INC_USED(x, y) +#define MEM_STATS_DEC_USED(x, y) +#define MEM_STATS_DISPLAY() +#endif + + #if MEMP_STATS +#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i]->x) +#define MEMP_STATS_DISPLAY(i) stats_display_memp(lwip_stats.memp[i], i) +#define MEMP_STATS_GET(x, i) STATS_GET(memp[i]->x) + #else +#define MEMP_STATS_DEC(x, i) +#define MEMP_STATS_DISPLAY(i) +#define MEMP_STATS_GET(x, i) 0 +#endif + +#if SYS_STATS +#define SYS_STATS_INC(x) STATS_INC(sys.x) +#define SYS_STATS_DEC(x) STATS_DEC(sys.x) +#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1) +#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys) +#else +#define SYS_STATS_INC(x) +#define SYS_STATS_DEC(x) +#define SYS_STATS_INC_USED(x) +#define SYS_STATS_DISPLAY() +#endif + +#if IP6_STATS +#define IP6_STATS_INC(x) STATS_INC(x) +#define IP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6, "IPv6") +#else +#define IP6_STATS_INC(x) +#define IP6_STATS_DISPLAY() +#endif + +#if ICMP6_STATS +#define ICMP6_STATS_INC(x) STATS_INC(x) +#define ICMP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp6, "ICMPv6") +#else +#define ICMP6_STATS_INC(x) +#define ICMP6_STATS_DISPLAY() +#endif + +#if IP6_FRAG_STATS +#define IP6_FRAG_STATS_INC(x) STATS_INC(x) +#define IP6_FRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6_frag, "IPv6 FRAG") +#else +#define IP6_FRAG_STATS_INC(x) +#define IP6_FRAG_STATS_DISPLAY() +#endif + +#if MLD6_STATS +#define MLD6_STATS_INC(x) STATS_INC(x) +#define MLD6_STATS_DISPLAY() stats_display_igmp(&lwip_stats.mld6, "MLDv1") +#else +#define MLD6_STATS_INC(x) +#define MLD6_STATS_DISPLAY() +#endif + +#if ND6_STATS +#define ND6_STATS_INC(x) STATS_INC(x) +#define ND6_STATS_DISPLAY() stats_display_proto(&lwip_stats.nd6, "ND") +#else +#define ND6_STATS_INC(x) +#define ND6_STATS_DISPLAY() +#endif + +#if MIB2_STATS +#define MIB2_STATS_INC(x) STATS_INC(x) +#else +#define MIB2_STATS_INC(x) +#endif + +/* Display of statistics */ +#if LWIP_STATS_DISPLAY +void stats_display(void); +void stats_display_proto(struct stats_proto *proto, const char *name); +void stats_display_igmp(struct stats_igmp *igmp, const char *name); +void stats_display_mem(struct stats_mem *mem, const char *name); +void stats_display_memp(struct stats_mem *mem, int index); +void stats_display_sys(struct stats_sys *sys); +#else /* LWIP_STATS_DISPLAY */ +#define stats_display() +#define stats_display_proto(proto, name) +#define stats_display_igmp(igmp, name) +#define stats_display_mem(mem, name) +#define stats_display_memp(mem, index) +#define stats_display_sys(sys) +#endif /* LWIP_STATS_DISPLAY */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_STATS_H */ diff --git a/sys/include/net/sys.h b/sys/include/net/sys.h new file mode 100644 index 0000000..c7e73fa --- /dev/null +++ b/sys/include/net/sys.h @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + */ + +#ifndef NET_HDR_SYS_H +#define NET_HDR_SYS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if NO_SYS + +#else /* NO_SYS */ + +/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ +#define SYS_ARCH_TIMEOUT 0xffffffffUL + +/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. + * For now we use the same magic value, but we allow this to change in future. + */ +#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT + +#include "net/err.h" +#include "net/arch/sys_arch.h" + +/** Function prototype for thread functions */ +typedef void (*lwip_thread_fn)(void *arg); + +/* Function prototypes for functions to be implemented by platform ports + (in sys_arch.c) */ + +/* Mutex functions: */ + +/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores + should be used instead */ +#ifndef LWIP_COMPAT_MUTEX +#define LWIP_COMPAT_MUTEX 0 +#endif + +#if LWIP_COMPAT_MUTEX +/* for old ports that don't have mutexes: define them to binary semaphores */ +#define sys_mutex_t sys_sem_t +#define sys_mutex_new(mutex) sys_sem_new(mutex, 1) +#define sys_mutex_lock(mutex) sys_sem_wait(mutex) +#define sys_mutex_unlock(mutex) sys_sem_signal(mutex) +#define sys_mutex_free(mutex) sys_sem_free(mutex) +#define sys_mutex_valid(mutex) sys_sem_valid(mutex) +#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) + +#else /* LWIP_COMPAT_MUTEX */ + +/** + * @ingroup sys_mutex + * Create a new mutex. + * Note that mutexes are expected to not be taken recursively by the lwIP code, + * so both implementation types (recursive or non-recursive) should work. + * @param mutex pointer to the mutex to create + * @return ERR_OK if successful, another err_t otherwise + */ +err_t sys_mutex_new(sys_mutex_t *mutex); +/** + * @ingroup sys_mutex + * Lock a mutex + * @param mutex the mutex to lock + */ +void sys_mutex_lock(sys_mutex_t *mutex); +/** + * @ingroup sys_mutex + * Unlock a mutex + * @param mutex the mutex to unlock + */ +void sys_mutex_unlock(sys_mutex_t *mutex); +/** + * @ingroup sys_mutex + * Delete a semaphore + * @param mutex the mutex to delete + */ +void sys_mutex_free(sys_mutex_t *mutex); +#ifndef sys_mutex_valid +/** + * @ingroup sys_mutex + * Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid + */ +int sys_mutex_valid(sys_mutex_t *mutex); +#endif +#ifndef sys_mutex_set_invalid +/** + * @ingroup sys_mutex + * Set a mutex invalid so that sys_mutex_valid returns 0 + */ +void sys_mutex_set_invalid(sys_mutex_t *mutex); +#endif +#endif /* LWIP_COMPAT_MUTEX */ + +/* Semaphore functions: */ + +/** + * @ingroup sys_sem + * Create a new semaphore + * @param sem pointer to the semaphore to create + * @param count initial count of the semaphore + * @return ERR_OK if successful, another err_t otherwise + */ +err_t sys_sem_new(sys_sem_t **sem, u8_t count); +/** + * @ingroup sys_sem + * Signals a semaphore + * @param sem the semaphore to signal + */ +void sys_sem_signal(struct sys_sem **s); +/** + * @ingroup sys_sem + * Wait for a semaphore for the specified timeout + * @param sem the semaphore to wait for + * @param timeout timeout in milliseconds to wait (0 = wait forever) + * @return time (in milliseconds) waited for the semaphore + * or SYS_ARCH_TIMEOUT on timeout + */ +uint32_t sys_arch_sem_wait(struct sys_sem **s, uint32_t timeout); +/** + * @ingroup sys_sem + * Delete a semaphore + * @param sem semaphore to delete + */ +void sys_sem_free(sys_sem_t **sem); +/** Wait for a semaphore - forever/no timeout */ +#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0) +#ifndef sys_sem_valid +/** + * @ingroup sys_sem + * Check if a semaphore is valid/allocated: return 1 for valid, 0 for invalid + */ +int sys_sem_valid(struct sys_sem **s); +#endif +#ifndef sys_sem_set_invalid +/** + * @ingroup sys_sem + * Set a semaphore invalid so that sys_sem_valid returns 0 + */ +void sys_sem_set_invalid(struct sys_sem **s); +#endif +#ifndef sys_sem_valid_val +/** + * Same as sys_sem_valid() but taking a value, not a pointer + */ +#define sys_sem_valid_val(sem) sys_sem_valid(&(sem)) +#endif +#ifndef sys_sem_set_invalid_val +/** + * Same as sys_sem_set_invalid() but taking a value, not a pointer + */ +#define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem)) +#endif + +#ifndef sys_msleep +/** + * @ingroup sys_misc + * Sleep for specified number of ms + */ +void sys_msleep(u32_t ms); /* only has a (close to) 1 ms resolution. */ +#endif + +/* Mailbox functions. */ + +/** + * @ingroup sys_mbox + * Create a new mbox of specified size + * @param mbox pointer to the mbox to create + * @param size (minimum) number of messages in this mbox + * @return ERR_OK if successful, another err_t otherwise + */ +err_t sys_mbox_new(struct sys_mbox **mb, int size); +/** + * @ingroup sys_mbox + * Post a message to an mbox - may not fail + * -> blocks if full, only used from tasks not from ISR + * @param mbox mbox to posts the message + * @param msg message to post (ATTENTION: can be NULL) + */ +void sys_mbox_post(struct sys_mbox **mb, void *msg); +/** + * @ingroup sys_mbox + * Try to post a message to an mbox - may fail if full or ISR + * @param mbox mbox to posts the message + * @param msg message to post (ATTENTION: can be NULL) + */ +err_t sys_mbox_trypost(struct sys_mbox **mb, void *msg); +/** + * @ingroup sys_mbox + * Wait for a new message to arrive in the mbox + * @param mbox mbox to get a message from + * @param msg pointer where the message is stored + * @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever) + * @return time (in milliseconds) waited for a message, may be 0 if not waited + or SYS_ARCH_TIMEOUT on timeout + * The returned time has to be accurate to prevent timer jitter! + */ +uint32_t sys_arch_mbox_fetch(struct sys_mbox **mb, void **msg, uint32_t timeout); +/* Allow port to override with a macro, e.g. special timeout for sys_arch_mbox_fetch() */ +#ifndef sys_arch_mbox_tryfetch +/** + * @ingroup sys_mbox + * Wait for a new message to arrive in the mbox + * @param mbox mbox to get a message from + * @param msg pointer where the message is stored + * @return 0 (milliseconds) if a message has been received + * or SYS_MBOX_EMPTY if the mailbox is empty + */ +uint32_t sys_arch_mbox_tryfetch(struct sys_mbox **mb, void **msg); +#endif +/** + * For now, we map straight to sys_arch implementation. + */ +#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) +/** + * @ingroup sys_mbox + * Delete an mbox + * @param mbox mbox to delete + */ +void sys_mbox_free(struct sys_mbox **mb); +#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0) +#ifndef sys_mbox_valid +/** + * @ingroup sys_mbox + * Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid + */ +int sys_mbox_valid(struct sys_mbox **mb); +#endif +#ifndef sys_mbox_set_invalid +/** + * @ingroup sys_mbox + * Set an mbox invalid so that sys_mbox_valid returns 0 + */ +void sys_mbox_set_invalid(struct sys_mbox **mb); +#endif +#ifndef sys_mbox_valid_val +/** + * Same as sys_mbox_valid() but taking a value, not a pointer + */ +#define sys_mbox_valid_val(mbox) sys_mbox_valid(&(mbox)) +#endif +#ifndef sys_mbox_set_invalid_val +/** + * Same as sys_mbox_set_invalid() but taking a value, not a pointer + */ +#define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox)) +#endif + + +/** + * @ingroup sys_misc + * The only thread function: + * Creates a new thread + * ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!) + * @param name human-readable name for the thread (used for debugging purposes) + * @param thread thread-function + * @param arg parameter passed to 'thread' + * @param stacksize stack size in bytes for the new thread (may be ignored by ports) + * @param prio priority of the new thread (may be ignored by ports) */ +sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio); + +#endif /* NO_SYS */ + +/* sys_init() must be called before anything else. */ +void sys_init(void); + +#ifndef sys_jiffies +/** + * Ticks/jiffies since power up. + */ +u32_t sys_jiffies(void); +#endif + +/** + * @ingroup sys_time + * Returns the current time in milliseconds, + * may be the same as sys_jiffies or at least based on it. + */ +u32_t sys_now(void); + +/* Critical Region Protection */ +/* These functions must be implemented in the sys_arch.c file. + In some implementations they can provide a more light-weight protection + mechanism than using semaphores. Otherwise semaphores can be used for + implementation */ +#ifndef SYS_ARCH_PROTECT +/** SYS_LIGHTWEIGHT_PROT + * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection + * for certain critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#if SYS_LIGHTWEIGHT_PROT + +/** + * @ingroup sys_prot + * SYS_ARCH_DECL_PROTECT + * declare a protection variable. This macro will default to defining a variable of + * type sys_prot_t. If a particular port needs a different implementation, then + * this macro may be defined in sys_arch.h. + */ +#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev +/** + * @ingroup sys_prot + * SYS_ARCH_PROTECT + * Perform a "fast" protect. This could be implemented by + * disabling interrupts for an embedded system or by using a semaphore or + * mutex. The implementation should allow calling SYS_ARCH_PROTECT when + * already protected. The old protection level is returned in the variable + * "lev". This macro will default to calling the sys_arch_protect() function + * which should be implemented in sys_arch.c. If a particular port needs a + * different implementation, then this macro may be defined in sys_arch.h + */ +#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() +/** + * @ingroup sys_prot + * SYS_ARCH_UNPROTECT + * Perform a "fast" set of the protection level to "lev". This could be + * implemented by setting the interrupt level to "lev" within the MACRO or by + * using a semaphore or mutex. This macro will default to calling the + * sys_arch_unprotect() function which should be implemented in + * sys_arch.c. If a particular port needs a different implementation, then + * this macro may be defined in sys_arch.h + */ +#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) +sys_prot_t sys_arch_protect(void); +void sys_arch_unprotect(sys_prot_t pval); + +#else + +#define SYS_ARCH_DECL_PROTECT(lev) +#define SYS_ARCH_PROTECT(lev) +#define SYS_ARCH_UNPROTECT(lev) + +#endif /* SYS_LIGHTWEIGHT_PROT */ + +#endif /* SYS_ARCH_PROTECT */ + +/* + * Macros to set/get and increase/decrease variables in a thread-safe way. + * Use these for accessing variable that are used from more than one thread. + */ + +#ifndef SYS_ARCH_INC +#define SYS_ARCH_INC(var, val) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + var += val; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_INC */ + +#ifndef SYS_ARCH_DEC +#define SYS_ARCH_DEC(var, val) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + var -= val; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_DEC */ + +#ifndef SYS_ARCH_GET +#define SYS_ARCH_GET(var, ret) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + ret = var; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_GET */ + +#ifndef SYS_ARCH_SET +#define SYS_ARCH_SET(var, val) do { \ + SYS_ARCH_DECL_PROTECT(old_level); \ + SYS_ARCH_PROTECT(old_level); \ + var = val; \ + SYS_ARCH_UNPROTECT(old_level); \ + } while(0) +#endif /* SYS_ARCH_SET */ + + +#ifdef __cplusplus +} +#endif + +#endif /* NET_HDR_SYS_H */ diff --git a/sys/include/net/tcp.h b/sys/include/net/tcp.h new file mode 100644 index 0000000..4f321fb --- /dev/null +++ b/sys/include/net/tcp.h @@ -0,0 +1,433 @@ +/** + * @file + * TCP API (to be used from TCPIP thread)\n + * See also @ref tcp_raw + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_TCP_H +#define LWIP_HDR_TCP_H + +#include "net/opt.h" + +#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ + +#include "net/mem.h" +#include "net/pbuf.h" +#include "net/ip.h" +#include "net/icmp.h" +#include "net/err.h" +#include "net/ip6.h" +#include "net/ip6_addr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct tcp_pcb; + +/** Function prototype for tcp accept callback functions. Called when a new + * connection can be accepted on a listening pcb. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param newpcb The new connection pcb + * @param err An error code if there has been an error accepting. + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err); + +/** Function prototype for tcp receive callback functions. Called when data has + * been received. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb The connection pcb which received data + * @param p The received data (or NULL when the connection has been closed!) + * @param err An error code if there has been an error receiving + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb, + struct pbuf *p, err_t err); + +/** Function prototype for tcp sent callback functions. Called when sent data has + * been acknowledged by the remote side. Use it to free corresponding resources. + * This also means that the pcb has now space available to send new data. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb The connection pcb for which data has been acknowledged + * @param len The amount of bytes acknowledged + * @return ERR_OK: try to send some data by calling tcp_output + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb, + u16_t len); + +/** Function prototype for tcp poll callback functions. Called periodically as + * specified by @see tcp_poll. + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb tcp pcb + * @return ERR_OK: try to send some data by calling tcp_output + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + */ +typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb); + +/** Function prototype for tcp error callback functions. Called when the pcb + * receives a RST or is unexpectedly closed for any other reason. + * + * @note The corresponding pcb is already freed when this callback is called! + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param err Error code to indicate why the pcb has been closed + * ERR_ABRT: aborted through tcp_abort or by a TCP timer + * ERR_RST: the connection was reset by the remote host + */ +typedef void (*tcp_err_fn)(void *arg, err_t err); + +/** Function prototype for tcp connected callback functions. Called when a pcb + * is connected to the remote side after initiating a connection attempt by + * calling tcp_connect(). + * + * @param arg Additional argument to pass to the callback function (@see tcp_arg()) + * @param tpcb The connection pcb which is connected + * @param err An unused error code, always ERR_OK currently ;-) @todo! + * Only return ERR_ABRT if you have called tcp_abort from within the + * callback function! + * + * @note When a connection attempt fails, the error callback is currently called! + */ +typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err); + +#if LWIP_WND_SCALE +#define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale)) +#define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale)) +#define TCPWND16(x) ((u16_t)LWIP_MIN((x), 0xFFFF)) +#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND))) +typedef u32_t tcpwnd_size_t; +#else +#define RCV_WND_SCALE(pcb, wnd) (wnd) +#define SND_WND_SCALE(pcb, wnd) (wnd) +#define TCPWND16(x) (x) +#define TCP_WND_MAX(pcb) TCP_WND +typedef u16_t tcpwnd_size_t; +#endif + +#if LWIP_WND_SCALE || TCP_LISTEN_BACKLOG || LWIP_TCP_TIMESTAMPS +typedef u16_t tcpflags_t; +#else +typedef u8_t tcpflags_t; +#endif + +enum tcp_state { + CLOSED = 0, + LISTEN = 1, + SYN_SENT = 2, + SYN_RCVD = 3, + ESTABLISHED = 4, + FIN_WAIT_1 = 5, + FIN_WAIT_2 = 6, + CLOSE_WAIT = 7, + CLOSING = 8, + LAST_ACK = 9, + TIME_WAIT = 10 +}; + +/** + * members common to struct tcp_pcb and struct tcp_listen_pcb + */ +#define TCP_PCB_COMMON(type) \ + type *next; /* for the linked list */ \ + void *callback_arg; \ + enum tcp_state state; /* TCP state */ \ + u8_t prio; \ + /* ports are in host byte order */ \ + u16_t local_port + + +/** the TCP protocol control block for listening pcbs */ +struct tcp_pcb_listen { +/** Common members of all PCB types */ + IP_PCB; +/** Protocol specific PCB members */ + TCP_PCB_COMMON(struct tcp_pcb_listen); + +#if LWIP_CALLBACK_API + /* Function to call when a listener has been connected. */ + tcp_accept_fn accept; +#endif /* LWIP_CALLBACK_API */ + +#if TCP_LISTEN_BACKLOG + u8_t backlog; + u8_t accepts_pending; +#endif /* TCP_LISTEN_BACKLOG */ +}; + + +/** the TCP protocol control block */ +struct tcp_pcb { +/** common PCB members */ + IP_PCB; +/** protocol specific PCB members */ + TCP_PCB_COMMON(struct tcp_pcb); + + /* ports are in host byte order */ + u16_t remote_port; + + tcpflags_t flags; +#define TF_ACK_DELAY 0x01U /* Delayed ACK. */ +#define TF_ACK_NOW 0x02U /* Immediate ACK. */ +#define TF_INFR 0x04U /* In fast recovery. */ +#define TF_CLOSEPEND 0x08U /* If this is set, tcp_close failed to enqueue the FIN (retried in tcp_tmr) */ +#define TF_RXCLOSED 0x10U /* rx closed by tcp_shutdown */ +#define TF_FIN 0x20U /* Connection was closed locally (FIN segment enqueued). */ +#define TF_NODELAY 0x40U /* Disable Nagle algorithm */ +#define TF_NAGLEMEMERR 0x80U /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ +#if LWIP_WND_SCALE +#define TF_WND_SCALE 0x0100U /* Window Scale option enabled */ +#endif +#if TCP_LISTEN_BACKLOG +#define TF_BACKLOGPEND 0x0200U /* If this is set, a connection pcb has increased the backlog on its listener */ +#endif +#if LWIP_TCP_TIMESTAMPS +#define TF_TIMESTAMP 0x0400U /* Timestamp option enabled */ +#endif + + /* the rest of the fields are in host byte order + as we have to do some math with them */ + + /* Timers */ + u8_t polltmr, pollinterval; + u8_t last_timer; + u32_t tmr; + + /* receiver variables */ + u32_t rcv_nxt; /* next seqno expected */ + tcpwnd_size_t rcv_wnd; /* receiver window available */ + tcpwnd_size_t rcv_ann_wnd; /* receiver window to announce */ + u32_t rcv_ann_right_edge; /* announced right edge of window */ + + /* Retransmission timer. */ + s16_t rtime; + + u16_t mss; /* maximum segment size */ + + /* RTT (round trip time) estimation variables */ + u32_t rttest; /* RTT estimate in 500ms ticks */ + u32_t rtseq; /* sequence number being timed */ + s16_t sa, sv; /* @todo document this */ + + s16_t rto; /* retransmission time-out */ + u8_t nrtx; /* number of retransmissions */ + + /* fast retransmit/recovery */ + u8_t dupacks; + u32_t lastack; /* Highest acknowledged seqno. */ + + /* congestion avoidance/control variables */ + tcpwnd_size_t cwnd; + tcpwnd_size_t ssthresh; + + /* sender variables */ + u32_t snd_nxt; /* next new seqno to be sent */ + u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last + window update. */ + u32_t snd_lbb; /* Sequence number of next byte to be buffered. */ + tcpwnd_size_t snd_wnd; /* sender window */ + tcpwnd_size_t snd_wnd_max; /* the maximum sender window announced by the remote host */ + + tcpwnd_size_t snd_buf; /* Available buffer space for sending (in bytes). */ +#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) + u16_t snd_queuelen; /* Number of pbufs currently in the send buffer. */ + +#if TCP_OVERSIZE + /* Extra bytes available at the end of the last pbuf in unsent. */ + u16_t unsent_oversize; +#endif /* TCP_OVERSIZE */ + + /* These are ordered by sequence number: */ + struct tcp_seg *unsent; /* Unsent (queued) segments. */ + struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ +#if TCP_QUEUE_OOSEQ + struct tcp_seg *ooseq; /* Received out of sequence segments. */ +#endif /* TCP_QUEUE_OOSEQ */ + + struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */ + +#if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG + struct tcp_pcb_listen* listener; +#endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */ + +#if LWIP_CALLBACK_API + /* Function to be called when more send buffer space is available. */ + tcp_sent_fn sent; + /* Function to be called when (in-sequence) data has arrived. */ + tcp_recv_fn recv; + /* Function to be called when a connection has been set up. */ + tcp_connected_fn connected; + /* Function which is called periodically. */ + tcp_poll_fn poll; + /* Function to be called whenever a fatal error occurs. */ + tcp_err_fn errf; +#endif /* LWIP_CALLBACK_API */ + +#if LWIP_TCP_TIMESTAMPS + u32_t ts_lastacksent; + u32_t ts_recent; +#endif /* LWIP_TCP_TIMESTAMPS */ + + /* idle time before KEEPALIVE is sent */ + u32_t keep_idle; +#if LWIP_TCP_KEEPALIVE + u32_t keep_intvl; + u32_t keep_cnt; +#endif /* LWIP_TCP_KEEPALIVE */ + + /* Persist timer counter */ + u8_t persist_cnt; + /* Persist timer back-off */ + u8_t persist_backoff; + + /* KEEPALIVE counter */ + u8_t keep_cnt_sent; + +#if LWIP_WND_SCALE + u8_t snd_scale; + u8_t rcv_scale; +#endif +}; + +#if LWIP_EVENT_API + +enum lwip_event { + LWIP_EVENT_ACCEPT, + LWIP_EVENT_SENT, + LWIP_EVENT_RECV, + LWIP_EVENT_CONNECTED, + LWIP_EVENT_POLL, + LWIP_EVENT_ERR +}; + +err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, + enum lwip_event, + struct pbuf *p, + u16_t size, + err_t err); + +#endif /* LWIP_EVENT_API */ + +/* Application program's interface: */ +struct tcp_pcb * tcp_new (void); +struct tcp_pcb * tcp_new_ip_type (u8_t type); + +void tcp_arg (struct tcp_pcb *pcb, void *arg); +#if LWIP_CALLBACK_API +void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv); +void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent); +void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); +void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); +#endif /* LWIP_CALLBACK_API */ +void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval); + +#if LWIP_TCP_TIMESTAMPS +#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss) +#else /* LWIP_TCP_TIMESTAMPS */ +#define tcp_mss(pcb) ((pcb)->mss) +#endif /* LWIP_TCP_TIMESTAMPS */ +#define tcp_sndbuf(pcb) (TCPWND16((pcb)->snd_buf)) +#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) +/** @ingroup tcp_raw */ +#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) +/** @ingroup tcp_raw */ +#define tcp_nagle_enable(pcb) ((pcb)->flags = (tcpflags_t)((pcb)->flags & ~TF_NODELAY)) +/** @ingroup tcp_raw */ +#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) + +#if TCP_LISTEN_BACKLOG +#define tcp_backlog_set(pcb, new_backlog) do { \ + LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", (pcb)->state == LISTEN); \ + ((struct tcp_pcb_listen *)(pcb))->backlog = ((new_backlog) ? (new_backlog) : 1); } while(0) +void tcp_backlog_delayed(struct tcp_pcb* pcb); +void tcp_backlog_accepted(struct tcp_pcb* pcb); +#else /* TCP_LISTEN_BACKLOG */ +#define tcp_backlog_set(pcb, new_backlog) +#define tcp_backlog_delayed(pcb) +#define tcp_backlog_accepted(pcb) +#endif /* TCP_LISTEN_BACKLOG */ +#define tcp_accepted(pcb) /* compatibility define, not needed any more */ + +void tcp_recved (struct tcp_pcb *pcb, u16_t len); +err_t tcp_bind (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, + u16_t port); +err_t tcp_connect (struct tcp_pcb *pcb, const ip_addr_t *ipaddr, + u16_t port, tcp_connected_fn connected); + +struct tcp_pcb * tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err); +struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); +/** @ingroup tcp_raw */ +#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) + +void tcp_abort (struct tcp_pcb *pcb); +err_t tcp_close (struct tcp_pcb *pcb); +err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx); + +/* Flags for "apiflags" parameter in tcp_write */ +#define TCP_WRITE_FLAG_COPY 0x01 +#define TCP_WRITE_FLAG_MORE 0x02 + +err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, + u8_t apiflags); + +void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); + +#define TCP_PRIO_MIN 1 +#define TCP_PRIO_NORMAL 64 +#define TCP_PRIO_MAX 127 + +err_t tcp_output (struct tcp_pcb *pcb); + + +const char* tcp_debug_state_str(enum tcp_state s); + +/* for compatibility with older implementation */ +#define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6) + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_TCP */ + +#endif /* LWIP_HDR_TCP_H */ diff --git a/sys/include/net/timeouts.h b/sys/include/net/timeouts.h new file mode 100644 index 0000000..e0e4b52 --- /dev/null +++ b/sys/include/net/timeouts.h @@ -0,0 +1,121 @@ +/** + * @file + * Timer implementations + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * Simon Goldschmidt + * + */ +#ifndef LWIP_HDR_TIMEOUTS_H +#define LWIP_HDR_TIMEOUTS_H + +#include "net/opt.h" +#include "net/err.h" +#if !NO_SYS +#include "net/sys.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef LWIP_DEBUG_TIMERNAMES +#ifdef LWIP_DEBUG +#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG +#else /* LWIP_DEBUG */ +#define LWIP_DEBUG_TIMERNAMES 0 +#endif /* LWIP_DEBUG*/ +#endif + +/** Function prototype for a stack-internal timer function that has to be + * called at a defined interval */ +typedef void (* lwip_cyclic_timer_handler)(void); + +/** This struct contains information about a stack-internal timer function + that has to be called at a defined interval */ +struct lwip_cyclic_timer { + u32_t interval_ms; + lwip_cyclic_timer_handler handler; +#if LWIP_DEBUG_TIMERNAMES + const char* handler_name; +#endif /* LWIP_DEBUG_TIMERNAMES */ +}; + +/** This array contains all stack-internal cyclic timers. To get the number of + * timers, use LWIP_ARRAYSIZE() */ +extern const struct lwip_cyclic_timer lwip_cyclic_timers[]; + +#if LWIP_TIMERS + +/** Function prototype for a timeout callback function. Register such a function + * using sys_timeout(). + * + * @param arg Additional argument to pass to the function - set up by sys_timeout() + */ +typedef void (* sys_timeout_handler)(void *arg); + +struct sys_timeo { + struct sys_timeo *next; + u32_t time; + sys_timeout_handler h; + void *arg; +#if LWIP_DEBUG_TIMERNAMES + const char* handler_name; +#endif /* LWIP_DEBUG_TIMERNAMES */ +}; + +void sys_timeouts_init(void); + +#if LWIP_DEBUG_TIMERNAMES +void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); +#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) +#else /* LWIP_DEBUG_TIMERNAMES */ +void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); +#endif /* LWIP_DEBUG_TIMERNAMES */ + +void sys_untimeout(sys_timeout_handler handler, void *arg); +void sys_restart_timeouts(void); +#if NO_SYS +void sys_check_timeouts(void); +u32_t sys_timeouts_sleeptime(void); +#else /* NO_SYS */ +void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); +#endif /* NO_SYS */ + + +#endif /* LWIP_TIMERS */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_HDR_TIMEOUTS_H */ diff --git a/sys/include/net/udp.h b/sys/include/net/udp.h new file mode 100644 index 0000000..129d380 --- /dev/null +++ b/sys/include/net/udp.h @@ -0,0 +1,182 @@ +/** + * @file + * UDP API (to be used from TCPIP thread)\n + * See also @ref udp_raw + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ +#ifndef LWIP_HDR_UDP_H +#define LWIP_HDR_UDP_H + +#include "net/opt.h" + +#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ + +#include "net/pbuf.h" +#include "net/netif.h" +#include "net/ip_addr.h" +#include "net/ip.h" +#include "net/ip6_addr.h" +#include "net/prot/udp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define UDP_FLAGS_NOCHKSUM 0x01U +#define UDP_FLAGS_UDPLITE 0x02U +#define UDP_FLAGS_CONNECTED 0x04U +#define UDP_FLAGS_MULTICAST_LOOP 0x08U + +struct udp_pcb; + +/** Function prototype for udp pcb receive callback functions + * addr and port are in same byte order as in the pcb + * The callback is responsible for freeing the pbuf + * if it's not used any more. + * + * ATTENTION: Be aware that 'addr' might point into the pbuf 'p' so freeing this pbuf + * can make 'addr' invalid, too. + * + * @param arg user supplied argument (udp_pcb.recv_arg) + * @param pcb the udp_pcb which received data + * @param p the packet buffer that was received + * @param addr the remote IP address from which the packet was received + * @param port the remote port from which the packet was received + */ +typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *addr, u16_t port); + +/** the UDP protocol control block */ +struct udp_pcb { +/** Common members of all PCB types */ + IP_PCB; + +/* Protocol specific PCB members */ + + struct udp_pcb *next; + + u8_t flags; + /** ports are in host byte order */ + u16_t local_port, remote_port; + +#if LWIP_MULTICAST_TX_OPTIONS + /** outgoing network interface for multicast packets */ + ip_addr_t multicast_ip; + /** TTL for outgoing multicast packets */ + u8_t mcast_ttl; +#endif /* LWIP_MULTICAST_TX_OPTIONS */ + +#if LWIP_UDPLITE + /** used for UDP_LITE only */ + u16_t chksum_len_rx, chksum_len_tx; +#endif /* LWIP_UDPLITE */ + + /** receive callback function */ + udp_recv_fn recv; + /** user-supplied argument for the recv callback */ + void *recv_arg; +}; +/* udp_pcbs export for external reference (e.g. SNMP agent) */ +extern struct udp_pcb *udp_pcbs; + +/* The following functions is the application layer interface to the + UDP code. */ +struct udp_pcb * udp_new (void); +struct udp_pcb * udp_new_ip_type(u8_t type); +void udp_remove (struct udp_pcb *pcb); +err_t udp_bind (struct udp_pcb *pcb, const ip_addr_t *ipaddr, + u16_t port); +err_t udp_connect (struct udp_pcb *pcb, const ip_addr_t *ipaddr, + u16_t port); +void udp_disconnect (struct udp_pcb *pcb); +void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, + void *recv_arg); +err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *dst_ip, u16_t dst_port, + struct netif *netif); +err_t udp_sendto_if_src(struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *dst_ip, u16_t dst_port, + struct netif *netif, const ip_addr_t *src_ip); +err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *dst_ip, u16_t dst_port); +err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); + +#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP +err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *dst_ip, u16_t dst_port, + struct netif *netif, u8_t have_chksum, + u16_t chksum); +err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *dst_ip, u16_t dst_port, + u8_t have_chksum, u16_t chksum); +err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, + u8_t have_chksum, u16_t chksum); +err_t udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif, + u8_t have_chksum, u16_t chksum, const ip_addr_t *src_ip); +#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ + +#define udp_flags(pcb) ((pcb)->flags) +#define udp_setflags(pcb, f) ((pcb)->flags = (f)) + +/* The following functions are the lower layer interface to UDP. */ +void udp_input (struct pbuf *p, struct netif *inp); + +void udp_init (void); + +/* for compatibility with older implementation */ +#define udp_new_ip6() udp_new_ip_type(IPADDR_TYPE_V6) + +#if LWIP_MULTICAST_TX_OPTIONS +#define udp_set_multicast_netif_addr(pcb, ip4addr) ip_addr_copy_from_ip4((pcb)->multicast_ip, *(ip4addr)) +#define udp_get_multicast_netif_addr(pcb) ip_2_ip4(&(pcb)->multicast_ip) +#define udp_set_multicast_ttl(pcb, value) do { (pcb)->mcast_ttl = value; } while(0) +#define udp_get_multicast_ttl(pcb) ((pcb)->mcast_ttl) +#endif /* LWIP_MULTICAST_TX_OPTIONS */ + +#if UDP_DEBUG +void udp_debug_print(struct udp_hdr *udphdr); +#else +#define udp_debug_print(udphdr) +#endif + +void udp_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_UDP */ + +#endif /* LWIP_HDR_UDP_H */ diff --git a/sys/include/netif/lowpan6.h b/sys/include/netif/lowpan6.h new file mode 100644 index 0000000..e72add1 --- /dev/null +++ b/sys/include/netif/lowpan6.h @@ -0,0 +1,86 @@ +/** + * @file + * + * 6LowPAN output for IPv6. Uses ND tables for link-layer addressing. Fragments packets to 6LowPAN units. + */ + +/* + * Copyright (c) 2015 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * + * Please coordinate changes and requests with Ivan Delamer + * + */ + +#ifndef LWIP_HDR_LOWPAN6_H +#define LWIP_HDR_LOWPAN6_H + +#include "netif/lowpan6_opts.h" + +#if LWIP_IPV6 && LWIP_6LOWPAN /* don't build if not configured for use in lwipopts.h */ + +#include "net/pbuf.h" +#include "net/ip.h" +#include "net/ip_addr.h" +#include "net/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** 1 second period */ +#define LOWPAN6_TMR_INTERVAL 1000 + +void lowpan6_tmr(void); + +err_t lowpan6_set_context(u8_t index, const ip6_addr_t * context); +err_t lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low); + +#if LWIP_IPV4 +err_t lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr); +#endif /* LWIP_IPV4 */ +err_t lowpan6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr); +err_t lowpan6_input(struct pbuf * p, struct netif *netif); +err_t lowpan6_if_init(struct netif *netif); + +/* pan_id in network byte order. */ +err_t lowpan6_set_pan_id(u16_t pan_id); + +#if !NO_SYS +err_t tcpip_6lowpan_input(struct pbuf *p, struct netif *inp); +#endif /* !NO_SYS */ + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_IPV6 && LWIP_6LOWPAN */ + +#endif /* LWIP_HDR_LOWPAN6_H */ diff --git a/sys/include/netif/lowpan6_opts.h b/sys/include/netif/lowpan6_opts.h new file mode 100644 index 0000000..19c64b6 --- /dev/null +++ b/sys/include/netif/lowpan6_opts.h @@ -0,0 +1,70 @@ +/** + * @file + * 6LowPAN options list + */ + +/* + * Copyright (c) 2015 Inico Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Ivan Delamer + * + * + * Please coordinate changes and requests with Ivan Delamer + * + */ + +#ifndef LWIP_HDR_LOWPAN6_OPTS_H +#define LWIP_HDR_LOWPAN6_OPTS_H + +#include "net/opt.h" + +#ifndef LWIP_6LOWPAN +#define LWIP_6LOWPAN 0 +#endif + +#ifndef LWIP_6LOWPAN_NUM_CONTEXTS +#define LWIP_6LOWPAN_NUM_CONTEXTS 10 +#endif + +#ifndef LWIP_6LOWPAN_INFER_SHORT_ADDRESS +#define LWIP_6LOWPAN_INFER_SHORT_ADDRESS 1 +#endif + +#ifndef LWIP_6LOWPAN_IPHC +#define LWIP_6LOWPAN_IPHC 1 +#endif + +#ifndef LWIP_6LOWPAN_HW_CRC +#define LWIP_6LOWPAN_HW_CRC 1 +#endif + +#ifndef LOWPAN6_DEBUG +#define LOWPAN6_DEBUG LWIP_DBG_OFF +#endif + +#endif /* LWIP_HDR_LOWPAN6_OPTS_H */ diff --git a/sys/include/netif/ppp/chap-md5.h b/sys/include/netif/ppp/chap-md5.h new file mode 100644 index 0000000..eb0269f --- /dev/null +++ b/sys/include/netif/ppp/chap-md5.h @@ -0,0 +1,36 @@ +/* + * chap-md5.h - New CHAP/MD5 implementation. + * + * Copyright (c) 2003 Paul Mackerras. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 3. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Paul Mackerras + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +extern const struct chap_digest_type md5_digest; + +#endif /* PPP_SUPPORT && CHAP_SUPPORT */ diff --git a/sys/include/netif/ppp/chap-new.h b/sys/include/netif/ppp/chap-new.h new file mode 100644 index 0000000..64eae32 --- /dev/null +++ b/sys/include/netif/ppp/chap-new.h @@ -0,0 +1,192 @@ +/* + * chap-new.c - New CHAP implementation. + * + * Copyright (c) 2003 Paul Mackerras. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 3. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Paul Mackerras + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && CHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef CHAP_H +#define CHAP_H + +#include "ppp.h" + +/* + * CHAP packets begin with a standard header with code, id, len (2 bytes). + */ +#define CHAP_HDRLEN 4 + +/* + * Values for the code field. + */ +#define CHAP_CHALLENGE 1 +#define CHAP_RESPONSE 2 +#define CHAP_SUCCESS 3 +#define CHAP_FAILURE 4 + +/* + * CHAP digest codes. + */ +#define CHAP_MD5 5 +#if MSCHAP_SUPPORT +#define CHAP_MICROSOFT 0x80 +#define CHAP_MICROSOFT_V2 0x81 +#endif /* MSCHAP_SUPPORT */ + +/* + * Semi-arbitrary limits on challenge and response fields. + */ +#define MAX_CHALLENGE_LEN 64 +#define MAX_RESPONSE_LEN 64 + +/* + * These limits apply to challenge and response packets we send. + * The +4 is the +1 that we actually need rounded up. + */ +#define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN) +#define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN) + +/* bitmask of supported algorithms */ +#if MSCHAP_SUPPORT +#define MDTYPE_MICROSOFT_V2 0x1 +#define MDTYPE_MICROSOFT 0x2 +#endif /* MSCHAP_SUPPORT */ +#define MDTYPE_MD5 0x4 +#define MDTYPE_NONE 0 + +#if MSCHAP_SUPPORT +/* Return the digest alg. ID for the most preferred digest type. */ +#define CHAP_DIGEST(mdtype) \ + ((mdtype) & MDTYPE_MD5)? CHAP_MD5: \ + ((mdtype) & MDTYPE_MICROSOFT_V2)? CHAP_MICROSOFT_V2: \ + ((mdtype) & MDTYPE_MICROSOFT)? CHAP_MICROSOFT: \ + 0 +#else /* !MSCHAP_SUPPORT */ +#define CHAP_DIGEST(mdtype) \ + ((mdtype) & MDTYPE_MD5)? CHAP_MD5: \ + 0 +#endif /* MSCHAP_SUPPORT */ + +/* Return the bit flag (lsb set) for our most preferred digest type. */ +#define CHAP_MDTYPE(mdtype) ((mdtype) ^ ((mdtype) - 1)) & (mdtype) + +/* Return the bit flag for a given digest algorithm ID. */ +#if MSCHAP_SUPPORT +#define CHAP_MDTYPE_D(digest) \ + ((digest) == CHAP_MICROSOFT_V2)? MDTYPE_MICROSOFT_V2: \ + ((digest) == CHAP_MICROSOFT)? MDTYPE_MICROSOFT: \ + ((digest) == CHAP_MD5)? MDTYPE_MD5: \ + 0 +#else /* !MSCHAP_SUPPORT */ +#define CHAP_MDTYPE_D(digest) \ + ((digest) == CHAP_MD5)? MDTYPE_MD5: \ + 0 +#endif /* MSCHAP_SUPPORT */ + +/* Can we do the requested digest? */ +#if MSCHAP_SUPPORT +#define CHAP_CANDIGEST(mdtype, digest) \ + ((digest) == CHAP_MICROSOFT_V2)? (mdtype) & MDTYPE_MICROSOFT_V2: \ + ((digest) == CHAP_MICROSOFT)? (mdtype) & MDTYPE_MICROSOFT: \ + ((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \ + 0 +#else /* !MSCHAP_SUPPORT */ +#define CHAP_CANDIGEST(mdtype, digest) \ + ((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \ + 0 +#endif /* MSCHAP_SUPPORT */ + +/* + * The code for each digest type has to supply one of these. + */ +struct chap_digest_type { + int code; + +#if PPP_SERVER + /* + * Note: challenge and response arguments below are formatted as + * a length byte followed by the actual challenge/response data. + */ + void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge); + int (*verify_response)(ppp_pcb *pcb, int id, const char *name, + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space); +#endif /* PPP_SERVER */ + void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *priv); + int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); + void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); +}; + +/* + * Each interface is described by chap structure. + */ +#if CHAP_SUPPORT +typedef struct chap_client_state { + u8_t flags; + const char *name; + const struct chap_digest_type *digest; + unsigned char priv[64]; /* private area for digest's use */ +} chap_client_state; + +#if PPP_SERVER +typedef struct chap_server_state { + u8_t flags; + u8_t id; + const char *name; + const struct chap_digest_type *digest; + int challenge_xmits; + int challenge_pktlen; + unsigned char challenge[CHAL_MAX_PKTLEN]; +} chap_server_state; +#endif /* PPP_SERVER */ +#endif /* CHAP_SUPPORT */ + +#if 0 /* UNUSED */ +/* Hook for a plugin to validate CHAP challenge */ +extern int (*chap_verify_hook)(char *name, char *ourname, int id, + const struct chap_digest_type *digest, + unsigned char *challenge, unsigned char *response, + char *message, int message_space); +#endif /* UNUSED */ + +#if PPP_SERVER +/* Called by authentication code to start authenticating the peer. */ +extern void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code); +#endif /* PPP_SERVER */ + +/* Called by auth. code to start authenticating us to the peer. */ +extern void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code); + +/* Represents the CHAP protocol to the main pppd code */ +extern const struct protent chap_protent; + +#endif /* CHAP_H */ +#endif /* PPP_SUPPORT && CHAP_SUPPORT */ diff --git a/sys/include/netif/ppp/chap_ms.h b/sys/include/netif/ppp/chap_ms.h new file mode 100644 index 0000000..0795291 --- /dev/null +++ b/sys/include/netif/ppp/chap_ms.h @@ -0,0 +1,44 @@ +/* + * chap_ms.h - Challenge Handshake Authentication Protocol definitions. + * + * Copyright (c) 1995 Eric Rosenquist. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $ + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && MSCHAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef CHAPMS_INCLUDE +#define CHAPMS_INCLUDE + +extern const struct chap_digest_type chapms_digest; +extern const struct chap_digest_type chapms2_digest; + +#endif /* CHAPMS_INCLUDE */ + +#endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ diff --git a/sys/include/netif/ppp/eap.h b/sys/include/netif/ppp/eap.h new file mode 100644 index 0000000..3ee9aaf --- /dev/null +++ b/sys/include/netif/ppp/eap.h @@ -0,0 +1,169 @@ +/* + * eap.h - Extensible Authentication Protocol for PPP (RFC 2284) + * + * Copyright (c) 2001 by Sun Microsystems, Inc. + * All rights reserved. + * + * Non-exclusive rights to redistribute, modify, translate, and use + * this software in source and binary forms, in whole or in part, is + * hereby granted, provided that the above copyright notice is + * duplicated in any source form, and that neither the name of the + * copyright holder nor the author is used to endorse or promote + * products derived from this software. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Original version by James Carlson + * + * $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $ + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef PPP_EAP_H +#define PPP_EAP_H + +#include "ppp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Packet header = Code, id, length. + */ +#define EAP_HEADERLEN 4 + + +/* EAP message codes. */ +#define EAP_REQUEST 1 +#define EAP_RESPONSE 2 +#define EAP_SUCCESS 3 +#define EAP_FAILURE 4 + +/* EAP types */ +#define EAPT_IDENTITY 1 +#define EAPT_NOTIFICATION 2 +#define EAPT_NAK 3 /* (response only) */ +#define EAPT_MD5CHAP 4 +#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */ +#define EAPT_TOKEN 6 /* Generic Token Card */ +/* 7 and 8 are unassigned. */ +#define EAPT_RSA 9 /* RSA Public Key Authentication */ +#define EAPT_DSS 10 /* DSS Unilateral */ +#define EAPT_KEA 11 /* KEA */ +#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */ +#define EAPT_TLS 13 /* EAP-TLS */ +#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */ +#define EAPT_W2K 15 /* Windows 2000 EAP */ +#define EAPT_ARCOT 16 /* Arcot Systems */ +#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */ +#define EAPT_NOKIACARD 18 /* Nokia IP smart card */ +#define EAPT_SRP 19 /* Secure Remote Password */ +/* 20 is deprecated */ + +/* EAP SRP-SHA1 Subtypes */ +#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */ +#define EAPSRP_CKEY 1 /* Response 1 - Client Key */ +#define EAPSRP_SKEY 2 /* Request 2 - Server Key */ +#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */ +#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */ +#define EAPSRP_ACK 3 /* Response 3 - final ack */ +#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */ + +#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */ + +#define SRP_PSEUDO_ID "pseudo_" +#define SRP_PSEUDO_LEN 7 + +#define MD5_SIGNATURE_SIZE 16 +#define EAP_MIN_CHALLENGE_LENGTH 17 +#define EAP_MAX_CHALLENGE_LENGTH 24 +#define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */ + +#define EAP_STATES \ + "Initial", "Pending", "Closed", "Listen", "Identify", \ + "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth" + +#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen) +#if PPP_SERVER +#define eap_server_active(pcb) \ + ((pcb)->eap.es_server.ea_state >= eapIdentify && \ + (pcb)->eap.es_server.ea_state <= eapMD5Chall) +#endif /* PPP_SERVER */ + +/* + * Complete EAP state for one PPP session. + */ +enum eap_state_code { + eapInitial = 0, /* No EAP authentication yet requested */ + eapPending, /* Waiting for LCP (no timer) */ + eapClosed, /* Authentication not in use */ + eapListen, /* Client ready (and timer running) */ + eapIdentify, /* EAP Identify sent */ + eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */ + eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */ + eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */ + eapMD5Chall, /* Sent MD5-Challenge */ + eapOpen, /* Completed authentication */ + eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */ + eapBadAuth /* Failed authentication */ +}; + +struct eap_auth { + const char *ea_name; /* Our name */ + char ea_peer[MAXNAMELEN +1]; /* Peer's name */ + void *ea_session; /* Authentication library linkage */ + u_char *ea_skey; /* Shared encryption key */ + u_short ea_namelen; /* Length of our name */ + u_short ea_peerlen; /* Length of peer's name */ + enum eap_state_code ea_state; + u_char ea_id; /* Current id */ + u_char ea_requests; /* Number of Requests sent/received */ + u_char ea_responses; /* Number of Responses */ + u_char ea_type; /* One of EAPT_* */ + u32_t ea_keyflags; /* SRP shared key usage flags */ +}; + +#ifndef EAP_MAX_CHALLENGE_LENGTH +#define EAP_MAX_CHALLENGE_LENGTH 24 +#endif +typedef struct eap_state { + struct eap_auth es_client; /* Client (authenticatee) data */ +#if PPP_SERVER + struct eap_auth es_server; /* Server (authenticator) data */ +#endif /* PPP_SERVER */ + int es_savedtime; /* Saved timeout */ + int es_rechallenge; /* EAP rechallenge interval */ + int es_lwrechallenge; /* SRP lightweight rechallenge inter */ + u8_t es_usepseudo; /* Use SRP Pseudonym if offered one */ + int es_usedpseudo; /* Set if we already sent PN */ + int es_challen; /* Length of challenge string */ + u_char es_challenge[EAP_MAX_CHALLENGE_LENGTH]; +} eap_state; + +/* + * Timeouts. + */ +#if 0 /* moved to ppp_opts.h */ +#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */ +#define EAP_DEFTRANSMITS 10 /* max # times to transmit */ +#define EAP_DEFREQTIME 20 /* Time to wait for peer request */ +#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */ +#endif /* moved to ppp_opts.h */ + +void eap_authwithpeer(ppp_pcb *pcb, const char *localname); +void eap_authpeer(ppp_pcb *pcb, const char *localname); + +extern const struct protent eap_protent; + +#ifdef __cplusplus +} +#endif + +#endif /* PPP_EAP_H */ + +#endif /* PPP_SUPPORT && EAP_SUPPORT */ diff --git a/sys/include/netif/ppp/ecp.h b/sys/include/netif/ppp/ecp.h new file mode 100644 index 0000000..5cdce29 --- /dev/null +++ b/sys/include/netif/ppp/ecp.h @@ -0,0 +1,50 @@ +/* + * ecp.h - Definitions for PPP Encryption Control Protocol. + * + * Copyright (c) 2002 Google, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $ + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +typedef struct ecp_options { + bool required; /* Is ECP required? */ + unsigned enctype; /* Encryption type */ +} ecp_options; + +extern fsm ecp_fsm[]; +extern ecp_options ecp_wantoptions[]; +extern ecp_options ecp_gotoptions[]; +extern ecp_options ecp_allowoptions[]; +extern ecp_options ecp_hisoptions[]; + +extern const struct protent ecp_protent; + +#endif /* PPP_SUPPORT && ECP_SUPPORT */ diff --git a/sys/include/netif/ppp/eui64.h b/sys/include/netif/ppp/eui64.h new file mode 100644 index 0000000..20ac22e --- /dev/null +++ b/sys/include/netif/ppp/eui64.h @@ -0,0 +1,94 @@ +/* + * eui64.h - EUI64 routines for IPv6CP. + * + * Copyright (c) 1999 Tommi Komulainen. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Tommi Komulainen + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $ +*/ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef EUI64_H +#define EUI64_H + +/* + * @todo: + * + * Maybe this should be done by processing struct in6_addr directly... + */ +typedef union +{ + u8_t e8[8]; + u16_t e16[4]; + u32_t e32[2]; +} eui64_t; + +#define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) +#define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ + ((e).e32[1] == (o).e32[1])) +#define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0; + +#define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t)) + +#define eui64_magic(e) do { \ + (e).e32[0] = magic(); \ + (e).e32[1] = magic(); \ + (e).e8[0] &= ~2; \ + } while (0) +#define eui64_magic_nz(x) do { \ + eui64_magic(x); \ + } while (eui64_iszero(x)) +#define eui64_magic_ne(x, y) do { \ + eui64_magic(x); \ + } while (eui64_equals(x, y)) + +#define eui64_get(ll, cp) do { \ + eui64_copy((*cp), (ll)); \ + (cp) += sizeof(eui64_t); \ + } while (0) + +#define eui64_put(ll, cp) do { \ + eui64_copy((ll), (*cp)); \ + (cp) += sizeof(eui64_t); \ + } while (0) + +#define eui64_set32(e, l) do { \ + (e).e32[0] = 0; \ + (e).e32[1] = lwip_htonl(l); \ + } while (0) +#define eui64_setlo32(e, l) eui64_set32(e, l) + +char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ + +#endif /* EUI64_H */ +#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ diff --git a/sys/include/netif/ppp/ipv6cp.h b/sys/include/netif/ppp/ipv6cp.h new file mode 100644 index 0000000..07d1ae3 --- /dev/null +++ b/sys/include/netif/ppp/ipv6cp.h @@ -0,0 +1,183 @@ +/* + * ipv6cp.h - PPP IPV6 Control Protocol. + * + * Copyright (c) 1999 Tommi Komulainen. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name(s) of the authors of this software must not be used to + * endorse or promote products derived from this software without + * prior written permission. + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Tommi Komulainen + * ". + * + * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* Original version, based on RFC2023 : + + Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt, + Alain.Durand@imag.fr, IMAG, + Jean-Luc.Richier@imag.fr, IMAG-LSR. + + Copyright (c) 1998, 1999 Francis.Dupont@inria.fr, GIE DYADE, + Alain.Durand@imag.fr, IMAG, + Jean-Luc.Richier@imag.fr, IMAG-LSR. + + Ce travail a été fait au sein du GIE DYADE (Groupement d'Intérêt + Économique ayant pour membres BULL S.A. et l'INRIA). + + Ce logiciel informatique est disponible aux conditions + usuelles dans la recherche, c'est-à-dire qu'il peut + être utilisé, copié, modifié, distribué à l'unique + condition que ce texte soit conservé afin que + l'origine de ce logiciel soit reconnue. + + Le nom de l'Institut National de Recherche en Informatique + et en Automatique (INRIA), de l'IMAG, ou d'une personne morale + ou physique ayant participé à l'élaboration de ce logiciel ne peut + être utilisé sans son accord préalable explicite. + + Ce logiciel est fourni tel quel sans aucune garantie, + support ou responsabilité d'aucune sorte. + Ce logiciel est dérivé de sources d'origine + "University of California at Berkeley" et + "Digital Equipment Corporation" couvertes par des copyrights. + + L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG) + est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National + Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant + sept laboratoires dont le laboratoire Logiciels, Systèmes, Réseaux (LSR). + + This work has been done in the context of GIE DYADE (joint R & D venture + between BULL S.A. and INRIA). + + This software is available with usual "research" terms + with the aim of retain credits of the software. + Permission to use, copy, modify and distribute this software for any + purpose and without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies, + and the name of INRIA, IMAG, or any contributor not be used in advertising + or publicity pertaining to this material without the prior explicit + permission. The software is provided "as is" without any + warranties, support or liabilities of any kind. + This software is derived from source code from + "University of California at Berkeley" and + "Digital Equipment Corporation" protected by copyrights. + + Grenoble's Institute of Computer Science and Applied Mathematics (IMAG) + is a federation of seven research units funded by the CNRS, National + Polytechnic Institute of Grenoble and University Joseph Fourier. + The research unit in Software, Systems, Networks (LSR) is member of IMAG. +*/ + +/* + * Derived from : + * + * + * ipcp.h - IP Control Protocol definitions. + * + * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any legal + * details, please contact + * Office of Technology Transfer + * Carnegie Mellon University + * 5000 Forbes Avenue + * Pittsburgh, PA 15213-3890 + * (412) 268-4387, fax: (412) 268-7395 + * tech-transfer@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: ipv6cp.h,v 1.7 2002/12/04 23:03:32 paulus Exp $ + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef IPV6CP_H +#define IPV6CP_H + +#include "eui64.h" + +/* + * Options. + */ +#define CI_IFACEID 1 /* Interface Identifier */ +#ifdef IPV6CP_COMP +#define CI_COMPRESSTYPE 2 /* Compression Type */ +#endif /* IPV6CP_COMP */ + +/* No compression types yet defined. + *#define IPV6CP_COMP 0x004f + */ +typedef struct ipv6cp_options { + unsigned int neg_ifaceid :1; /* Negotiate interface identifier? */ + unsigned int req_ifaceid :1; /* Ask peer to send interface identifier? */ + unsigned int accept_local :1; /* accept peer's value for iface id? */ + unsigned int opt_local :1; /* ourtoken set by option */ + unsigned int opt_remote :1; /* histoken set by option */ + unsigned int use_ip :1; /* use IP as interface identifier */ +#if 0 + unsigned int use_persistent :1; /* use uniquely persistent value for address */ +#endif +#ifdef IPV6CP_COMP + unsigned int neg_vj :1; /* Van Jacobson Compression? */ +#endif /* IPV6CP_COMP */ + +#ifdef IPV6CP_COMP + u_short vj_protocol; /* protocol value to use in VJ option */ +#endif /* IPV6CP_COMP */ + eui64_t ourid, hisid; /* Interface identifiers */ +} ipv6cp_options; + +extern const struct protent ipv6cp_protent; + +#endif /* IPV6CP_H */ +#endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ diff --git a/sys/include/netif/ppp/magic.h b/sys/include/netif/ppp/magic.h new file mode 100644 index 0000000..a2a9b53 --- /dev/null +++ b/sys/include/netif/ppp/magic.h @@ -0,0 +1,122 @@ +/* + * magic.h - PPP Magic Number definitions. + * + * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any legal + * details, please contact + * Office of Technology Transfer + * Carnegie Mellon University + * 5000 Forbes Avenue + * Pittsburgh, PA 15213-3890 + * (412) 268-4387, fax: (412) 268-7395 + * tech-transfer@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $ + */ +/***************************************************************************** +* randm.h - Random number generator header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* Copyright (c) 1998 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 98-05-29 Guy Lancaster , Global Election Systems Inc. +* Extracted from avos. +*****************************************************************************/ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef MAGIC_H +#define MAGIC_H + +/*********************** +*** PUBLIC FUNCTIONS *** +***********************/ + +/* + * Initialize the random number generator. + */ +void magic_init(void); + +/* + * Randomize our random seed value. To be called for truely random events + * such as user operations and network traffic. + */ +void magic_randomize(void); + +/* + * Return a new random number. + */ +u32_t magic(void); /* Returns the next magic number */ + +/* + * Fill buffer with random bytes + * + * Use the random pool to generate random data. This degrades to pseudo + * random when used faster than randomness is supplied using magic_churnrand(). + * Thus it's important to make sure that the results of this are not + * published directly because one could predict the next result to at + * least some degree. Also, it's important to get a good seed before + * the first use. + */ +void magic_random_bytes(unsigned char *buf, u32_t buf_len); + +/* + * Return a new random number between 0 and (2^pow)-1 included. + */ +u32_t magic_pow(u8_t pow); + +#endif /* MAGIC_H */ + +#endif /* PPP_SUPPORT */ diff --git a/sys/include/netif/ppp/polarssl/arc4.h b/sys/include/netif/ppp/polarssl/arc4.h new file mode 100644 index 0000000..863626d --- /dev/null +++ b/sys/include/netif/ppp/polarssl/arc4.h @@ -0,0 +1,81 @@ +/** + * \file arc4.h + * + * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + * + * Copyright (C) 2009 Paul Bakker + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "netif/ppp/ppp_opts.h" +#if LWIP_INCLUDED_POLARSSL_ARC4 + +#ifndef LWIP_INCLUDED_POLARSSL_ARC4_H +#define LWIP_INCLUDED_POLARSSL_ARC4_H + +/** + * \brief ARC4 context structure + */ +typedef struct +{ + int x; /*!< permutation index */ + int y; /*!< permutation index */ + unsigned char m[256]; /*!< permutation table */ +} +arc4_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief ARC4 key schedule + * + * \param ctx ARC4 context to be initialized + * \param key the secret key + * \param keylen length of the key + */ +void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); + +/** + * \brief ARC4 cipher function + * + * \param ctx ARC4 context + * \param buf buffer to be processed + * \param buflen amount of data in buf + */ +void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_ARC4_H */ + +#endif /* LWIP_INCLUDED_POLARSSL_ARC4 */ diff --git a/sys/include/netif/ppp/polarssl/des.h b/sys/include/netif/ppp/polarssl/des.h new file mode 100644 index 0000000..ad2f0a2 --- /dev/null +++ b/sys/include/netif/ppp/polarssl/des.h @@ -0,0 +1,92 @@ +/** + * \file des.h + * + * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + * + * Copyright (C) 2009 Paul Bakker + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "netif/ppp/ppp_opts.h" +#if LWIP_INCLUDED_POLARSSL_DES + +#ifndef LWIP_INCLUDED_POLARSSL_DES_H +#define LWIP_INCLUDED_POLARSSL_DES_H + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +/** + * \brief DES context structure + */ +typedef struct +{ + int mode; /*!< encrypt/decrypt */ + unsigned long sk[32]; /*!< DES subkeys */ +} +des_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief DES key schedule (56-bit, encryption) + * + * \param ctx DES context to be initialized + * \param key 8-byte secret key + */ +void des_setkey_enc( des_context *ctx, unsigned char key[8] ); + +/** + * \brief DES key schedule (56-bit, decryption) + * + * \param ctx DES context to be initialized + * \param key 8-byte secret key + */ +void des_setkey_dec( des_context *ctx, unsigned char key[8] ); + +/** + * \brief DES-ECB block encryption/decryption + * + * \param ctx DES context + * \param input 64-bit input block + * \param output 64-bit output block + */ +void des_crypt_ecb( des_context *ctx, + const unsigned char input[8], + unsigned char output[8] ); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_DES_H */ + +#endif /* LWIP_INCLUDED_POLARSSL_DES */ diff --git a/sys/include/netif/ppp/polarssl/md4.h b/sys/include/netif/ppp/polarssl/md4.h index 5704456..2262995 100644 --- a/sys/include/netif/ppp/polarssl/md4.h +++ b/sys/include/netif/ppp/polarssl/md4.h @@ -1,97 +1,97 @@ -/** - * \file md4.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_MD4 - -#ifndef LWIP_INCLUDED_POLARSSL_MD4_H -#define LWIP_INCLUDED_POLARSSL_MD4_H - -/** - * \brief MD4 context structure - */ -typedef struct -{ - unsigned long total[2]; /*!< number of bytes processed */ - unsigned long state[4]; /*!< intermediate digest state */ - unsigned char buffer[64]; /*!< data block being processed */ -} -md4_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief MD4 context setup - * - * \param ctx context to be initialized - */ -void md4_starts( md4_context *ctx ); - -/** - * \brief MD4 process buffer - * - * \param ctx MD4 context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); - -/** - * \brief MD4 final digest - * - * \param ctx MD4 context - * \param output MD4 checksum result - */ -void md4_finish( md4_context *ctx, unsigned char output[16] ); - -/** - * \brief Output = MD4( input buffer ) - * - * \param input buffer holding the data - * \param ilen length of the input data - * \param output MD4 checksum result - */ -void md4( unsigned char *input, int ilen, unsigned char output[16] ); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_MD4_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_MD4 */ +/** + * \file md4.h + * + * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + * + * Copyright (C) 2009 Paul Bakker + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "netif/ppp/ppp_opts.h" +#if LWIP_INCLUDED_POLARSSL_MD4 + +#ifndef LWIP_INCLUDED_POLARSSL_MD4_H +#define LWIP_INCLUDED_POLARSSL_MD4_H + +/** + * \brief MD4 context structure + */ +typedef struct +{ + unsigned long total[2]; /*!< number of bytes processed */ + unsigned long state[4]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +md4_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief MD4 context setup + * + * \param ctx context to be initialized + */ +void md4_starts( md4_context *ctx ); + +/** + * \brief MD4 process buffer + * + * \param ctx MD4 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void md4_update( md4_context *ctx, const unsigned char *input, int ilen ); + +/** + * \brief MD4 final digest + * + * \param ctx MD4 context + * \param output MD4 checksum result + */ +void md4_finish( md4_context *ctx, unsigned char output[16] ); + +/** + * \brief Output = MD4( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output MD4 checksum result + */ +void md4( unsigned char *input, int ilen, unsigned char output[16] ); + + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_MD4_H */ + +#endif /* LWIP_INCLUDED_POLARSSL_MD4 */ diff --git a/sys/include/netif/ppp/polarssl/md5.h b/sys/include/netif/ppp/polarssl/md5.h index 1244011..3059e1d 100644 --- a/sys/include/netif/ppp/polarssl/md5.h +++ b/sys/include/netif/ppp/polarssl/md5.h @@ -1,96 +1,96 @@ -/** - * \file md5.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_MD5 - -#ifndef LWIP_INCLUDED_POLARSSL_MD5_H -#define LWIP_INCLUDED_POLARSSL_MD5_H - -/** - * \brief MD5 context structure - */ -typedef struct -{ - unsigned long total[2]; /*!< number of bytes processed */ - unsigned long state[4]; /*!< intermediate digest state */ - unsigned char buffer[64]; /*!< data block being processed */ -} -md5_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief MD5 context setup - * - * \param ctx context to be initialized - */ -void md5_starts( md5_context *ctx ); - -/** - * \brief MD5 process buffer - * - * \param ctx MD5 context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); - -/** - * \brief MD5 final digest - * - * \param ctx MD5 context - * \param output MD5 checksum result - */ -void md5_finish( md5_context *ctx, unsigned char output[16] ); - -/** - * \brief Output = MD5( input buffer ) - * - * \param input buffer holding the data - * \param ilen length of the input data - * \param output MD5 checksum result - */ -void md5( unsigned char *input, int ilen, unsigned char output[16] ); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_MD5 */ +/** + * \file md5.h + * + * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + * + * Copyright (C) 2009 Paul Bakker + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "netif/ppp/ppp_opts.h" +#if LWIP_INCLUDED_POLARSSL_MD5 + +#ifndef LWIP_INCLUDED_POLARSSL_MD5_H +#define LWIP_INCLUDED_POLARSSL_MD5_H + +/** + * \brief MD5 context structure + */ +typedef struct +{ + unsigned long total[2]; /*!< number of bytes processed */ + unsigned long state[4]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +md5_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief MD5 context setup + * + * \param ctx context to be initialized + */ +void md5_starts( md5_context *ctx ); + +/** + * \brief MD5 process buffer + * + * \param ctx MD5 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void md5_update( md5_context *ctx, const unsigned char *input, int ilen ); + +/** + * \brief MD5 final digest + * + * \param ctx MD5 context + * \param output MD5 checksum result + */ +void md5_finish( md5_context *ctx, unsigned char output[16] ); + +/** + * \brief Output = MD5( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output MD5 checksum result + */ +void md5( unsigned char *input, int ilen, unsigned char output[16] ); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_MD5_H */ + +#endif /* LWIP_INCLUDED_POLARSSL_MD5 */ diff --git a/sys/include/netif/ppp/polarssl/sha1.h b/sys/include/netif/ppp/polarssl/sha1.h index a4c53e0..6d2a76e 100644 --- a/sys/include/netif/ppp/polarssl/sha1.h +++ b/sys/include/netif/ppp/polarssl/sha1.h @@ -1,96 +1,96 @@ -/** - * \file sha1.h - * - * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine - * - * Copyright (C) 2009 Paul Bakker - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the names of PolarSSL or XySSL nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "netif/ppp/ppp_opts.h" -#if LWIP_INCLUDED_POLARSSL_SHA1 - -#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H -#define LWIP_INCLUDED_POLARSSL_SHA1_H - -/** - * \brief SHA-1 context structure - */ -typedef struct -{ - unsigned long total[2]; /*!< number of bytes processed */ - unsigned long state[5]; /*!< intermediate digest state */ - unsigned char buffer[64]; /*!< data block being processed */ -} -sha1_context; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief SHA-1 context setup - * - * \param ctx context to be initialized - */ -void sha1_starts( sha1_context *ctx ); - -/** - * \brief SHA-1 process buffer - * - * \param ctx SHA-1 context - * \param input buffer holding the data - * \param ilen length of the input data - */ -void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); - -/** - * \brief SHA-1 final digest - * - * \param ctx SHA-1 context - * \param output SHA-1 checksum result - */ -void sha1_finish( sha1_context *ctx, unsigned char output[20] ); - -/** - * \brief Output = SHA-1( input buffer ) - * - * \param input buffer holding the data - * \param ilen length of the input data - * \param output SHA-1 checksum result - */ -void sha1( unsigned char *input, int ilen, unsigned char output[20] ); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ - -#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ +/** + * \file sha1.h + * + * Based on XySSL: Copyright (C) 2006-2008 Christophe Devine + * + * Copyright (C) 2009 Paul Bakker + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the names of PolarSSL or XySSL nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "netif/ppp/ppp_opts.h" +#if LWIP_INCLUDED_POLARSSL_SHA1 + +#ifndef LWIP_INCLUDED_POLARSSL_SHA1_H +#define LWIP_INCLUDED_POLARSSL_SHA1_H + +/** + * \brief SHA-1 context structure + */ +typedef struct +{ + unsigned long total[2]; /*!< number of bytes processed */ + unsigned long state[5]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} +sha1_context; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SHA-1 context setup + * + * \param ctx context to be initialized + */ +void sha1_starts( sha1_context *ctx ); + +/** + * \brief SHA-1 process buffer + * + * \param ctx SHA-1 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen ); + +/** + * \brief SHA-1 final digest + * + * \param ctx SHA-1 context + * \param output SHA-1 checksum result + */ +void sha1_finish( sha1_context *ctx, unsigned char output[20] ); + +/** + * \brief Output = SHA-1( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output SHA-1 checksum result + */ +void sha1( unsigned char *input, int ilen, unsigned char output[20] ); + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_INCLUDED_POLARSSL_SHA1_H */ + +#endif /* LWIP_INCLUDED_POLARSSL_SHA1 */ diff --git a/sys/include/netif/ppp/ppp.h b/sys/include/netif/ppp/ppp.h new file mode 100644 index 0000000..d966a96 --- /dev/null +++ b/sys/include/netif/ppp/ppp.h @@ -0,0 +1,690 @@ +/***************************************************************************** +* ppp.h - Network Point to Point Protocol header file. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1997 Global Election Systems Inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 97-11-05 Guy Lancaster , Global Election Systems Inc. +* Original derived from BSD codes. +*****************************************************************************/ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef PPP_H +#define PPP_H + +#include "net/def.h" +#include "net/stats.h" +#include "net/mem.h" +#include "net/netif.h" +#include "net/sys.h" +#include "net/timeouts.h" +#if PPP_IPV6_SUPPORT +#include "net/ip6_addr.h" +#endif /* PPP_IPV6_SUPPORT */ + +/* Disable non-working or rarely used PPP feature, so rarely that we don't want to bloat ppp_opts.h with them */ +#ifndef PPP_OPTIONS +#define PPP_OPTIONS 0 +#endif + +#ifndef PPP_NOTIFY +#define PPP_NOTIFY 0 +#endif + +#ifndef PPP_REMOTENAME +#define PPP_REMOTENAME 0 +#endif + +#ifndef PPP_IDLETIMELIMIT +#define PPP_IDLETIMELIMIT 0 +#endif + +#ifndef PPP_LCP_ADAPTIVE +#define PPP_LCP_ADAPTIVE 0 +#endif + +#ifndef PPP_MAXCONNECT +#define PPP_MAXCONNECT 0 +#endif + +#ifndef PPP_ALLOWED_ADDRS +#define PPP_ALLOWED_ADDRS 0 +#endif + +#ifndef PPP_PROTOCOLNAME +#define PPP_PROTOCOLNAME 0 +#endif + +#ifndef PPP_STATS_SUPPORT +#define PPP_STATS_SUPPORT 0 +#endif + +#ifndef DEFLATE_SUPPORT +#define DEFLATE_SUPPORT 0 +#endif + +#ifndef BSDCOMPRESS_SUPPORT +#define BSDCOMPRESS_SUPPORT 0 +#endif + +#ifndef PREDICTOR_SUPPORT +#define PREDICTOR_SUPPORT 0 +#endif + +/************************* +*** PUBLIC DEFINITIONS *** +*************************/ + +/* + * The basic PPP frame. + */ +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ + +/* + * Values for phase. + */ +#define PPP_PHASE_DEAD 0 +#define PPP_PHASE_MASTER 1 +#define PPP_PHASE_HOLDOFF 2 +#define PPP_PHASE_INITIALIZE 3 +#define PPP_PHASE_SERIALCONN 4 +#define PPP_PHASE_DORMANT 5 +#define PPP_PHASE_ESTABLISH 6 +#define PPP_PHASE_AUTHENTICATE 7 +#define PPP_PHASE_CALLBACK 8 +#define PPP_PHASE_NETWORK 9 +#define PPP_PHASE_RUNNING 10 +#define PPP_PHASE_TERMINATE 11 +#define PPP_PHASE_DISCONNECT 12 + +/* Error codes. */ +#define PPPERR_NONE 0 /* No error. */ +#define PPPERR_PARAM 1 /* Invalid parameter. */ +#define PPPERR_OPEN 2 /* Unable to open PPP session. */ +#define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */ +#define PPPERR_ALLOC 4 /* Unable to allocate resources. */ +#define PPPERR_USER 5 /* User interrupt. */ +#define PPPERR_CONNECT 6 /* Connection lost. */ +#define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */ +#define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */ +#define PPPERR_PEERDEAD 9 /* Connection timeout */ +#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */ +#define PPPERR_CONNECTTIME 11 /* Max connect time reached */ +#define PPPERR_LOOPBACK 12 /* Loopback detected */ + +/* Whether auth support is enabled at all */ +#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT) + +/************************ +*** PUBLIC DATA TYPES *** +************************/ + +/* + * Other headers require ppp_pcb definition for prototypes, but ppp_pcb + * require some structure definition from other headers as well, we are + * fixing the dependency loop here by declaring the ppp_pcb type then + * by including headers containing necessary struct definition for ppp_pcb + */ +typedef struct ppp_pcb_s ppp_pcb; + +/* Type definitions for BSD code. */ +#ifndef __u_char_defined +typedef unsigned long u_long; +typedef unsigned int u_int; +typedef unsigned short u_short; +typedef unsigned char u_char; +#endif + +#include "fsm.h" +#include "lcp.h" +#if CCP_SUPPORT +#include "ccp.h" +#endif /* CCP_SUPPORT */ +#if MPPE_SUPPORT +#include "mppe.h" +#endif /* MPPE_SUPPORT */ +#if PPP_IPV4_SUPPORT +#include "ipcp.h" +#endif /* PPP_IPV4_SUPPORT */ +#if PPP_IPV6_SUPPORT +#include "ipv6cp.h" +#endif /* PPP_IPV6_SUPPORT */ +#if PAP_SUPPORT +#include "upap.h" +#endif /* PAP_SUPPORT */ +#if CHAP_SUPPORT +#include "chap-new.h" +#endif /* CHAP_SUPPORT */ +#if EAP_SUPPORT +#include "eap.h" +#endif /* EAP_SUPPORT */ +#if VJ_SUPPORT +#include "vj.h" +#endif /* VJ_SUPPORT */ + +/* Link status callback function prototype */ +typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx); + +/* + * PPP configuration. + */ +typedef struct ppp_settings_s { + +#if PPP_SERVER && PPP_AUTH_SUPPORT + unsigned int auth_required :1; /* Peer is required to authenticate */ + unsigned int null_login :1; /* Username of "" and a password of "" are acceptable */ +#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */ +#if PPP_REMOTENAME + unsigned int explicit_remote :1; /* remote_name specified with remotename opt */ +#endif /* PPP_REMOTENAME */ +#if PAP_SUPPORT + unsigned int refuse_pap :1; /* Don't proceed auth. with PAP */ +#endif /* PAP_SUPPORT */ +#if CHAP_SUPPORT + unsigned int refuse_chap :1; /* Don't proceed auth. with CHAP */ +#endif /* CHAP_SUPPORT */ +#if MSCHAP_SUPPORT + unsigned int refuse_mschap :1; /* Don't proceed auth. with MS-CHAP */ + unsigned int refuse_mschap_v2 :1; /* Don't proceed auth. with MS-CHAPv2 */ +#endif /* MSCHAP_SUPPORT */ +#if EAP_SUPPORT + unsigned int refuse_eap :1; /* Don't proceed auth. with EAP */ +#endif /* EAP_SUPPORT */ +#if LWIP_DNS + unsigned int usepeerdns :1; /* Ask peer for DNS adds */ +#endif /* LWIP_DNS */ + unsigned int persist :1; /* Persist mode, always try to open the connection */ +#if PRINTPKT_SUPPORT + unsigned int hide_password :1; /* Hide password in dumped packets */ +#endif /* PRINTPKT_SUPPORT */ + unsigned int noremoteip :1; /* Let him have no IP address */ + unsigned int lax_recv :1; /* accept control chars in asyncmap */ + unsigned int noendpoint :1; /* don't send/accept endpoint discriminator */ +#if PPP_LCP_ADAPTIVE + unsigned int lcp_echo_adaptive :1; /* request echo only if the link was idle */ +#endif /* PPP_LCP_ADAPTIVE */ +#if MPPE_SUPPORT + unsigned int require_mppe :1; /* Require MPPE (Microsoft Point to Point Encryption) */ + unsigned int refuse_mppe_40 :1; /* Allow MPPE 40-bit mode? */ + unsigned int refuse_mppe_128 :1; /* Allow MPPE 128-bit mode? */ + unsigned int refuse_mppe_stateful :1; /* Allow MPPE stateful mode? */ +#endif /* MPPE_SUPPORT */ + + u16_t listen_time; /* time to listen first (ms), waiting for peer to send LCP packet */ + +#if PPP_IDLETIMELIMIT + u16_t idle_time_limit; /* Disconnect if idle for this many seconds */ +#endif /* PPP_IDLETIMELIMIT */ +#if PPP_MAXCONNECT + u32_t maxconnect; /* Maximum connect time (seconds) */ +#endif /* PPP_MAXCONNECT */ + +#if PPP_AUTH_SUPPORT + /* auth data */ + const char *user; /* Username for PAP */ + const char *passwd; /* Password for PAP, secret for CHAP */ +#if PPP_REMOTENAME + char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ +#endif /* PPP_REMOTENAME */ + +#if PAP_SUPPORT + u8_t pap_timeout_time; /* Timeout (seconds) for auth-req retrans. */ + u8_t pap_max_transmits; /* Number of auth-reqs sent */ +#if PPP_SERVER + u8_t pap_req_timeout; /* Time to wait for auth-req from peer */ +#endif /* PPP_SERVER */ +#endif /* PAP_SUPPPORT */ + +#if CHAP_SUPPORT + u8_t chap_timeout_time; /* Timeout (seconds) for retransmitting req */ + u8_t chap_max_transmits; /* max # times to send challenge */ +#if PPP_SERVER + u8_t chap_rechallenge_time; /* Time to wait for auth-req from peer */ +#endif /* PPP_SERVER */ +#endif /* CHAP_SUPPPORT */ + +#if EAP_SUPPORT + u8_t eap_req_time; /* Time to wait (for retransmit/fail) */ + u8_t eap_allow_req; /* Max Requests allowed */ +#if PPP_SERVER + u8_t eap_timeout_time; /* Time to wait (for retransmit/fail) */ + u8_t eap_max_transmits; /* Max Requests allowed */ +#endif /* PPP_SERVER */ +#endif /* EAP_SUPPORT */ + +#endif /* PPP_AUTH_SUPPORT */ + + u8_t fsm_timeout_time; /* Timeout time in seconds */ + u8_t fsm_max_conf_req_transmits; /* Maximum Configure-Request transmissions */ + u8_t fsm_max_term_transmits; /* Maximum Terminate-Request transmissions */ + u8_t fsm_max_nak_loops; /* Maximum number of nak loops tolerated */ + + u8_t lcp_loopbackfail; /* Number of times we receive our magic number from the peer + before deciding the link is looped-back. */ + u8_t lcp_echo_interval; /* Interval between LCP echo-requests */ + u8_t lcp_echo_fails; /* Tolerance to unanswered echo-requests */ + +} ppp_settings; + +#if PPP_SERVER +struct ppp_addrs { +#if PPP_IPV4_SUPPORT + ip4_addr_t our_ipaddr, his_ipaddr, netmask; +#if LWIP_DNS + ip4_addr_t dns1, dns2; +#endif /* LWIP_DNS */ +#endif /* PPP_IPV4_SUPPORT */ +#if PPP_IPV6_SUPPORT + ip6_addr_t our6_ipaddr, his6_ipaddr; +#endif /* PPP_IPV6_SUPPORT */ +}; +#endif /* PPP_SERVER */ + +/* + * PPP interface control block. + */ +struct ppp_pcb_s { + ppp_settings settings; + const struct link_callbacks *link_cb; + void *link_ctx_cb; + void (*link_status_cb)(ppp_pcb *pcb, int err_code, void *ctx); /* Status change callback */ +#if PPP_NOTIFY_PHASE + void (*notify_phase_cb)(ppp_pcb *pcb, u8_t phase, void *ctx); /* Notify phase callback */ +#endif /* PPP_NOTIFY_PHASE */ + void *ctx_cb; /* Callbacks optional pointer */ + struct netif *netif; /* PPP interface */ + u8_t phase; /* where the link is at */ + u8_t err_code; /* Code indicating why interface is down. */ + + /* flags */ +#if PPP_IPV4_SUPPORT + unsigned int ask_for_local :1; /* request our address from peer */ + unsigned int ipcp_is_open :1; /* haven't called np_finished() */ + unsigned int ipcp_is_up :1; /* have called ipcp_up() */ + unsigned int if4_up :1; /* True when the IPv4 interface is up. */ +#if 0 /* UNUSED - PROXY ARP */ + unsigned int proxy_arp_set :1; /* Have created proxy arp entry */ +#endif /* UNUSED - PROXY ARP */ +#endif /* PPP_IPV4_SUPPORT */ +#if PPP_IPV6_SUPPORT + unsigned int ipv6cp_is_up :1; /* have called ip6cp_up() */ + unsigned int if6_up :1; /* True when the IPv6 interface is up. */ +#endif /* PPP_IPV6_SUPPORT */ + unsigned int lcp_echo_timer_running :1; /* set if a timer is running */ +#if VJ_SUPPORT + unsigned int vj_enabled :1; /* Flag indicating VJ compression enabled. */ +#endif /* VJ_SUPPORT */ +#if CCP_SUPPORT + unsigned int ccp_all_rejected :1; /* we rejected all peer's options */ +#endif /* CCP_SUPPORT */ +#if MPPE_SUPPORT + unsigned int mppe_keys_set :1; /* Have the MPPE keys been set? */ +#endif /* MPPE_SUPPORT */ + +#if PPP_AUTH_SUPPORT + /* auth data */ +#if PPP_SERVER && defined(HAVE_MULTILINK) + char peer_authname[MAXNAMELEN + 1]; /* The name by which the peer authenticated itself to us. */ +#endif /* PPP_SERVER && defined(HAVE_MULTILINK) */ + u16_t auth_pending; /* Records which authentication operations haven't completed yet. */ + u16_t auth_done; /* Records which authentication operations have been completed. */ + +#if PAP_SUPPORT + upap_state upap; /* PAP data */ +#endif /* PAP_SUPPORT */ + +#if CHAP_SUPPORT + chap_client_state chap_client; /* CHAP client data */ +#if PPP_SERVER + chap_server_state chap_server; /* CHAP server data */ +#endif /* PPP_SERVER */ +#endif /* CHAP_SUPPORT */ + +#if EAP_SUPPORT + eap_state eap; /* EAP data */ +#endif /* EAP_SUPPORT */ +#endif /* PPP_AUTH_SUPPORT */ + + fsm lcp_fsm; /* LCP fsm structure */ + lcp_options lcp_wantoptions; /* Options that we want to request */ + lcp_options lcp_gotoptions; /* Options that peer ack'd */ + lcp_options lcp_allowoptions; /* Options we allow peer to request */ + lcp_options lcp_hisoptions; /* Options that we ack'd */ + u16_t peer_mru; /* currently negotiated peer MRU */ + u8_t lcp_echos_pending; /* Number of outstanding echo msgs */ + u8_t lcp_echo_number; /* ID number of next echo frame */ + + u8_t num_np_open; /* Number of network protocols which we have opened. */ + u8_t num_np_up; /* Number of network protocols which have come up. */ + +#if VJ_SUPPORT + struct vjcompress vj_comp; /* Van Jacobson compression header. */ +#endif /* VJ_SUPPORT */ + +#if CCP_SUPPORT + fsm ccp_fsm; /* CCP fsm structure */ + ccp_options ccp_wantoptions; /* what to request the peer to use */ + ccp_options ccp_gotoptions; /* what the peer agreed to do */ + ccp_options ccp_allowoptions; /* what we'll agree to do */ + ccp_options ccp_hisoptions; /* what we agreed to do */ + u8_t ccp_localstate; /* Local state (mainly for handling reset-reqs and reset-acks). */ + u8_t ccp_receive_method; /* Method chosen on receive path */ + u8_t ccp_transmit_method; /* Method chosen on transmit path */ +#if MPPE_SUPPORT + ppp_mppe_state mppe_comp; /* MPPE "compressor" structure */ + ppp_mppe_state mppe_decomp; /* MPPE "decompressor" structure */ +#endif /* MPPE_SUPPORT */ +#endif /* CCP_SUPPORT */ + +#if PPP_IPV4_SUPPORT + fsm ipcp_fsm; /* IPCP fsm structure */ + ipcp_options ipcp_wantoptions; /* Options that we want to request */ + ipcp_options ipcp_gotoptions; /* Options that peer ack'd */ + ipcp_options ipcp_allowoptions; /* Options we allow peer to request */ + ipcp_options ipcp_hisoptions; /* Options that we ack'd */ +#endif /* PPP_IPV4_SUPPORT */ + +#if PPP_IPV6_SUPPORT + fsm ipv6cp_fsm; /* IPV6CP fsm structure */ + ipv6cp_options ipv6cp_wantoptions; /* Options that we want to request */ + ipv6cp_options ipv6cp_gotoptions; /* Options that peer ack'd */ + ipv6cp_options ipv6cp_allowoptions; /* Options we allow peer to request */ + ipv6cp_options ipv6cp_hisoptions; /* Options that we ack'd */ +#endif /* PPP_IPV6_SUPPORT */ +}; + +/************************ + *** PUBLIC FUNCTIONS *** + ************************/ + +/* + * WARNING: For multi-threads environment, all ppp_set_* functions most + * only be called while the PPP is in the dead phase (i.e. disconnected). + */ + +#if PPP_AUTH_SUPPORT +/* + * Set PPP authentication. + * + * Warning: Using PPPAUTHTYPE_ANY might have security consequences. + * RFC 1994 says: + * + * In practice, within or associated with each PPP server, there is a + * database which associates "user" names with authentication + * information ("secrets"). It is not anticipated that a particular + * named user would be authenticated by multiple methods. This would + * make the user vulnerable to attacks which negotiate the least secure + * method from among a set (such as PAP rather than CHAP). If the same + * secret was used, PAP would reveal the secret to be used later with + * CHAP. + * + * Instead, for each user name there should be an indication of exactly + * one method used to authenticate that user name. If a user needs to + * make use of different authentication methods under different + * circumstances, then distinct user names SHOULD be employed, each of + * which identifies exactly one authentication method. + * + * Default is none auth type, unset (NULL) user and passwd. + */ +#define PPPAUTHTYPE_NONE 0x00 +#define PPPAUTHTYPE_PAP 0x01 +#define PPPAUTHTYPE_CHAP 0x02 +#define PPPAUTHTYPE_MSCHAP 0x04 +#define PPPAUTHTYPE_MSCHAP_V2 0x08 +#define PPPAUTHTYPE_EAP 0x10 +#define PPPAUTHTYPE_ANY 0xff +void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd); + +/* + * If set, peer is required to authenticate. This is mostly necessary for PPP server support. + * + * Default is false. + */ +#define ppp_set_auth_required(ppp, boolval) (ppp->settings.auth_required = boolval) +#endif /* PPP_AUTH_SUPPORT */ + +#if PPP_IPV4_SUPPORT +/* + * Set PPP interface "our" and "his" IPv4 addresses. This is mostly necessary for PPP server + * support but it can also be used on a PPP link where each side choose its own IP address. + * + * Default is unset (0.0.0.0). + */ +#define ppp_set_ipcp_ouraddr(ppp, addr) do { ppp->ipcp_wantoptions.ouraddr = ip4_addr_get_u32(addr); \ + ppp->ask_for_local = ppp->ipcp_wantoptions.ouraddr != 0; } while(0) +#define ppp_set_ipcp_hisaddr(ppp, addr) (ppp->ipcp_wantoptions.hisaddr = ip4_addr_get_u32(addr)) +#if LWIP_DNS +/* + * Set DNS server addresses that are sent if the peer asks for them. This is mostly necessary + * for PPP server support. + * + * Default is unset (0.0.0.0). + */ +#define ppp_set_ipcp_dnsaddr(ppp, index, addr) (ppp->ipcp_allowoptions.dnsaddr[index] = ip4_addr_get_u32(addr)) + +/* + * If set, we ask the peer for up to 2 DNS server addresses. Received DNS server addresses are + * registered using the dns_setserver() function. + * + * Default is false. + */ +#define ppp_set_usepeerdns(ppp, boolval) (ppp->settings.usepeerdns = boolval) +#endif /* LWIP_DNS */ +#endif /* PPP_IPV4_SUPPORT */ + +#if MPPE_SUPPORT +/* Disable MPPE (Microsoft Point to Point Encryption). This parameter is exclusive. */ +#define PPP_MPPE_DISABLE 0x00 +/* Require the use of MPPE (Microsoft Point to Point Encryption). */ +#define PPP_MPPE_ENABLE 0x01 +/* Allow MPPE to use stateful mode. Stateless mode is still attempted first. */ +#define PPP_MPPE_ALLOW_STATEFUL 0x02 +/* Refuse the use of MPPE with 40-bit encryption. Conflict with PPP_MPPE_REFUSE_128. */ +#define PPP_MPPE_REFUSE_40 0x04 +/* Refuse the use of MPPE with 128-bit encryption. Conflict with PPP_MPPE_REFUSE_40. */ +#define PPP_MPPE_REFUSE_128 0x08 +/* + * Set MPPE configuration + * + * Default is disabled. + */ +void ppp_set_mppe(ppp_pcb *pcb, u8_t flags); +#endif /* MPPE_SUPPORT */ + +/* + * Wait for up to intval milliseconds for a valid PPP packet from the peer. + * At the end of this time, or when a valid PPP packet is received from the + * peer, we commence negotiation by sending our first LCP packet. + * + * Default is 0. + */ +#define ppp_set_listen_time(ppp, intval) (ppp->settings.listen_time = intval) + +/* + * If set, we will attempt to initiate a connection but if no reply is received from + * the peer, we will then just wait passively for a valid LCP packet from the peer. + * + * Default is false. + */ +#define ppp_set_passive(ppp, boolval) (ppp->lcp_wantoptions.passive = boolval) + +/* + * If set, we will not transmit LCP packets to initiate a connection until a valid + * LCP packet is received from the peer. This is what we usually call the server mode. + * + * Default is false. + */ +#define ppp_set_silent(ppp, boolval) (ppp->lcp_wantoptions.silent = boolval) + +/* + * If set, enable protocol field compression negotiation in both the receive and + * the transmit direction. + * + * Default is true. + */ +#define ppp_set_neg_pcomp(ppp, boolval) (ppp->lcp_wantoptions.neg_pcompression = \ + ppp->lcp_allowoptions.neg_pcompression = boolval) + +/* + * If set, enable Address/Control compression in both the receive and the transmit + * direction. + * + * Default is true. + */ +#define ppp_set_neg_accomp(ppp, boolval) (ppp->lcp_wantoptions.neg_accompression = \ + ppp->lcp_allowoptions.neg_accompression = boolval) + +/* + * If set, enable asyncmap negotiation. Otherwise forcing all control characters to + * be escaped for both the transmit and the receive direction. + * + * Default is true. + */ +#define ppp_set_neg_asyncmap(ppp, boolval) (ppp->lcp_wantoptions.neg_asyncmap = \ + ppp->lcp_allowoptions.neg_asyncmap = boolval) + +/* + * This option sets the Async-Control-Character-Map (ACCM) for this end of the link. + * The ACCM is a set of 32 bits, one for each of the ASCII control characters with + * values from 0 to 31, where a 1 bit indicates that the corresponding control + * character should not be used in PPP packets sent to this system. The map is + * an unsigned 32 bits integer where the least significant bit (00000001) represents + * character 0 and the most significant bit (80000000) represents character 31. + * We will then ask the peer to send these characters as a 2-byte escape sequence. + * + * Default is 0. + */ +#define ppp_set_asyncmap(ppp, intval) (ppp->lcp_wantoptions.asyncmap = intval) + +/* + * Set a PPP interface as the default network interface + * (used to output all packets for which no specific route is found). + */ +#define ppp_set_default(ppp) netif_set_default(ppp->netif) + +#if PPP_NOTIFY_PHASE +/* + * Set a PPP notify phase callback. + * + * This can be used for example to set a LED pattern depending on the + * current phase of the PPP session. + */ +typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx); +void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb); +#endif /* PPP_NOTIFY_PHASE */ + +/* + * Initiate a PPP connection. + * + * This can only be called if PPP is in the dead phase. + * + * Holdoff is the time to wait (in seconds) before initiating + * the connection. + * + * If this port connects to a modem, the modem connection must be + * established before calling this. + */ +err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff); + +#if PPP_SERVER +/* + * Listen for an incoming PPP connection. + * + * This can only be called if PPP is in the dead phase. + * + * If this port connects to a modem, the modem connection must be + * established before calling this. + */ +err_t ppp_listen(ppp_pcb *pcb); +#endif /* PPP_SERVER */ + +/* + * Initiate the end of a PPP connection. + * Any outstanding packets in the queues are dropped. + * + * Setting nocarrier to 1 close the PPP connection without initiating the + * shutdown procedure. Always using nocarrier = 0 is still recommended, + * this is going to take a little longer time if your link is down, but + * is a safer choice for the PPP state machine. + * + * Return 0 on success, an error code on failure. + */ +err_t ppp_close(ppp_pcb *pcb, u8_t nocarrier); + +/* + * Release the control block. + * + * This can only be called if PPP is in the dead phase. + * + * You must use ppp_close() before if you wish to terminate + * an established PPP session. + * + * Return 0 on success, an error code on failure. + */ +err_t ppp_free(ppp_pcb *pcb); + +/* + * PPP IOCTL commands. + * + * Get the up status - 0 for down, non-zero for up. The argument must + * point to an int. + */ +#define PPPCTLG_UPSTATUS 0 + +/* + * Get the PPP error code. The argument must point to an int. + * Returns a PPPERR_* value. + */ +#define PPPCTLG_ERRCODE 1 + +/* + * Get the fd associated with a PPP over serial + */ +#define PPPCTLG_FD 2 + +/* + * Get and set parameters for the given connection. + * Return 0 on success, an error code on failure. + */ +err_t ppp_ioctl(ppp_pcb *pcb, u8_t cmd, void *arg); + +/* Get the PPP netif interface */ +#define ppp_netif(ppp) (ppp->netif) + +/* Set an lwIP-style status-callback for the selected PPP device */ +#define ppp_set_netif_statuscallback(ppp, status_cb) \ + netif_set_status_callback(ppp->netif, status_cb); + +/* Set an lwIP-style link-callback for the selected PPP device */ +#define ppp_set_netif_linkcallback(ppp, link_cb) \ + netif_set_link_callback(ppp->netif, link_cb); + +#endif /* PPP_H */ + +#endif /* PPP_SUPPORT */ diff --git a/sys/include/netif/ppp/pppdebug.h b/sys/include/netif/ppp/pppdebug.h new file mode 100644 index 0000000..7ead045 --- /dev/null +++ b/sys/include/netif/ppp/pppdebug.h @@ -0,0 +1,80 @@ +/***************************************************************************** +* pppdebug.h - System debugging utilities. +* +* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. +* portions Copyright (c) 1998 Global Election Systems Inc. +* portions Copyright (c) 2001 by Cognizant Pty Ltd. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY (please don't use tabs!) +* +* 03-01-01 Marc Boucher +* Ported to lwIP. +* 98-07-29 Guy Lancaster , Global Election Systems Inc. +* Original. +* +***************************************************************************** +*/ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef PPPDEBUG_H +#define PPPDEBUG_H + +/* Trace levels. */ +#define LOG_CRITICAL (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) +#define LOG_ERR (PPP_DEBUG | LWIP_DBG_LEVEL_SEVERE) +#define LOG_NOTICE (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) +#define LOG_WARNING (PPP_DEBUG | LWIP_DBG_LEVEL_WARNING) +#define LOG_INFO (PPP_DEBUG) +#define LOG_DETAIL (PPP_DEBUG) +#define LOG_DEBUG (PPP_DEBUG) + +#if PPP_DEBUG + +#define MAINDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define SYSDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define FSMDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define LCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define IPCPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define IPV6CPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define UPAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define CHAPDEBUG(a) LWIP_DEBUGF(LWIP_DBG_LEVEL_WARNING, a) +#define PPPDEBUG(a, b) LWIP_DEBUGF(a, b) + +#else /* PPP_DEBUG */ + +#define MAINDEBUG(a) +#define SYSDEBUG(a) +#define FSMDEBUG(a) +#define LCPDEBUG(a) +#define IPCPDEBUG(a) +#define IPV6CPDEBUG(a) +#define UPAPDEBUG(a) +#define CHAPDEBUG(a) +#define PPPDEBUG(a, b) + +#endif /* PPP_DEBUG */ + +#endif /* PPPDEBUG_H */ + +#endif /* PPP_SUPPORT */ diff --git a/sys/include/netif/ppp/pppoe.h b/sys/include/netif/ppp/pppoe.h new file mode 100644 index 0000000..9f8f289 --- /dev/null +++ b/sys/include/netif/ppp/pppoe.h @@ -0,0 +1,179 @@ +/***************************************************************************** +* pppoe.h - PPP Over Ethernet implementation for lwIP. +* +* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. +* +* The authors hereby grant permission to use, copy, modify, distribute, +* and license this software and its documentation for any purpose, provided +* that existing copyright notices are retained in all copies and that this +* notice and the following disclaimer are included verbatim in any +* distributions. No written agreement, license, or royalty fee is required +* for any of the authorized uses. +* +* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +****************************************************************************** +* REVISION HISTORY +* +* 06-01-01 Marc Boucher +* Ported to lwIP. +*****************************************************************************/ + + + +/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ + +/*- + * Copyright (c) 2002 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Martin Husemann . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && PPPOE_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef PPP_OE_H +#define PPP_OE_H + +#include "ppp.h" +#include "lwip/etharp.h" + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct pppoehdr { + PACK_STRUCT_FLD_8(u8_t vertype); + PACK_STRUCT_FLD_8(u8_t code); + PACK_STRUCT_FIELD(u16_t session); + PACK_STRUCT_FIELD(u16_t plen); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/bpstruct.h" +#endif +PACK_STRUCT_BEGIN +struct pppoetag { + PACK_STRUCT_FIELD(u16_t tag); + PACK_STRUCT_FIELD(u16_t len); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END +#ifdef PACK_STRUCT_USE_INCLUDES +# include "arch/epstruct.h" +#endif + + +#define PPPOE_STATE_INITIAL 0 +#define PPPOE_STATE_PADI_SENT 1 +#define PPPOE_STATE_PADR_SENT 2 +#define PPPOE_STATE_SESSION 3 +/* passive */ +#define PPPOE_STATE_PADO_SENT 1 + +#define PPPOE_HEADERLEN sizeof(struct pppoehdr) +#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ + +#define PPPOE_TAG_EOL 0x0000 /* end of list */ +#define PPPOE_TAG_SNAME 0x0101 /* service name */ +#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ +#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ +#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ +#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ +#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ +#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ +#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ +#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ + +#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ +#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ +#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ +#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ +#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ + +#ifndef PPPOE_MAX_AC_COOKIE_LEN +#define PPPOE_MAX_AC_COOKIE_LEN 64 +#endif + +struct pppoe_softc { + struct pppoe_softc *next; + struct netif *sc_ethif; /* ethernet interface we are using */ + ppp_pcb *pcb; /* PPP PCB */ + + struct eth_addr sc_dest; /* hardware address of concentrator */ + u16_t sc_session; /* PPPoE session id */ + u8_t sc_state; /* discovery phase or session connected */ + +#ifdef PPPOE_TODO + u8_t *sc_service_name; /* if != NULL: requested name of service */ + u8_t *sc_concentrator_name; /* if != NULL: requested concentrator id */ +#endif /* PPPOE_TODO */ + u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */ + u8_t sc_ac_cookie_len; /* length of cookie data */ +#ifdef PPPOE_SERVER + u8_t *sc_hunique; /* content of host unique we must echo back */ + u8_t sc_hunique_len; /* length of host unique */ +#endif + u8_t sc_padi_retried; /* number of PADI retries already done */ + u8_t sc_padr_retried; /* number of PADR retries already done */ +}; + + +#define pppoe_init() /* compatibility define, no initialization needed */ + +ppp_pcb *pppoe_create(struct netif *pppif, + struct netif *ethif, + const char *service_name, const char *concentrator_name, + ppp_link_status_cb_fn link_status_cb, void *ctx_cb); + +/* + * Functions called from lwIP + * DO NOT CALL FROM lwIP USER APPLICATION. + */ +void pppoe_disc_input(struct netif *netif, struct pbuf *p); +void pppoe_data_input(struct netif *netif, struct pbuf *p); + +#endif /* PPP_OE_H */ + +#endif /* PPP_SUPPORT && PPPOE_SUPPORT */ diff --git a/sys/include/netif/ppp/pppol2tp.h b/sys/include/netif/ppp/pppol2tp.h new file mode 100644 index 0000000..f03950e --- /dev/null +++ b/sys/include/netif/ppp/pppol2tp.h @@ -0,0 +1,201 @@ +/** + * @file + * Network Point to Point Protocol over Layer 2 Tunneling Protocol header file. + * + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && PPPOL2TP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef PPPOL2TP_H +#define PPPOL2TP_H + +#include "ppp.h" + +/* Timeout */ +#define PPPOL2TP_CONTROL_TIMEOUT (5*1000) /* base for quick timeout calculation */ +#define PPPOL2TP_SLOW_RETRY (60*1000) /* persistent retry interval */ + +#define PPPOL2TP_MAXSCCRQ 4 /* retry SCCRQ four times (quickly) */ +#define PPPOL2TP_MAXICRQ 4 /* retry IRCQ four times */ +#define PPPOL2TP_MAXICCN 4 /* retry ICCN four times */ + +/* L2TP header flags */ +#define PPPOL2TP_HEADERFLAG_CONTROL 0x8000 +#define PPPOL2TP_HEADERFLAG_LENGTH 0x4000 +#define PPPOL2TP_HEADERFLAG_SEQUENCE 0x0800 +#define PPPOL2TP_HEADERFLAG_OFFSET 0x0200 +#define PPPOL2TP_HEADERFLAG_PRIORITY 0x0100 +#define PPPOL2TP_HEADERFLAG_VERSION 0x0002 + +/* Mandatory bits for control: Control, Length, Sequence, Version 2 */ +#define PPPOL2TP_HEADERFLAG_CONTROL_MANDATORY (PPPOL2TP_HEADERFLAG_CONTROL|PPPOL2TP_HEADERFLAG_LENGTH|PPPOL2TP_HEADERFLAG_SEQUENCE|PPPOL2TP_HEADERFLAG_VERSION) +/* Forbidden bits for control: Offset, Priority */ +#define PPPOL2TP_HEADERFLAG_CONTROL_FORBIDDEN (PPPOL2TP_HEADERFLAG_OFFSET|PPPOL2TP_HEADERFLAG_PRIORITY) + +/* Mandatory bits for data: Version 2 */ +#define PPPOL2TP_HEADERFLAG_DATA_MANDATORY (PPPOL2TP_HEADERFLAG_VERSION) + +/* AVP (Attribute Value Pair) header */ +#define PPPOL2TP_AVPHEADERFLAG_MANDATORY 0x8000 +#define PPPOL2TP_AVPHEADERFLAG_HIDDEN 0x4000 +#define PPPOL2TP_AVPHEADERFLAG_LENGTHMASK 0x03ff + +/* -- AVP - Message type */ +#define PPPOL2TP_AVPTYPE_MESSAGE 0 /* Message type */ + +/* Control Connection Management */ +#define PPPOL2TP_MESSAGETYPE_SCCRQ 1 /* Start Control Connection Request */ +#define PPPOL2TP_MESSAGETYPE_SCCRP 2 /* Start Control Connection Reply */ +#define PPPOL2TP_MESSAGETYPE_SCCCN 3 /* Start Control Connection Connected */ +#define PPPOL2TP_MESSAGETYPE_STOPCCN 4 /* Stop Control Connection Notification */ +#define PPPOL2TP_MESSAGETYPE_HELLO 6 /* Hello */ +/* Call Management */ +#define PPPOL2TP_MESSAGETYPE_OCRQ 7 /* Outgoing Call Request */ +#define PPPOL2TP_MESSAGETYPE_OCRP 8 /* Outgoing Call Reply */ +#define PPPOL2TP_MESSAGETYPE_OCCN 9 /* Outgoing Call Connected */ +#define PPPOL2TP_MESSAGETYPE_ICRQ 10 /* Incoming Call Request */ +#define PPPOL2TP_MESSAGETYPE_ICRP 11 /* Incoming Call Reply */ +#define PPPOL2TP_MESSAGETYPE_ICCN 12 /* Incoming Call Connected */ +#define PPPOL2TP_MESSAGETYPE_CDN 14 /* Call Disconnect Notify */ +/* Error reporting */ +#define PPPOL2TP_MESSAGETYPE_WEN 15 /* WAN Error Notify */ +/* PPP Session Control */ +#define PPPOL2TP_MESSAGETYPE_SLI 16 /* Set Link Info */ + +/* -- AVP - Result code */ +#define PPPOL2TP_AVPTYPE_RESULTCODE 1 /* Result code */ +#define PPPOL2TP_RESULTCODE 1 /* General request to clear control connection */ + +/* -- AVP - Protocol version (!= L2TP Header version) */ +#define PPPOL2TP_AVPTYPE_VERSION 2 +#define PPPOL2TP_VERSION 0x0100 /* L2TP Protocol version 1, revision 0 */ + +/* -- AVP - Framing capabilities */ +#define PPPOL2TP_AVPTYPE_FRAMINGCAPABILITIES 3 /* Bearer capabilities */ +#define PPPOL2TP_FRAMINGCAPABILITIES 0x00000003 /* Async + Sync framing */ + +/* -- AVP - Bearer capabilities */ +#define PPPOL2TP_AVPTYPE_BEARERCAPABILITIES 4 /* Bearer capabilities */ +#define PPPOL2TP_BEARERCAPABILITIES 0x00000003 /* Analog + Digital Access */ + +/* -- AVP - Tie breaker */ +#define PPPOL2TP_AVPTYPE_TIEBREAKER 5 + +/* -- AVP - Host name */ +#define PPPOL2TP_AVPTYPE_HOSTNAME 7 /* Host name */ +#define PPPOL2TP_HOSTNAME "lwIP" /* FIXME: make it configurable */ + +/* -- AVP - Vendor name */ +#define PPPOL2TP_AVPTYPE_VENDORNAME 8 /* Vendor name */ +#define PPPOL2TP_VENDORNAME "lwIP" /* FIXME: make it configurable */ + +/* -- AVP - Assign tunnel ID */ +#define PPPOL2TP_AVPTYPE_TUNNELID 9 /* Assign Tunnel ID */ + +/* -- AVP - Receive window size */ +#define PPPOL2TP_AVPTYPE_RECEIVEWINDOWSIZE 10 /* Receive window size */ +#define PPPOL2TP_RECEIVEWINDOWSIZE 8 /* FIXME: make it configurable */ + +/* -- AVP - Challenge */ +#define PPPOL2TP_AVPTYPE_CHALLENGE 11 /* Challenge */ + +/* -- AVP - Cause code */ +#define PPPOL2TP_AVPTYPE_CAUSECODE 12 /* Cause code*/ + +/* -- AVP - Challenge response */ +#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE 13 /* Challenge response */ +#define PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE 16 + +/* -- AVP - Assign session ID */ +#define PPPOL2TP_AVPTYPE_SESSIONID 14 /* Assign Session ID */ + +/* -- AVP - Call serial number */ +#define PPPOL2TP_AVPTYPE_CALLSERIALNUMBER 15 /* Call Serial Number */ + +/* -- AVP - Framing type */ +#define PPPOL2TP_AVPTYPE_FRAMINGTYPE 19 /* Framing Type */ +#define PPPOL2TP_FRAMINGTYPE 0x00000001 /* Sync framing */ + +/* -- AVP - TX Connect Speed */ +#define PPPOL2TP_AVPTYPE_TXCONNECTSPEED 24 /* TX Connect Speed */ +#define PPPOL2TP_TXCONNECTSPEED 100000000 /* Connect speed: 100 Mbits/s */ + +/* L2TP Session state */ +#define PPPOL2TP_STATE_INITIAL 0 +#define PPPOL2TP_STATE_SCCRQ_SENT 1 +#define PPPOL2TP_STATE_ICRQ_SENT 2 +#define PPPOL2TP_STATE_ICCN_SENT 3 +#define PPPOL2TP_STATE_DATA 4 + +#define PPPOL2TP_OUTPUT_DATA_HEADER_LEN 6 /* Our data header len */ + +/* + * PPPoL2TP interface control block. + */ +typedef struct pppol2tp_pcb_s pppol2tp_pcb; +struct pppol2tp_pcb_s { + ppp_pcb *ppp; /* PPP PCB */ + u8_t phase; /* L2TP phase */ + struct udp_pcb *udp; /* UDP L2TP Socket */ + struct netif *netif; /* Output interface, used as a default route */ + ip_addr_t remote_ip; /* LNS IP Address */ + u16_t remote_port; /* LNS port */ +#if PPPOL2TP_AUTH_SUPPORT + const u8_t *secret; /* Secret string */ + u8_t secret_len; /* Secret string length */ + u8_t secret_rv[16]; /* Random vector */ + u8_t challenge_hash[16]; /* Challenge response */ + u8_t send_challenge; /* Boolean whether the next sent packet should contains a challenge response */ +#endif /* PPPOL2TP_AUTH_SUPPORT */ + + u16_t tunnel_port; /* Tunnel port */ + u16_t our_ns; /* NS to peer */ + u16_t peer_nr; /* NR from peer */ + u16_t peer_ns; /* NS from peer */ + u16_t source_tunnel_id; /* Tunnel ID assigned by peer */ + u16_t remote_tunnel_id; /* Tunnel ID assigned to peer */ + u16_t source_session_id; /* Session ID assigned by peer */ + u16_t remote_session_id; /* Session ID assigned to peer */ + + u8_t sccrq_retried; /* number of SCCRQ retries already done */ + u8_t icrq_retried; /* number of ICRQ retries already done */ + u8_t iccn_retried; /* number of ICCN retries already done */ +}; + + +/* Create a new L2TP session. */ +ppp_pcb *pppol2tp_create(struct netif *pppif, + struct netif *netif, const ip_addr_t *ipaddr, u16_t port, + const u8_t *secret, u8_t secret_len, + ppp_link_status_cb_fn link_status_cb, void *ctx_cb); + +#endif /* PPPOL2TP_H */ +#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */ diff --git a/sys/include/netif/ppp/pppos.h b/sys/include/netif/ppp/pppos.h new file mode 100644 index 0000000..58adedb --- /dev/null +++ b/sys/include/netif/ppp/pppos.h @@ -0,0 +1,118 @@ +/** + * @file + * Network Point to Point Protocol over Serial header file. + * + */ + +/* + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && PPPOS_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef PPPOS_H +#define PPPOS_H + +#include "net/sys.h" + +#include "ppp.h" +#include "vj.h" + +/* PPP packet parser states. Current state indicates operation yet to be + * completed. */ +enum { + PDIDLE = 0, /* Idle state - waiting. */ + PDSTART, /* Process start flag. */ + PDADDRESS, /* Process address field. */ + PDCONTROL, /* Process control field. */ + PDPROTOCOL1, /* Process protocol field 1. */ + PDPROTOCOL2, /* Process protocol field 2. */ + PDDATA /* Process data byte. */ +}; + +/* PPPoS serial output callback function prototype */ +typedef u32_t (*pppos_output_cb_fn)(ppp_pcb *pcb, u8_t *data, u32_t len, void *ctx); + +/* + * Extended asyncmap - allows any character to be escaped. + */ +typedef u8_t ext_accm[32]; + +/* + * PPPoS interface control block. + */ +typedef struct pppos_pcb_s pppos_pcb; +struct pppos_pcb_s { + /* -- below are data that will NOT be cleared between two sessions */ + ppp_pcb *ppp; /* PPP PCB */ + pppos_output_cb_fn output_cb; /* PPP serial output callback */ + + /* -- below are data that will be cleared between two sessions + * + * last_xmit must be the first member of cleared members, because it is + * used to know which part must not be cleared. + */ + u32_t last_xmit; /* Time of last transmission. */ + ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ + + /* flags */ + unsigned int open :1; /* Set if PPPoS is open */ + unsigned int pcomp :1; /* Does peer accept protocol compression? */ + unsigned int accomp :1; /* Does peer accept addr/ctl compression? */ + + /* PPPoS rx */ + ext_accm in_accm; /* Async-Ctl-Char-Map for input. */ + struct pbuf *in_head, *in_tail; /* The input packet. */ + u16_t in_protocol; /* The input protocol code. */ + u16_t in_fcs; /* Input Frame Check Sequence value. */ + u8_t in_state; /* The input process state. */ + u8_t in_escaped; /* Escape next character. */ +}; + +/* Create a new PPPoS session. */ +ppp_pcb *pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, + ppp_link_status_cb_fn link_status_cb, void *ctx_cb); + +#if !NO_SYS && !PPP_INPROC_IRQ_SAFE +/* Pass received raw characters to PPPoS to be decoded through lwIP TCPIP thread. */ +err_t pppos_input_tcpip(ppp_pcb *ppp, u8_t *s, int l); +#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ + +/* PPP over Serial: this is the input function to be called for received data. */ +void pppos_input(ppp_pcb *ppp, u8_t* data, int len); + + +/* + * Functions called from lwIP + * DO NOT CALL FROM lwIP USER APPLICATION. + */ +#if !NO_SYS && !PPP_INPROC_IRQ_SAFE +err_t pppos_input_sys(struct pbuf *p, struct netif *inp); +#endif /* !NO_SYS && !PPP_INPROC_IRQ_SAFE */ + +#endif /* PPPOS_H */ +#endif /* PPP_SUPPORT && PPPOL2TP_SUPPORT */ diff --git a/sys/include/netif/ppp/upap.h b/sys/include/netif/ppp/upap.h new file mode 100644 index 0000000..7da792e --- /dev/null +++ b/sys/include/netif/ppp/upap.h @@ -0,0 +1,123 @@ +/* + * upap.h - User/Password Authentication Protocol definitions. + * + * Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any legal + * details, please contact + * Office of Technology Transfer + * Carnegie Mellon University + * 5000 Forbes Avenue + * Pittsburgh, PA 15213-3890 + * (412) 268-4387, fax: (412) 268-7395 + * tech-transfer@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Id: upap.h,v 1.8 2002/12/04 23:03:33 paulus Exp $ + */ + +#include "netif/ppp/ppp_opts.h" +#if PPP_SUPPORT && PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ + +#ifndef UPAP_H +#define UPAP_H + +#include "ppp.h" + +/* + * Packet header = Code, id, length. + */ +#define UPAP_HEADERLEN 4 + + +/* + * UPAP codes. + */ +#define UPAP_AUTHREQ 1 /* Authenticate-Request */ +#define UPAP_AUTHACK 2 /* Authenticate-Ack */ +#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ + + +/* + * Client states. + */ +#define UPAPCS_INITIAL 0 /* Connection down */ +#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ +#define UPAPCS_OPEN 4 /* We've received an Ack */ +#define UPAPCS_BADAUTH 5 /* We've received a Nak */ + +/* + * Server states. + */ +#define UPAPSS_INITIAL 0 /* Connection down */ +#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ +#define UPAPSS_OPEN 4 /* We've sent an Ack */ +#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ + + +/* + * Timeouts. + */ +#if 0 /* moved to ppp_opts.h */ +#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ +#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ +#endif /* moved to ppp_opts.h */ + +/* + * Each interface is described by upap structure. + */ +#if PAP_SUPPORT +typedef struct upap_state { + const char *us_user; /* User */ + u8_t us_userlen; /* User length */ + const char *us_passwd; /* Password */ + u8_t us_passwdlen; /* Password length */ + u8_t us_clientstate; /* Client state */ +#if PPP_SERVER + u8_t us_serverstate; /* Server state */ +#endif /* PPP_SERVER */ + u8_t us_id; /* Current id */ + u8_t us_transmits; /* Number of auth-reqs sent */ +} upap_state; +#endif /* PAP_SUPPORT */ + + +void upap_authwithpeer(ppp_pcb *pcb, const char *user, const char *password); +#if PPP_SERVER +void upap_authpeer(ppp_pcb *pcb); +#endif /* PPP_SERVER */ + +extern const struct protent pap_protent; + +#endif /* UPAP_H */ +#endif /* PPP_SUPPORT && PAP_SUPPORT */ diff --git a/sys/include/objgfx/ogDisplay_VESA.h b/sys/include/objgfx/ogDisplay_VESA.h old mode 100644 new mode 100755 diff --git a/sys/include/pci/hd.h b/sys/include/pci/hd.h new file mode 100644 index 0000000..6b0870e --- /dev/null +++ b/sys/include/pci/hd.h @@ -0,0 +1,487 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PCI_HD_H_ +#define _PCI_HD_H_ + +#include +#include + +#define hdData 0x0 +#define hdError 0x1 +#define hdSecCount 0x2 +#define hdSecNum 0x3 +#define hdCylLow 0x4 +#define hdCylHi 0x5 +#define hdHead 0x6 +#define hdStat 0x7 +#define hdCmd 0x7 + +/* ATA Uhm? */ +#define ATA_IDENTIFY_COMMAND_SET_SUPPORTED1_48BIT_ENABLE 0x0400 +#define ATA_IDENTIFY_SECTOR_LARGER_THEN_512_ENABLE 0x0100 + +/* ATA register defines */ +#define ATA_DATA 0 /* (RW) data */ + +#define ATA_FEATURE 1 /* (W) feature */ +#define ATA_F_DMA 0x01 /* enable DMA */ +#define ATA_F_OVL 0x02 /* enable overlap */ + +#define ATA_COUNT 2 /* (W) sector count */ + +#define ATA_SECTOR 3 /* (RW) sector # */ +#define ATA_CYL_LSB 4 /* (RW) cylinder# LSB */ +#define ATA_CYL_MSB 5 /* (RW) cylinder# MSB */ +#define ATA_DRIVE 6 /* (W) Sector/Drive/Head */ +#define ATA_D_LBA 0x40 /* use LBA addressing */ +#define ATA_D_IBM 0xa0 /* 512 byte sectors, ECC */ + +#define ATA_COMMAND 7 /* (W) command */ + +#define ATA_ERROR 8 /* (R) error */ +#define ATA_E_ILI 0x01 /* illegal length */ +#define ATA_E_NM 0x02 /* no media */ +#define ATA_E_ABORT 0x04 /* command aborted */ +#define ATA_E_MCR 0x08 /* media change request */ +#define ATA_E_IDNF 0x10 /* ID not found */ +#define ATA_E_MC 0x20 /* media changed */ +#define ATA_E_UNC 0x40 /* uncorrectable data */ +#define ATA_E_ICRC 0x80 /* UDMA crc error */ +#define ATA_E_ATAPI_SENSE_MASK 0xf0 /* ATAPI sense key mask */ + +#define ATA_IREASON 9 /* (R) interrupt reason */ +#define ATA_I_CMD 0x01 /* cmd (1) | data (0) */ +#define ATA_I_IN 0x02 /* read (1) | write (0) */ +#define ATA_I_RELEASE 0x04 /* released bus (1) */ +#define ATA_I_TAGMASK 0xf8 /* tag mask */ + +#define ATA_STATUS 10 /* (R) status */ +#define ATA_ALTSTAT 11 /* (R) alternate status */ +#define ATA_S_ERROR 0x01 /* error */ +#define ATA_S_INDEX 0x02 /* index */ +#define ATA_S_CORR 0x04 /* data corrected */ +#define ATA_S_DRQ 0x08 /* data request */ +#define ATA_S_DSC 0x10 /* drive seek completed */ +#define ATA_S_SERVICE 0x10 /* drive needs service */ +#define ATA_S_DWF 0x20 /* drive write fault */ +#define ATA_S_DMA 0x20 /* DMA ready */ +#define ATA_S_READY 0x40 /* drive ready */ +#define ATA_S_BUSY 0x80 /* busy */ + +#define ATA_CONTROL 12 /* (W) control */ + +#define ATA_CTLOFFSET 0x206 /* control register offset */ +#define ATA_PCCARD_CTLOFFSET 0x0e /* do for PCCARD devices */ +#define ATA_PC98_CTLOFFSET 0x10c /* do for PC98 devices */ +#define ATA_A_IDS 0x02 /* disable interrupts */ +#define ATA_A_RESET 0x04 /* RESET controller */ +#ifdef ATA_LEGACY_SUPPORT +#define ATA_A_4BIT 0x08 /* 4 head bits: obsolete 1996 */ +#else +#define ATA_A_4BIT 0x00 +#endif +#define ATA_A_HOB 0x80 /* High Order Byte enable */ + +/* ATA Commands */ +#define ATA_IDENTIFY 0xEC +#define ATA_CHECK_POWER_MODE 0xE5 +#define ATA_STANDBY 0xE2 +#define ATA_STANDBY_IMMED 0xE0 +#define ATA_IDLE_IMMED 0xE1 +#define ATA_IDLE 0xE3 +#define ATA_FLUSH_CACHE 0xE7 +#define ATA_FLUSH_CACHE_EXT 0xEA +#define ATA_READ_DMA_EXT 0x25 +#define ATA_READ_DMA 0xC8 +#define ATA_READ_SECTORS_EXT 0x24 +#define ATA_READ_SECTORS 0x20 +#define ATA_WRITE_DMA_EXT 0x35 +#define ATA_WRITE_DMA 0xCA +#define ATA_WRITE_SECTORS_EXT 0x34 +#define ATA_WRITE_SECTORS 0x30 +#define ATA_WRITE_UNCORRECTABLE 0x45 +#define ATA_READ_VERIFY_SECTORS 0x40 +#define ATA_READ_VERIFY_SECTORS_EXT 0x42 +#define ATA_READ_BUFFER 0xE4 +#define ATA_WRITE_BUFFER 0xE8 +#define ATA_EXECUTE_DEVICE_DIAG 0x90 +#define ATA_SET_FEATURES 0xEF +#define ATA_SMART 0xB0 +#define ATA_PACKET_IDENTIFY 0xA1 +#define ATA_PACKET 0xA0 +#define ATA_READ_FPDMA 0x60 +#define ATA_WRITE_FPDMA 0x61 +#define ATA_READ_LOG_EXT 0x2F +#define ATA_NOP 0x00 +#define ATA_DEVICE_RESET 0x08 +#define ATA_MEDIA_EJECT 0xED +#define ATA_SECURITY_UNLOCK 0xF2 +#define ATA_SECURITY_FREEZE_LOCK 0xF5 +#define ATA_DATA_SET_MANAGEMENT 0x06 +#define ATA_DOWNLOAD_MICROCODE 0x92 +#define ATA_WRITE_STREAM_DMA_EXT 0x3A +#define ATA_READ_LOG_DMA_EXT 0x47 +#define ATA_READ_STREAM_DMA_EXT 0x2A +#define ATA_WRITE_DMA_FUA 0x3D +#define ATA_WRITE_LOG_DMA_EXT 0x57 +#define ATA_READ_DMA_QUEUED 0xC7 +#define ATA_READ_DMA_QUEUED_EXT 0x26 +#define ATA_WRITE_DMA_QUEUED 0xCC +#define ATA_WRITE_DMA_QUEUED_EXT 0x36 +#define ATA_WRITE_DMA_QUEUED_FUA_EXT 0x3E +#define ATA_READ_MULTIPLE 0xC4 +#define ATA_READ_MULTIPLE_EXT 0x29 +#define ATA_WRITE_MULTIPLE 0xC5 +#define ATA_WRITE_MULTIPLE_EXT 0x39 +#define ATA_WRITE_MULTIPLE_FUA_EXT 0xCE + +struct driveInfo { + struct driveDiskLabel *diskLabel; + struct ata_identify_data *ata_identify; + uint32_t lba_high; + uint32_t lba_low; + uint32_t sector_size; + char hdEnable; + char hdDev; + char hdFlags; + char hdShift; + long hdMask; + uint32_t hdMulti; + long hdPort; + long hdSize; + long hdCalc; + long parOffset; + int part; + long lba_start; + long lba_end; +}; + +int initHardDisk(); +int hdWrite(struct driveInfo *hdd, void *, uInt32, uInt32); +int hdRead(struct driveInfo *hdd, void *, uInt32, uInt32); +int hdReset(); +int hdIoctl(); +int hdStart(); +int hdStop(); +int hdStandby(); +int hdInit(struct device_node *dev); + +struct dos_partition { + unsigned char dp_flag; /* bootstrap flags */ + unsigned char dp_shd; /* starting head */ + unsigned char dp_ssect; /* starting sector */ + unsigned char dp_scyl; /* starting cylinder */ + unsigned char dp_type; /* partition type */ + unsigned char dp_ehd; /* end head */ + unsigned char dp_esect; /* end sector */ + unsigned char dp_ecyl; /* end cylinder */ + uInt32 dp_start; /* absolute starting sector number */ + uInt32 dp_size; /* partition size in sectors */ +}; + +#define MAXPARTITIONS 8 + +struct bsd_disklabel { + uint32_t d_magic; /* the magic number */ + u_int16_t d_type; /* drive type */ + u_int16_t d_subtype; /* controller/d_type specific */ + char d_typename[16]; /* type name, e.g. "eagle" */ + + char d_packname[16]; /* pack identifier */ + + /* disk geometry: */ + uint32_t d_secsize; /* # of bytes per sector */ + uint32_t d_nsectors; /* # of data sectors per track */ + uint32_t d_ntracks; /* # of tracks per cylinder */ + uint32_t d_ncylinders; /* # of data cylinders per unit */ + uint32_t d_secpercyl; /* # of data sectors per cylinder */ + uint32_t d_secperunit; /* # of data sectors per unit */ + + /* + * Spares (bad sector replacements) below are not counted in + * d_nsectors or d_secpercyl. Spare sectors are assumed to + * be physical sectors which occupy space at the end of each + * track and/or cylinder. + */ + u_int16_t d_sparespertrack; /* # of spare sectors per track */ + u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */ + /* + * Alternate cylinders include maintenance, replacement, configuration + * description areas, etc. + */ + uint32_t d_acylinders; /* # of alt. cylinders per unit */ + + /* hardware characteristics: */ + /* + * d_interleave, d_trackskew and d_cylskew describe perturbations + * in the media format used to compensate for a slow controller. + * Interleave is physical sector interleave, set up by the + * formatter or controller when formatting. When interleaving is + * in use, logically adjacent sectors are not physically + * contiguous, but instead are separated by some number of + * sectors. It is specified as the ratio of physical sectors + * traversed per logical sector. Thus an interleave of 1:1 + * implies contiguous layout, while 2:1 implies that logical + * sector 0 is separated by one sector from logical sector 1. + * d_trackskew is the offset of sector 0 on track N relative to + * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew + * is the offset of sector 0 on cylinder N relative to sector 0 + * on cylinder N-1. + */ + u_int16_t d_rpm; /* rotational speed */ + u_int16_t d_interleave; /* hardware sector interleave */ + u_int16_t d_trackskew; /* sector 0 skew, per track */ + u_int16_t d_cylskew; /* sector 0 skew, per cylinder */ + uint32_t d_headswitch; /* head switch time, usec */ + uint32_t d_trkseek; /* track-to-track seek, usec */ + uint32_t d_flags; /* generic flags */ +#define NDDATA 5 + uint32_t d_drivedata[NDDATA]; /* drive-type specific information */ +#define NSPARE 5 + uint32_t d_spare[NSPARE]; /* reserved for future use */ + uint32_t d_magic2; /* the magic number (again) */ + u_int16_t d_checksum; /* xor of data incl. partitions */ + + /* filesystem and partition information: */ + u_int16_t d_npartitions; /* number of partitions in following */ + uint32_t d_bbsize; /* size of boot area at sn0, bytes */ + uint32_t d_sbsize; /* max size of fs superblock, bytes */ + struct partition { /* the partition table */ + uint32_t p_size; /* number of sectors in partition */ + uint32_t p_offset; /* starting sector */ + uint32_t p_fsize; /* filesystem basic fragment size */ + u_int8_t p_fstype; /* filesystem type, see below */ + u_int8_t p_frag; /* filesystem fragments per block */ + u_int16_t p_cpg; /* filesystem cylinders per group */ + } d_partitions[MAXPARTITIONS]; /* actually may be more */ +}; + +static const char *fstypenames[] = { "unused", "swap", "Version 6", "Version 7", "System V", "4.1BSD", "Eighth Edition", "4.2BSD", "MSDOS", "4.4LFS", "unknown", "HPFS", "ISO9660", "boot", "vinum", "raid", "?", "?", "?", "?", "jfs", NULL }; + +/** + * @name ATA_IDENTIFY_DEVICE_FIELD_LENGTHS + * + * The following constants define the number of bytes contained in various + * fields found in the IDENTIFY DEVICE data structure. + */ +#define ATA_IDENTIFY_SERIAL_NUMBER_LEN 20 +#define ATA_IDENTIFY_MODEL_NUMBER_LEN 40 +#define ATA_IDENTIFY_FW_REVISION_LEN 8 +#define ATA_IDENTIFY_48_LBA_LEN 8 +#define ATA_IDENTIFY_MEDIA_SERIAL_NUMBER_LEN 30 +#define ATA_IDENTIFY_WWN_LEN 8 + +struct ata_identify_data { + u_int16_t general_config_bits; // word 00 + u_int16_t obsolete0; // word 01 (num cylinders) + u_int16_t vendor_specific_config_bits; // word 02 + u_int16_t obsolete1; // word 03 (num heads) + u_int16_t retired1[2]; // words 04-05 + u_int16_t obsolete2; // word 06 (sectors / track) + u_int16_t reserved_for_compact_flash1[2]; // words 07-08 + u_int16_t retired0; // word 09 + u_int8_t serial_number[ATA_IDENTIFY_SERIAL_NUMBER_LEN]; // word 10-19 + u_int16_t retired2[2]; // words 20-21 + u_int16_t obsolete4; // word 22 + u_int8_t firmware_revision[ATA_IDENTIFY_FW_REVISION_LEN]; // words 23-26 + u_int8_t model_number[ATA_IDENTIFY_MODEL_NUMBER_LEN]; // words 27-46 + u_int16_t max_sectors_per_multiple; // word 47 + u_int16_t reserved0; // word 48 + u_int16_t capabilities1; // word 49 + u_int16_t capabilities2; // word 50 + u_int16_t obsolete5[2]; // words 51-52 + u_int16_t validity_bits; // word 53 + u_int16_t obsolete6[5]; // words 54-58 Used to be: + // current cylinders, + // current heads, + // current sectors/Track, + // current capacity + u_int16_t current_max_sectors_per_multiple; // word 59 + u_int8_t total_num_sectors[4]; // words 60-61 + u_int16_t obsolete7; // word 62 + u_int16_t multi_word_dma_mode; // word 63 + u_int16_t pio_modes_supported; // word 64 + u_int16_t min_multiword_dma_transfer_cycle; // word 65 + u_int16_t rec_min_multiword_dma_transfer_cycle; // word 66 + u_int16_t min_pio_transfer_no_flow_ctrl; // word 67 + u_int16_t min_pio_transfer_with_flow_ctrl; // word 68 + u_int16_t additional_supported; // word 69 + u_int16_t reserved1; // word 70 + u_int16_t reserved2[4]; // words 71-74 + u_int16_t queue_depth; // word 75 + u_int16_t serial_ata_capabilities; // word 76 + u_int16_t serial_ata_reserved; // word 77 + u_int16_t serial_ata_features_supported; // word 78 + u_int16_t serial_ata_features_enabled; // word 79 + u_int16_t major_version_number; // word 80 + u_int16_t minor_version_number; // word 81 + u_int16_t command_set_supported0; // word 82 + u_int16_t command_set_supported1; // word 83 + u_int16_t command_set_supported_extention; // word 84 + u_int16_t command_set_enabled0; // word 85 + u_int16_t command_set_enabled1; // word 86 + u_int16_t command_set_default; // word 87 + u_int16_t ultra_dma_mode; // word 88 + u_int16_t security_erase_completion_time; // word 89 + u_int16_t enhanced_security_erase_time; // word 90 + u_int16_t current_power_mgmt_value; // word 91 + u_int16_t master_password_revision; // word 92 + u_int16_t hardware_reset_result; // word 93 + u_int16_t current_acoustic_management_value; // word 94 + u_int16_t stream_min_request_size; // word 95 + u_int16_t stream_transfer_time; // word 96 + u_int16_t stream_access_latency; // word 97 + u_int16_t stream_performance_granularity[2]; // words 98-99 + u_int8_t max_48bit_lba[ATA_IDENTIFY_48_LBA_LEN]; // words 100-103 + u_int16_t streaming_transfer_time; // word 104 + u_int16_t max_lba_range_entry_blocks; // word 105 + u_int16_t physical_logical_sector_info; // word 106 + u_int16_t acoustic_test_interseek_delay; // word 107 + u_int8_t world_wide_name[ATA_IDENTIFY_WWN_LEN]; // words 108-111 + u_int8_t reserved_for_wwn_extention[ATA_IDENTIFY_WWN_LEN]; // words 112-115 + u_int16_t reserved4; // word 116 + u_int8_t words_per_logical_sector[4]; // words 117-118 + u_int16_t command_set_supported2; // word 119 + u_int16_t reserved5[7]; // words 120-126 + u_int16_t removable_media_status; // word 127 + u_int16_t security_status; // word 128 + u_int16_t vendor_specific1[31]; // words 129-159 + u_int16_t cfa_power_mode1; // word 160 + u_int16_t reserved_for_compact_flash2[7]; // words 161-167 + u_int16_t device_nominal_form_factor; // word 168 + u_int16_t data_set_management; // word 169 + u_int16_t reserved_for_compact_flash3[6]; // words 170-175 + u_int16_t current_media_serial_number[ATA_IDENTIFY_MEDIA_SERIAL_NUMBER_LEN]; //words 176-205 + u_int16_t reserved6[3]; // words 206-208 + u_int16_t logical_sector_alignment; // words 209 + u_int16_t reserved7[7]; // words 210-216 + u_int16_t nominal_media_rotation_rate; // word 217 + u_int16_t reserved8[16]; // words 218-233 + u_int16_t min_num_blocks_per_microcode; // word 234 + u_int16_t max_num_blocks_per_microcode; // word 235 + u_int16_t reserved9[19]; // words 236-254 + u_int16_t integrity_word; // word 255 +}; + +/* + * A list of partition types, probably outdated. + */ +static const char * const part_types[256] = { + [0x00] = "unused", + [0x01] = "Primary DOS with 12 bit FAT", + [0x02] = "XENIX / file system", + [0x03] = "XENIX /usr file system", + [0x04] = "Primary DOS with 16 bit FAT (< 32MB)", + [0x05] = "Extended DOS", + [0x06] = "Primary DOS, 16 bit FAT (>= 32MB)", + [0x07] = "NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX", + [0x08] = "AIX file system or SplitDrive", + [0x09] = "AIX boot partition or Coherent", + [0x0A] = "OS/2 Boot Manager, OPUS or Coherent swap", + [0x0B] = "DOS or Windows 95 with 32 bit FAT", + [0x0C] = "DOS or Windows 95 with 32 bit FAT (LBA)", + [0x0E] = "Primary 'big' DOS (>= 32MB, LBA)", + [0x0F] = "Extended DOS (LBA)", + [0x10] = "OPUS", + [0x11] = "OS/2 BM: hidden DOS with 12-bit FAT", + [0x12] = "Compaq diagnostics", + [0x14] = "OS/2 BM: hidden DOS with 16-bit FAT (< 32MB)", + [0x16] = "OS/2 BM: hidden DOS with 16-bit FAT (>= 32MB)", + [0x17] = "OS/2 BM: hidden IFS (e.g. HPFS)", + [0x18] = "AST Windows swapfile", + [0x1b] = "ASUS Recovery partition (NTFS)", + [0x24] = "NEC DOS", + [0x3C] = "PartitionMagic recovery", + [0x39] = "plan9", + [0x40] = "VENIX 286", + [0x41] = "Linux/MINIX (sharing disk with DRDOS)", + [0x42] = "SFS or Linux swap (sharing disk with DRDOS)", + [0x43] = "Linux native (sharing disk with DRDOS)", + [0x4D] = "QNX 4.2 Primary", + [0x4E] = "QNX 4.2 Secondary", + [0x4F] = "QNX 4.2 Tertiary", + [0x50] = "DM (disk manager)", + [0x51] = "DM6 Aux1 (or Novell)", + [0x52] = "CP/M or Microport SysV/AT", + [0x53] = "DM6 Aux3", + [0x54] = "DM6", + [0x55] = "EZ-Drive (disk manager)", + [0x56] = "Golden Bow (disk manager)", + [0x5c] = "Priam Edisk (disk manager)", /* according to S. Widlake */ + [0x61] = "SpeedStor", + [0x63] = "System V/386 (such as ISC UNIX), GNU HURD or Mach", + [0x64] = "Novell Netware/286 2.xx", + [0x65] = "Novell Netware/386 3.xx", + [0x70] = "DiskSecure Multi-Boot", + [0x75] = "PCIX", + [0x77] = "QNX4.x", + [0x78] = "QNX4.x 2nd part", + [0x79] = "QNX4.x 3rd part", + [0x80] = "Minix until 1.4a", + [0x81] = "Minix since 1.4b, early Linux partition or Mitac disk manager", + [0x82] = "Linux swap or Solaris x86", + [0x83] = "Linux native", + [0x84] = "OS/2 hidden C: drive", + [0x85] = "Linux extended", + [0x86] = "NTFS volume set??", + [0x87] = "NTFS volume set??", + [0x93] = "Amoeba file system", + [0x94] = "Amoeba bad block table", + [0x9F] = "BSD/OS", + [0xA0] = "Suspend to Disk", + [0xA5] = "FreeBSD/NetBSD/386BSD", + [0xA6] = "OpenBSD", + [0xA7] = "NeXTSTEP", + [0xA9] = "NetBSD", + [0xAC] = "IBM JFS", + [0xAF] = "HFS+", + [0xB7] = "BSDI BSD/386 file system", + [0xB8] = "BSDI BSD/386 swap", + [0xBE] = "Solaris x86 boot", + [0xBF] = "Solaris x86 (new)", + [0xC1] = "DRDOS/sec with 12-bit FAT", + [0xC4] = "DRDOS/sec with 16-bit FAT (< 32MB)", + [0xC6] = "DRDOS/sec with 16-bit FAT (>= 32MB)", + [0xC7] = "Syrinx", + [0xDB] = "CP/M, Concurrent CP/M, Concurrent DOS or CTOS", + [0xDE] = "DELL Utilities - FAT filesystem", + [0xE1] = "DOS access or SpeedStor with 12-bit FAT extended partition", + [0xE3] = "DOS R/O or SpeedStor", + [0xE4] = "SpeedStor with 16-bit FAT extended partition < 1024 cyl.", + [0xEB] = "BeOS file system", + [0xEE] = "EFI GPT", + [0xEF] = "EFI System Partition", + [0xF1] = "SpeedStor", + [0xF2] = "DOS 3.3+ Secondary", + [0xF4] = "SpeedStor large partition", + [0xFB] = "VMware VMFS", + [0xFE] = "SpeedStor >1024 cyl. or LANstep", + [0xFF] = "Xenix bad blocks table", }; + +#endif diff --git a/sys/include/pci/lnc.h b/sys/include/pci/lnc.h new file mode 100644 index 0000000..aafd2a0 --- /dev/null +++ b/sys/include/pci/lnc.h @@ -0,0 +1,257 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PCI_LNC_H +#define _PCI_LNC_H + +#include + +// TEMP COMMENT FRESH +#define RDP 0x10 // Register Data Port 16Bit +#define RDP32 0x10 // Register Data Port 32Bit +#define RAP 0x12 // Register Address Port 16Bit +#define RAP32 0x14 // Register Address Port 32Bit +#define RESET 0x14 // Reset Port 16Bit +#define RESET32 0x18 // Reset Port 32Bit +#define BDP 0x16 // 16Bit +#define BDP32 0x1C // 32Bit + +// BCR18 +#define BCR18 18 +#define BCR18_DWIO 0x0080 + +// BCR20 +#define BCR20 0x0014 + +// Modes +#define MODE_16 0 +#define MODE_32 1 +#define MODE_INVALID 3 + +// CSR0 +#define CSR0 0x0000 +#define CSR0_STOP 0x0004 + +// CSR15 +#define CSR15 15 +#define CSR15_DXMTFCS 0x0008 +#define CSR15_DRTY 0x0020 +#define CSR15_PROM 0x8000 + +// CSR58 +#define CSR58 0x003A + +struct mds { + uint16_t md0; + uint16_t md1; + short md2; + uint16_t md3; +}; + +struct hostRingEntry_old { + struct mds *md; + union { + //struct mbuf *mbuf; + char *data; + } buff; +}; + +struct hostRingEntry { + uint32_t addr; + uint16_t bcnt; + uint8_t md[6]; + uint32_t reserved; +}; + +struct arpcom { + //struct ifnet ac_if; /* network-visible interface */ + uint8_t ac_enaddr[6]; /* ethernet hardware address */ + int ac_multicnt; /* length of ac_multiaddrs list */ + void *ac_netgraph; /* ng_ether(4) netgraph node info */ +}; + +struct nicInfo { + int ident; /* Type of card */ + int ic; /* Type of ic, Am7990, Am79C960 etc. */ + int memMode; + int iobase; + int mode; /* Mode setting at initialization */ +}; + +struct initBlock16 { + uint16_t mode; // Mode register + uint8_t padr[6]; // Ethernet address + uint8_t ladrf[8]; // Logical address filter (multicast) + uint16_t rdra; // Low order pointer to receive ring + uint16_t rlen; // High order pointer and no. rings + uint16_t tdra; // Low order pointer to transmit ring + uint16_t tlen; // High order pointer and no rings +}; + +struct initBlock32 { + uint16_t mode; + uint8_t rlen; + uint8_t tlen; + uint8_t padr[6]; + uint16_t res; + uint8_t ladrf[8]; + uint32_t rdra; + uint32_t tdra; +}; + +struct lncInfo { + struct arpcom arpcom; + struct nicInfo nic; + struct hostRingEntry *rxRing; + char *rxBuffer; + struct hostRingEntry *txRing; + char *txBuffer; + struct initBlock32 init; + unsigned int ioAddr; + int nrdre; + int ntdre; + int bufferSize; + int txPtr; + int rxPtr; +}; + +/* Functions */ +void lnc_writeCSR(struct lncInfo *, uint16_t, uint16_t); +void lnc_writeCSR32(struct lncInfo *, uint32_t, uint32_t); + +uint16_t lnc_readCSR(struct lncInfo *, uint16_t); +uint32_t lnc_readCSR32(struct lncInfo *, uint32_t); + +void lnc_writeBCR(struct lncInfo *, uint16_t, uint16_t); +void lnc_writeBCR32(struct lncInfo *, uint32_t, uint32_t); + +uint16_t lnc_readBCR(struct lncInfo *, uint16_t); +uint32_t lnc_readBCR32(struct lncInfo *, uint32_t); + +void lnc_reset(struct lncInfo *); +void lnc_reset32(struct lncInfo *); + +int lnc_probe(struct lncInfo *); + +int lnc_switchDWord(struct lncInfo *); + +int lnc_getMode(struct lncInfo *); + +void lnc_isr(); +int lnc_driverOwnsRX(struct lncInfo *); +int lnc_driverOwnsRX(struct lncInfo *); + +void lnc_INT(); +void lnc_rxINT(); +void lnc_txINT(); + +// OLD + +#define NDESC(len2) (1 << len2) +#define NORMAL 0 +#define MEM_SLEW 8 +#define TRANSBUFSIZE 1518 +#define RECVBUFSIZE 1518 +#define NRDRE 3 +#define NTDRE 3 +#define ETHER_ADDR_LEN 6 +#define NE2100_IOSIZE 24 + +#define PCNET_VSW 0x18 +#define NE2100 2 + +/* mem_mode values */ +#define DMA_FIXED 1 +#define DMA_MBUF 2 +#define SHMEM 4 + +/********** Chip Types **********/ +#define UNKNOWN 0 /* Unknown */ +#define LANCE 1 /* Am7990 */ +#define C_LANCE 2 /* Am79C90 */ +#define PCnet_ISA 3 /* Am79C960 */ +#define PCnet_ISAplus 4 /* Am79C961 */ +#define PCnet_ISA_II 5 /* Am79C961A */ +#define PCnet_32 6 /* Am79C965 */ +#define PCnet_PCI 7 /* Am79C970 */ +#define PCnet_PCI_II 8 /* Am79C970A */ +#define PCnet_FAST 9 /* Am79C971 */ +#define PCnet_FASTplus 10 /* Am79C972 */ +#define PCnet_Home 11 /* Am79C978 */ + +/******** AM7990 Specifics **************/ +#define CSR1 1 +#define CSR2 2 +#define CSR3 3 +#define CSR88 88 +#define CSR89 89 + +#define ERR 0x8000 +#define BABL 0x4000 +#define CERR 0x2000 +#define MISS 0x1000 +#define MERR 0x0800 +#define RINT 0x0400 +#define TINT 0x0200 +#define IDON 0x0100 +#define INTR 0x0080 +#define INEA 0x0040 +#define RXON 0x0020 +#define TXON 0x0010 +#define TDMD 0x0008 + +#define STRT 0x0002 +#define INIT 0x0001 + +/* CSR88-89: Chip ID masks */ +#define AMD_MASK 0x003 +#define PART_MASK 0xffff +#define Am79C960 0x0003 +#define Am79C961 0x2260 +#define Am79C961A 0x2261 +#define Am79C965 0x2430 +#define Am79C970 0x0242 +#define Am79C970A 0x2621 +#define Am79C971 0x2623 +#define Am79C972 0x2624 +#define Am79C973 0x2625 +#define Am79C978 0x2626 + +extern struct lncInfo *lnc; + +int initLNC(); +int probe(struct lncInfo *lnc); +int lanceProbe(struct lncInfo *lnc); +int lncAttach(struct lncInfo *lnc, int unit); + +void lncInt(); +void _lncInt(); + +int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uInt8 *dest); + +#endif diff --git a/sys/include/pci/pci.h b/sys/include/pci/pci.h new file mode 100644 index 0000000..1c8d00d --- /dev/null +++ b/sys/include/pci/pci.h @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PCI_H +#define _PCI_H + +#include + +struct pciConfig { + uint16_t vendorID; + uint16_t deviceID; + + uint16_t command; + uint16_t status; + + uint8_t revisionID; + uint8_t progIf; + uint8_t subClass; + uint8_t classCode; + + uint8_t cacheLineSize; + uint8_t latencyTimer; + uint8_t headerType; + uint8_t bist; + + uint32_t bar[6]; + + uint32_t cbPointer; + + uint16_t subsysVendorID; + uint16_t subsysID; + + uint32_t epromAddr; + + uint16_t capabilites; + uint16_t res1; + + uint32_t res2; + + uint8_t intLine; + uint8_t intPin; + uint8_t minGrant; + uint8_t maxLatency; + + /* device info */ + //uint8_t bus; + //uint8_t dev; + //uint8_t func; + //uint8_t irq; + //uint8_t irqLine; + /* base registers */ + //uInt32 base[6]; + //uInt32 size[6]; + //uint16_t subsysVendor; + //uint16_t subsys; + /* Device Info */ + //Move this to anotther struct eventually + uint8_t bus; + uint8_t dev; + uint8_t func; + +}; + +struct confadd { + uint8_t reg :8; + uint8_t func :3; + uint8_t dev :5; + uint8_t bus :8; + uint8_t rsvd :7; + uint8_t enable :1; +}; + +#define countof(a) (sizeof(a) / sizeof(a[0])) + +int pci_init(); + +uint32_t pciProbe(int bus, int dev, int func); +uInt32 pciRead(int bus, int dev, int func, int reg, int bytes); +void pciWrite(int bus, int dev, int func, int reg, uInt32 v, int bytes); + +#endif diff --git a/sys/include/sde/ogDisplay_UbixOS.h b/sys/include/sde/ogDisplay_UbixOS.h new file mode 100755 index 0000000..8726d07 --- /dev/null +++ b/sys/include/sde/ogDisplay_UbixOS.h @@ -0,0 +1,116 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef OGDISPLAY_UBIXOS_H +#define OGDISPLAY_UBIXOS_H + +#include +#include + +struct ogModeInfo { + uint16_t modeAttributes __attribute__((packed)); + uint8_t windowAFlags __attribute__((packed)); + uint8_t windowBFlags __attribute__((packed)); + uint16_t granularity __attribute__((packed)); + uint16_t windowSize __attribute__((packed)); + uint16_t windowASeg __attribute__((packed)); + uint16_t windowBSeg __attribute__((packed)); + void* bankSwitch __attribute__((packed)); + uint16_t bytesPerLine __attribute__((packed)); + uint16_t xRes __attribute__((packed)); + uint16_t yRes __attribute__((packed)); + uint8_t charWidth __attribute__((packed)); + uint8_t charHeight __attribute__((packed)); + uint8_t numBitPlanes __attribute__((packed)); + uint8_t bitsPerPixel __attribute__((packed)); + uint8_t numberOfBanks __attribute__((packed)); + uint8_t memoryModel __attribute__((packed)); + uint8_t bankSize __attribute__((packed)); + uint8_t numOfImagePages __attribute__((packed)); + uint8_t reserved __attribute__((packed)); + // Direct colour fields (required for Direct/6 and YUV/7 memory models + uint8_t redMaskSize __attribute__((packed)); + uint8_t redFieldPosition __attribute__((packed)); + uint8_t greenMaskSize __attribute__((packed)); + uint8_t greenFieldPosition __attribute__((packed)); + uint8_t blueMaskSize __attribute__((packed)); + uint8_t blueFieldPosition __attribute__((packed)); + uint8_t alphaMaskSize __attribute__((packed)); + uint8_t alphaFieldPosition __attribute__((packed)); + uint8_t directColourMode __attribute__((packed)); + // VESA 2.0 specific fields + uint32_t physBasePtr __attribute__((packed)); + void* offScreenMemOffset __attribute__((packed)); + uint16_t offScreenMemSize __attribute__((packed)); + uint8_t paddington[461] __attribute__((packed)); +}; + +struct ogVESAInfo { + char VBESignature[4] __attribute__((packed)); + uint8_t minVersion __attribute__((packed)); + uint8_t majVersion __attribute__((packed)); + uint32_t OEMStringPtr __attribute__((packed)); + uint32_t capabilities __attribute__((packed)); + uint32_t videoModePtr __attribute__((packed)); + uint16_t totalMemory __attribute__((packed)); + // VESA 2.0 specific fields + uint16_t OEMSoftwareRev __attribute__((packed)); + uint32_t OEMVendorNamePtr __attribute__((packed)); + uint32_t OEMProductNamePtr __attribute__((packed)); + uint32_t OEMProductRevPtr __attribute__((packed)); + uint8_t paddington[474] __attribute__((packed)); +}; + +class ogDisplay_UbixOS: public ogSurface { + protected: + void * pages[2]; + uint32_t activePage; + uint32_t visualPage; + ogVESAInfo * VESAInfo; + ogModeInfo * modeInfo; + + uint16_t FindMode(uint32_t, uint32_t, uint32_t); + void GetModeInfo(uint16_t); + void GetVESAInfo(void); + void SetMode(uint16_t); + void SetPal(void); + public: + ogDisplay_UbixOS(void); + virtual bool ogAlias(ogSurface&, uint32_t, uint32_t, uint32_t, uint32_t); + virtual bool ogClone(ogSurface&); + virtual void ogCopyPalette(ogSurface&); + virtual bool ogCreate(uint32_t, uint32_t, ogPixelFmt); + virtual bool ogLoadPalette(const char *); + virtual void ogSetPalette(const ogRGBA8[]); + virtual void ogSetPalette(uint8_t, uint8_t, uint8_t, uint8_t); + virtual void ogSetPalette(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t); + virtual ~ogDisplay_UbixOS(void); +}; +// ogDisplay_UbixOS + +#endif diff --git a/sys/include/string.h b/sys/include/string.h index 781da93..ffc5559 100644 --- a/sys/include/string.h +++ b/sys/include/string.h @@ -26,14 +26,10 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _STRING_H_ -#define _STRING_H_ +#ifndef _STRING_H +#define _STRING_H -#include -#include -#include - - +#include #include void *memcpy(const void *dst, const void * src, size_t length); @@ -48,16 +44,31 @@ char *strtok_r(char *str, const char *sep, char **last); char *strstr(const char *s, char *find); +extern u_char const bcd2bin_data[]; +extern u_char const bin2bcd_data[]; +extern char const hex2ascii_data[]; +#define bcd2bin(bcd) (bcd2bin_data[bcd]) +#define bin2bcd(bin) (bin2bcd_data[bin]) +#define hex2ascii(hex) (hex2ascii_data[hex]) + +#define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z'))) +#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z'))) #ifdef __cplusplus extern "C" { #endif + + + + + + int sprintf(char *buf, const char *fmt, ...); #ifdef __cplusplus } #endif -#endif /* !_STRING_H_ */ +#endif /* END _STRING_H */ diff --git a/sys/include/sys/_timeval.h b/sys/include/sys/_timeval.h new file mode 100644 index 0000000..931f21c --- /dev/null +++ b/sys/include/sys/_timeval.h @@ -0,0 +1,22 @@ +#ifndef _SYS__TIMEVAL_H +#define _SYS__TIMEVAL_H + +#include + +#ifndef _SUSECONDS_T_DECLARED +typedef __suseconds_t suseconds_t; +#define _SUSECONDS_T_DECLARED +#endif + +#ifndef _TIME_T_DECLARED +typedef __time_t time_t; +#define _TIME_T_DECLARED +#endif + +// Structure returned by gettimeofday(2) system call, and used in other calls. +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* and microseconds */ +}; + +#endif /* END _SYS__TIMEVAL_H */ diff --git a/sys/include/sys/_types.h b/sys/include/sys/_types.h new file mode 100644 index 0000000..c998ff6 --- /dev/null +++ b/sys/include/sys/_types.h @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS__TYPES_H_ +#define _SYS__TYPES_H_ + +typedef char __int8_t; +typedef unsigned char __uint8_t; +typedef short __int16_t; +typedef unsigned short __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +typedef long long __int64_t; +typedef unsigned long long __uint64_t; + +typedef unsigned long __clock_t; +typedef __uint32_t __ino_t; typedef __int32_t __ssize_t;/* stat types */ +typedef __uint32_t __dev_t;/* device number */ +typedef __uint16_t __mode_t; typedef __uint16_t __nlink_t;/* link count */ +typedef __uint32_t __uid_t; typedef __uint32_t __gid_t; typedef __int32_t __time_t; typedef __int64_t __blkcnt_t;/* file block count */ +typedef __uint32_t __blksize_t;/* file block size */ +typedef __uint32_t __fflags_t;/* file flags */ +typedef __int8_t __int_fast8_t; typedef __uint8_t __uint_fast8_t; typedef __int16_t __int_fast16_t; typedef __uint16_t __uint_fast16_t; typedef __int32_t __int_fast32_t; typedef __uint32_t __uint_fast32_t; typedef __int64_t __int_fast64_t; typedef __uint64_t __uint_fast64_t; typedef __int32_t __intptr_t; typedef __uint32_t __uintptr_t; typedef __uint32_t __uintfptr_t; typedef __uint32_t __size_t; typedef __int64_t __intmax_t; typedef __uint64_t __uintmax_t; typedef __int32_t __ptrdiff_t; typedef __uint8_t __uint_least8_t; typedef __uint16_t __uint_least16_t; typedef __uint32_t __uint_least32_t; typedef __uint64_t __uint_least64_t; typedef __int8_t __int_least8_t; typedef __int16_t __int_least16_t; typedef __int32_t __int_least32_t; typedef __int64_t __int_least64_t; typedef +int ___wchar_t; + +typedef long __suseconds_t; /* microseconds (signed) */ +typedef __int32_t __pid_t;/* process [group] */ + +#if !defined(__clang__) || !defined(__cplusplus) +typedef __uint_least16_t __char16_t; typedef __uint_least32_t __char32_t; +#endif + +#endif diff --git a/sys/include/sys/cdefs.h b/sys/include/sys/cdefs.h new file mode 100644 index 0000000..4117232 --- /dev/null +++ b/sys/include/sys/cdefs.h @@ -0,0 +1,895 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 + * $FreeBSD: releng/11.1/sys/sys/cdefs.h 317342 2017-04-23 20:32:46Z kib $ + */ + +#ifndef _SYS_CDEFS_H_ +#define _SYS_CDEFS_H_ + +/* + * Testing against Clang-specific extensions. + */ +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension __has_feature +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +/* + * This code has been put in place to help reduce the addition of + * compiler specific defines in FreeBSD code. It helps to aid in + * having a compiler-agnostic source tree. + */ + +#if defined(__GNUC__) || defined(__INTEL_COMPILER) + +#if __GNUC__ >= 3 || defined(__INTEL_COMPILER) +#define __GNUCLIKE_ASM 3 +#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS +#else +#define __GNUCLIKE_ASM 2 +#endif +#define __GNUCLIKE___TYPEOF 1 +#define __GNUCLIKE___OFFSETOF 1 +#define __GNUCLIKE___SECTION 1 + +#ifndef __INTEL_COMPILER +#define __GNUCLIKE_CTOR_SECTION_HANDLING 1 +#endif + +#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 +#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \ + __INTEL_COMPILER < 800 +#undef __GNUCLIKE_BUILTIN_CONSTANT_P +#endif + +#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) +#define __GNUCLIKE_BUILTIN_VARARGS 1 +#define __GNUCLIKE_BUILTIN_STDARG 1 +#define __GNUCLIKE_BUILTIN_VAALIST 1 +#endif + +#if defined(__GNUC__) +#define __GNUC_VA_LIST_COMPATIBILITY 1 +#endif + +/* + * Compiler memory barriers, specific to gcc and clang. + */ +#if defined(__GNUC__) +#define __compiler_membar() __asm __volatile(" " : : : "memory") +#endif + +#ifndef __INTEL_COMPILER +#define __GNUCLIKE_BUILTIN_NEXT_ARG 1 +#define __GNUCLIKE_MATH_BUILTIN_RELOPS +#endif + +#define __GNUCLIKE_BUILTIN_MEMCPY 1 + +/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ +#define __CC_SUPPORTS_INLINE 1 +#define __CC_SUPPORTS___INLINE 1 +#define __CC_SUPPORTS___INLINE__ 1 + +#define __CC_SUPPORTS___FUNC__ 1 +#define __CC_SUPPORTS_WARNING 1 + +#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ + +#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 + +#endif /* __GNUC__ || __INTEL_COMPILER */ + +/* + * Macro to test if we're using a specific version of gcc or later. + */ +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) +#define __GNUC_PREREQ__(ma, mi) \ + (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) +#else +#define __GNUC_PREREQ__(ma, mi) 0 +#endif + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI + * mode -- there must be no spaces between its arguments, and for nested + * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also + * concatenate double-quoted strings produced by the __STRING macro, but + * this only works with ANSI C. + * + * __XSTRING is like __STRING, but it expands any macros in its argument + * first. It is only available with ANSI C. + */ +#if defined(__STDC__) || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT1(x,y) x ## y +#define __CONCAT(x,y) __CONCAT1(x,y) +#define __STRING(x) #x /* stringify without expanding x */ +#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) +#define __inline inline /* convert to C++ keyword */ +#else +#if !(defined(__CC_SUPPORTS___INLINE)) +#define __inline /* delete GCC keyword */ +#endif /* ! __CC_SUPPORTS___INLINE */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x,y) x/**/y +#define __STRING(x) "x" + +#if !defined(__CC_SUPPORTS___INLINE) +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * When using a compiler other than gcc, programs using the ANSI C keywords + * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. + * When using "gcc -traditional", we assume that this is the intent; if + * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. + */ +#ifndef NO_ANSI_KEYWORDS +#define const /* delete ANSI C keywords */ +#define inline +#define signed +#define volatile +#endif /* !NO_ANSI_KEYWORDS */ +#endif /* !__CC_SUPPORTS___INLINE */ +#endif /* !(__STDC__ || __cplusplus) */ + +/* + * Compiler-dependent macros to help declare dead (non-returning) and + * pure (no side effects) functions, and unused variables. They are + * null except for versions of gcc that are known to support the features + * properly (old versions of gcc-2 supported the dead and pure features + * in a different (wrong) way). If we do not provide an implementation + * for a given compiler, let the compile fail if it is told to use + * a feature that we cannot live without. + */ +#ifdef lint +#define __dead2 +#define __pure2 +#define __unused +#define __packed +#define __aligned(x) +#define __alloc_align(x) +#define __alloc_size(x) +#define __section(x) +#define __weak_symbol +#else +#define __weak_symbol __attribute__((__weak__)) +#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) +#define __dead2 +#define __pure2 +#define __unused +#endif +#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER) +#define __dead2 __attribute__((__noreturn__)) +#define __pure2 __attribute__((__const__)) +#define __unused +/* XXX Find out what to do for __packed, __aligned and __section */ +#endif +#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER) +#define __dead2 __attribute__((__noreturn__)) +#define __pure2 __attribute__((__const__)) +#define __unused __attribute__((__unused__)) +#define __used __attribute__((__used__)) +#define __packed __attribute__((__packed__)) +#define __aligned(x) __attribute__((__aligned__(x))) +#define __section(x) __attribute__((__section__(x))) +#endif +#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__) +#define __alloc_size(x) __attribute__((__alloc_size__(x))) +#else +#define __alloc_size(x) +#endif +#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__) +#define __alloc_align(x) __attribute__((__alloc_align__(x))) +#else +#define __alloc_align(x) +#endif +#endif /* lint */ + +#if !__GNUC_PREREQ__(2, 95) +#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) +#endif + +/* + * Keywords added in C11. + */ + +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint) + +#if !__has_extension(c_alignas) +#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ + __has_extension(cxx_alignas) +#define _Alignas(x) alignas(x) +#else +/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */ +#define _Alignas(x) __aligned(x) +#endif +#endif + +#if defined(__cplusplus) && __cplusplus >= 201103L +#define _Alignof(x) alignof(x) +#else +#define _Alignof(x) __alignof(x) +#endif + +#if !defined(__cplusplus) && !__has_extension(c_atomic) && \ + !__has_extension(cxx_atomic) +/* + * No native support for _Atomic(). Place object in structure to prevent + * most forms of direct non-atomic access. + */ +#define _Atomic(T) struct { T volatile __val; } +#endif + +#if defined(__cplusplus) && __cplusplus >= 201103L +#define _Noreturn [[noreturn]] +#else +#define _Noreturn __dead2 +#endif + +#if !__has_extension(c_static_assert) +#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ + __has_extension(cxx_static_assert) +#define _Static_assert(x, y) static_assert(x, y) +#elif __GNUC_PREREQ__(4,6) +/* Nothing, gcc 4.6 and higher has _Static_assert built-in */ +#elif defined(__COUNTER__) +#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) +#define __Static_assert(x, y) ___Static_assert(x, y) +#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \ + __unused +#else +#define _Static_assert(x, y) struct __hack +#endif +#endif + +#if !__has_extension(c_thread_local) +/* + * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode + * without actually supporting the thread_local keyword. Don't check for + * the presence of C++11 when defining _Thread_local. + */ +#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ + __has_extension(cxx_thread_local) +#define _Thread_local thread_local +#else +#define _Thread_local __thread +#endif +#endif + +#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */ + +/* + * Emulation of C11 _Generic(). Unlike the previously defined C11 + * keywords, it is not possible to implement this using exactly the same + * syntax. Therefore implement something similar under the name + * __generic(). Unlike _Generic(), this macro can only distinguish + * between a single type, so it requires nested invocations to + * distinguish multiple cases. + */ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + __has_extension(c_generic_selections) +#define __generic(expr, t, yes, no) \ + _Generic(expr, t: yes, default: no) +#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) +#define __generic(expr, t, yes, no) \ + __builtin_choose_expr( \ + __builtin_types_compatible_p(__typeof(expr), t), yes, no) +#endif + +/* + * C99 Static array indices in function parameter declarations. Syntax such as: + * void bar(int myArray[static 10]); + * is allowed in C99 but not in C++. Define __min_size appropriately so + * headers using it can be compiled in either language. Use like this: + * void bar(int myArray[__min_size(10)]); + */ +#if !defined(__cplusplus) && \ + (defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \ + (!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901)) +#define __min_size(x) static (x) +#else +#define __min_size(x) (x) +#endif + +#if __GNUC_PREREQ__(2, 96) +#define __malloc_like __attribute__((__malloc__)) +#define __pure __attribute__((__pure__)) +#else +#define __malloc_like +#define __pure +#endif + +#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) +#define __always_inline __attribute__((__always_inline__)) +#else +#define __always_inline +#endif + +#if __GNUC_PREREQ__(3, 1) +#define __noinline __attribute__ ((__noinline__)) +#else +#define __noinline +#endif + +#if __GNUC_PREREQ__(3, 3) +#define __nonnull(x) __attribute__((__nonnull__(x))) +#define __nonnull_all __attribute__((__nonnull__)) +#else +#define __nonnull(x) +#define __nonnull_all +#endif + +#if __GNUC_PREREQ__(3, 4) +#define __fastcall __attribute__((__fastcall__)) +#define __result_use_check __attribute__((__warn_unused_result__)) +#else +#define __fastcall +#define __result_use_check +#endif + +#if __GNUC_PREREQ__(4, 1) +#define __returns_twice __attribute__((__returns_twice__)) +#else +#define __returns_twice +#endif + +#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable) +#define __unreachable() __builtin_unreachable() +#else +#define __unreachable() ((void)0) +#endif + +/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ +#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) +#define __func__ NULL +#endif + +#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 +#define __LONG_LONG_SUPPORTED +#endif + +/* C++11 exposes a load of C99 stuff */ +#if defined(__cplusplus) && __cplusplus >= 201103L +#define __LONG_LONG_SUPPORTED +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS +#endif +#endif + +/* + * GCC 2.95 provides `__restrict' as an extension to C90 to support the + * C99-specific `restrict' type qualifier. We happen to use `__restrict' as + * a way to define the `restrict' type qualifier without disturbing older + * software that is unaware of C99 keywords. + */ +#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint) +#define __restrict +#else +#define __restrict restrict +#endif +#endif + +/* + * GNU C version 2.96 adds explicit branch prediction so that + * the CPU back-end can hint the processor and also so that + * code blocks can be reordered such that the predicted path + * sees a more linear flow, thus improving cache behavior, etc. + * + * The following two macros provide us with a way to utilize this + * compiler feature. Use __predict_true() if you expect the expression + * to evaluate to true, and __predict_false() if you expect the + * expression to evaluate to false. + * + * A few notes about usage: + * + * * Generally, __predict_false() error condition checks (unless + * you have some _strong_ reason to do otherwise, in which case + * document it), and/or __predict_true() `no-error' condition + * checks, assuming you want to optimize for the no-error case. + * + * * Other than that, if you don't know the likelihood of a test + * succeeding from empirical or other `hard' evidence, don't + * make predictions. + * + * * These are meant to be used in places that are run `a lot'. + * It is wasteful to make predictions in code that is run + * seldomly (e.g. at subsystem initialization time) as the + * basic block reordering that this affects can often generate + * larger code. + */ +#if __GNUC_PREREQ__(2, 96) +#define __predict_true(exp) __builtin_expect((exp), 1) +#define __predict_false(exp) __builtin_expect((exp), 0) +#else +#define __predict_true(exp) (exp) +#define __predict_false(exp) (exp) +#endif + +#if __GNUC_PREREQ__(4, 0) +#define __null_sentinel __attribute__((__sentinel__)) +#define __exported __attribute__((__visibility__("default"))) +#define __hidden __attribute__((__visibility__("hidden"))) +#else +#define __null_sentinel +#define __exported +#define __hidden +#endif + +/* + * We define this here since , , and + * require it. + */ +#if __GNUC_PREREQ__(4, 1) +#define __offsetof(type, field) __builtin_offsetof(type, field) +#else +#ifndef __cplusplus +#define __offsetof(type, field) \ + ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) +#else +#define __offsetof(type, field) \ + (__offsetof__ (reinterpret_cast <__size_t> \ + (&reinterpret_cast \ + (static_cast (0)->field)))) +#endif +#endif +#define __rangeof(type, start, end) \ + (__offsetof(type, end) - __offsetof(type, start)) + +/* + * Given the pointer x to the member m of the struct s, return + * a pointer to the containing structure. When using GCC, we first + * assign pointer x to a local variable, to check that its type is + * compatible with member m. + */ +#if __GNUC_PREREQ__(3, 1) +#define __containerof(x, s, m) ({ \ + const volatile __typeof(((s *)0)->m) *__x = (x); \ + __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ +}) +#else +#define __containerof(x, s, m) \ + __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) +#endif + +/* + * Compiler-dependent macros to declare that functions take printf-like + * or scanf-like arguments. They are null except for versions of gcc + * that are known to support the features properly (old versions of gcc-2 + * didn't permit keeping the keywords out of the application namespace). + */ +#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) +#define __printflike(fmtarg, firstvararg) +#define __scanflike(fmtarg, firstvararg) +#define __format_arg(fmtarg) +#define __strfmonlike(fmtarg, firstvararg) +#define __strftimelike(fmtarg, firstvararg) +#else +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) +#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) +#define __strfmonlike(fmtarg, firstvararg) \ + __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) +#define __strftimelike(fmtarg, firstvararg) \ + __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) +#endif + +/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ +#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ + defined(__GNUC__) && !defined(__INTEL_COMPILER) +#define __printf0like(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) +#else +#define __printf0like(fmtarg, firstvararg) +#endif + +#if defined(__GNUC__) || defined(__INTEL_COMPILER) +#ifndef __INTEL_COMPILER +#define __strong_reference(sym,aliassym) \ + extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) +#endif +#ifdef __STDC__ +#define __weak_reference(sym,alias) \ + __asm__(".weak " #alias); \ + __asm__(".equ " #alias ", " #sym) +#define __warn_references(sym,msg) \ + __asm__(".section .gnu.warning." #sym); \ + __asm__(".asciz \"" msg "\""); \ + __asm__(".previous") +#define __sym_compat(sym,impl,verid) \ + __asm__(".symver " #impl ", " #sym "@" #verid) +#define __sym_default(sym,impl,verid) \ + __asm__(".symver " #impl ", " #sym "@@" #verid) +#else +#define __weak_reference(sym,alias) \ + __asm__(".weak alias"); \ + __asm__(".equ alias, sym") +#define __warn_references(sym,msg) \ + __asm__(".section .gnu.warning.sym"); \ + __asm__(".asciz \"msg\""); \ + __asm__(".previous") +#define __sym_compat(sym,impl,verid) \ + __asm__(".symver impl, sym@verid") +#define __sym_default(impl,sym,verid) \ + __asm__(".symver impl, sym@@verid") +#endif /* __STDC__ */ +#endif /* __GNUC__ || __INTEL_COMPILER */ + +#define __GLOBL1(sym) __asm__(".globl " #sym) +#define __GLOBL(sym) __GLOBL1(sym) + +#if defined(__GNUC__) || defined(__INTEL_COMPILER) +#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"") +#else +/* + * The following definition might not work well if used in header files, + * but it should be better than nothing. If you want a "do nothing" + * version, then it should generate some harmless declaration, such as: + * #define __IDSTRING(name,string) struct __hack + */ +#define __IDSTRING(name,string) static const char name[] __unused = string +#endif + +/* + * Embed the rcs id of a source file in the resulting library. Note that in + * more recent ELF binutils, we use .ident allowing the ID to be stripped. + * Usage: + * __FBSDID("$FreeBSD: releng/11.1/sys/sys/cdefs.h 317342 2017-04-23 20:32:46Z kib $"); + */ +#ifndef __FBSDID +#if !defined(lint) && !defined(STRIP_FBSDID) +#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) +#else +#define __FBSDID(s) struct __hack +#endif +#endif + +#ifndef __RCSID +#ifndef NO__RCSID +#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) +#else +#define __RCSID(s) struct __hack +#endif +#endif + +#ifndef __RCSID_SOURCE +#ifndef NO__RCSID_SOURCE +#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s) +#else +#define __RCSID_SOURCE(s) struct __hack +#endif +#endif + +#ifndef __SCCSID +#ifndef NO__SCCSID +#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s) +#else +#define __SCCSID(s) struct __hack +#endif +#endif + +#ifndef __COPYRIGHT +#ifndef NO__COPYRIGHT +#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s) +#else +#define __COPYRIGHT(s) struct __hack +#endif +#endif + +#ifndef __DECONST +#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) +#endif + +#ifndef __DEVOLATILE +#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) +#endif + +#ifndef __DEQUALIFY +#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) +#endif + +/*- + * The following definitions are an extension of the behavior originally + * implemented in , but with a different level of granularity. + * POSIX.1 requires that the macros we test be defined before any standard + * header file is included. + * + * Here's a quick run-down of the versions: + * defined(_POSIX_SOURCE) 1003.1-1988 + * _POSIX_C_SOURCE == 1 1003.1-1990 + * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option + * _POSIX_C_SOURCE == 199309 1003.1b-1993 + * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + * _POSIX_C_SOURCE == 200112 1003.1-2001 + * _POSIX_C_SOURCE == 200809 1003.1-2008 + * + * In addition, the X/Open Portability Guide, which is now the Single UNIX + * Specification, defines a feature-test macro which indicates the version of + * that specification, and which subsumes _POSIX_C_SOURCE. + * + * Our macros begin with two underscores to avoid namespace screwage. + */ + +/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 +#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ +#define _POSIX_C_SOURCE 199009 +#endif + +/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199209 +#endif + +/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ +#ifdef _XOPEN_SOURCE +#if _XOPEN_SOURCE - 0 >= 700 +#define __XSI_VISIBLE 700 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809 +#elif _XOPEN_SOURCE - 0 >= 600 +#define __XSI_VISIBLE 600 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112 +#elif _XOPEN_SOURCE - 0 >= 500 +#define __XSI_VISIBLE 500 +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199506 +#endif +#endif + +/* + * Deal with all versions of POSIX. The ordering relative to the tests above is + * important. + */ +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 198808 +#endif +#ifdef _POSIX_C_SOURCE +#if _POSIX_C_SOURCE >= 200809 +#define __POSIX_VISIBLE 200809 +#define __ISO_C_VISIBLE 1999 +#elif _POSIX_C_SOURCE >= 200112 +#define __POSIX_VISIBLE 200112 +#define __ISO_C_VISIBLE 1999 +#elif _POSIX_C_SOURCE >= 199506 +#define __POSIX_VISIBLE 199506 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199309 +#define __POSIX_VISIBLE 199309 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199209 +#define __POSIX_VISIBLE 199209 +#define __ISO_C_VISIBLE 1990 +#elif _POSIX_C_SOURCE >= 199009 +#define __POSIX_VISIBLE 199009 +#define __ISO_C_VISIBLE 1990 +#else +#define __POSIX_VISIBLE 198808 +#define __ISO_C_VISIBLE 0 +#endif /* _POSIX_C_SOURCE */ +#else +/*- + * Deal with _ANSI_SOURCE: + * If it is defined, and no other compilation environment is explicitly + * requested, then define our internal feature-test macros to zero. This + * makes no difference to the preprocessor (undefined symbols in preprocessing + * expressions are defined to have value zero), but makes it more convenient for + * a test program to print out the values. + * + * If a program mistakenly defines _ANSI_SOURCE and some other macro such as + * _POSIX_C_SOURCE, we will assume that it wants the broader compilation + * environment (and in fact we will never get here). + */ +#if defined(_ANSI_SOURCE) /* Hide almost everything. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 1990 +#define __EXT1_VISIBLE 0 +#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 1999 +#define __EXT1_VISIBLE 0 +#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ +#define __POSIX_VISIBLE 0 +#define __XSI_VISIBLE 0 +#define __BSD_VISIBLE 0 +#define __ISO_C_VISIBLE 2011 +#define __EXT1_VISIBLE 0 +#else /* Default environment: show everything. */ +#define __POSIX_VISIBLE 200809 +#define __XSI_VISIBLE 700 +#define __BSD_VISIBLE 1 +#define __ISO_C_VISIBLE 2011 +#define __EXT1_VISIBLE 1 +#endif +#endif + +/* User override __EXT1_VISIBLE */ +#if defined(__STDC_WANT_LIB_EXT1__) +#undef __EXT1_VISIBLE +#if __STDC_WANT_LIB_EXT1__ +#define __EXT1_VISIBLE 1 +#else +#define __EXT1_VISIBLE 0 +#endif +#endif /* __STDC_WANT_LIB_EXT1__ */ + +#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__) +#define __NO_TLS 1 +#endif + +/* + * Old versions of GCC use non-standard ARM arch symbols; acle-compat.h + * translates them to __ARM_ARCH and the modern feature symbols defined by ARM. + */ +#if defined(__arm__) && !defined(__ARM_ARCH) +#include +#endif + +/* + * Nullability qualifiers: currently only supported by Clang. + */ +#if !(defined(__clang__) && __has_feature(nullability)) +#define _Nonnull +#define _Nullable +#define _Null_unspecified +#define __NULLABILITY_PRAGMA_PUSH +#define __NULLABILITY_PRAGMA_POP +#else +#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"") +#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop") +#endif + +/* + * Type Safety Checking + * + * Clang provides additional attributes to enable checking type safety + * properties that cannot be enforced by the C type system. + */ + +#if __has_attribute(__argument_with_type_tag__) && \ + __has_attribute(__type_tag_for_datatype__) && !defined(lint) +#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \ + __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx))) +#define __datatype_type_tag(kind, type) \ + __attribute__((__type_tag_for_datatype__(kind, type))) +#else +#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) +#define __datatype_type_tag(kind, type) +#endif + +/* + * Lock annotations. + * + * Clang provides support for doing basic thread-safety tests at + * compile-time, by marking which locks will/should be held when + * entering/leaving a functions. + * + * Furthermore, it is also possible to annotate variables and structure + * members to enforce that they are only accessed when certain locks are + * held. + */ + +#if __has_extension(c_thread_safety_attributes) +#define __lock_annotate(x) __attribute__((x)) +#else +#define __lock_annotate(x) +#endif + +/* Structure implements a lock. */ +#define __lockable __lock_annotate(lockable) + +/* Function acquires an exclusive or shared lock. */ +#define __locks_exclusive(...) \ + __lock_annotate(exclusive_lock_function(__VA_ARGS__)) +#define __locks_shared(...) \ + __lock_annotate(shared_lock_function(__VA_ARGS__)) + +/* Function attempts to acquire an exclusive or shared lock. */ +#define __trylocks_exclusive(...) \ + __lock_annotate(exclusive_trylock_function(__VA_ARGS__)) +#define __trylocks_shared(...) \ + __lock_annotate(shared_trylock_function(__VA_ARGS__)) + +/* Function releases a lock. */ +#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__)) + +/* Function asserts that an exclusive or shared lock is held. */ +#define __asserts_exclusive(...) \ + __lock_annotate(assert_exclusive_lock(__VA_ARGS__)) +#define __asserts_shared(...) \ + __lock_annotate(assert_shared_lock(__VA_ARGS__)) + +/* Function requires that an exclusive or shared lock is or is not held. */ +#define __requires_exclusive(...) \ + __lock_annotate(exclusive_locks_required(__VA_ARGS__)) +#define __requires_shared(...) \ + __lock_annotate(shared_locks_required(__VA_ARGS__)) +#define __requires_unlocked(...) \ + __lock_annotate(locks_excluded(__VA_ARGS__)) + +/* Function should not be analyzed. */ +#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis) + +/* Guard variables and structure members by lock. */ +#define __guarded_by(x) __lock_annotate(guarded_by(x)) +#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x)) + +#endif /* !_SYS_CDEFS_H_ */ diff --git a/sys/include/sys/device.h b/sys/include/sys/device.h new file mode 100644 index 0000000..3dc5d70 --- /dev/null +++ b/sys/include/sys/device.h @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_DEVICE_H +#define _SYS_DEVICE_H + +#include + +struct device_node { + struct device_node *prev; + struct device_node *next; + struct device_interface *devInfo; + struct device_resource *devRec; + char type; + int minor; +}; + +struct device_resource { + uInt8 irq; +}; + +struct device_interface { + uInt8 initialized; + uInt32 size; + int major; + void *info; + int (*read)(void *, void *, uInt32, uInt32); + int (*write)(void *, void *, uInt32, uInt32); + void (*reset)(void *); + int (*init)(void *); + void (*ioctl)(void *); + void (*stop)(void *); + void (*start)(void *); + void (*standby)(void *); +}; + +int device_add(int, char, struct device_interface *); +struct device_node *device_find(int major, int minor); +int device_remove(struct device_node *); + +#endif /* END _SYS_DEVICE_H */ diff --git a/sys/include/sys/device.old.h b/sys/include/sys/device.old.h new file mode 100644 index 0000000..27641cd --- /dev/null +++ b/sys/include/sys/device.old.h @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DEVICE_H +#define _DEVICE_H + +#include + +struct device { + struct net *net; + uInt16 ioAddr; + uInt32 irq; + struct ei_device *priv; + uInt32 mtu; + }; + +struct net { + char mac[6]; + char broadcast[6]; + }; + +struct ei_device { + int txStartPage; + int rxStartPage; + int stopPage; + int currentPage; + uInt16 word16; + uInt32 pingPong; + int tx1; + int tx2; + }; + +#endif + +/*** + END + ***/ + diff --git a/sys/include/sys/driver.h b/sys/include/sys/driver.h new file mode 100644 index 0000000..b0b16ff --- /dev/null +++ b/sys/include/sys/driver.h @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_DRIVER_H +#define _SYS_DRIVER_H + +#include + +typedef struct devMethodType devMethod; + +struct devMethodType { +}; + +struct driverType { + const char *devName; + devMethod *methods; +} + +#endif /* END _SYS_DRIVER_H */ diff --git a/sys/include/sys/elf.h b/sys/include/sys/elf.h new file mode 100644 index 0000000..4392989 --- /dev/null +++ b/sys/include/sys/elf.h @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_ELF_H_ +#define _SYS_ELF_H_ 1 + +#define __i386__ 1 + +#include +#include +#include +#include + +typedef struct elf_file { + int preloaded; /* Was file pre-loaded */ + caddr_t address; /* Relocation address */ + Elf_Dyn *dynamic; /* Symbol table etc. */ + Elf_Hashelt nbuckets; /* DT_HASH info */ + Elf_Hashelt nchains; + const Elf_Hashelt *buckets; + const Elf_Hashelt *chains; + caddr_t hash; + caddr_t strtab; /* DT_STRTAB */ + int strsz; /* DT_STRSZ */ + const Elf_Sym *symtab; /* DT_SYMTAB */ + Elf_Addr *got; /* DT_PLTGOT */ + const Elf_Rel *pltrel; /* DT_JMPREL */ + int pltrelsize; /* DT_PLTRELSZ */ + const Elf_Rela *pltrela; /* DT_JMPREL */ + int pltrelasize; /* DT_PLTRELSZ */ + const Elf_Rel *rel; /* DT_REL */ + int relsize; /* DT_RELSZ */ + const Elf_Rela *rela; /* DT_RELA */ + int relasize; /* DT_RELASZ */ + caddr_t modptr; + const Elf_Sym *ddbsymtab; /* The symbol table we are using */ + long ddbsymcnt; /* Number of symbols */ + caddr_t ddbstrtab; /* String table */ + long ddbstrcnt; /* number of bytes in string table */ + caddr_t symbase; /* malloc'ed symbold base */ + caddr_t strbase; /* malloc'ed string base */ + caddr_t ctftab; /* CTF table */ + long ctfcnt; /* number of bytes in CTF table */ + caddr_t ctfoff; /* CTF offset table */ + caddr_t typoff; /* Type offset table */ + long typlen; /* Number of type entries. */ + Elf_Addr pcpu_start; /* Pre-relocation pcpu set start. */ + Elf_Addr pcpu_stop; /* Pre-relocation pcpu set stop. */ + Elf_Addr pcpu_base; /* Relocated pcpu set address. */ +} *elf_file_t; + + +#include + +#define elfExecutable 0x002 +#define elfLibrary 0x003 + +char *elfGetShType( int ); +char *elfGetPhType( int ); +char *elfGetRelType( int ); + +int elf_load_file( kTask_t *p, const char *file, uint32_t *addr, uint32_t *entry ); + +#endif /* END _SYS_ELF_H */ diff --git a/sys/include/sys/elf32.h b/sys/include/sys/elf32.h new file mode 100644 index 0000000..d19803e --- /dev/null +++ b/sys/include/sys/elf32.h @@ -0,0 +1,259 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_ELF32_H_ +#define _SYS_ELF32_H_ 1 + +#include + +/* + * ELF definitions common to all 32-bit architectures. + */ + +typedef uint32_t Elf32_Addr; +typedef uint16_t Elf32_Half; +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf32_Word; +typedef uint64_t Elf32_Lword; + +typedef Elf32_Word Elf32_Hashelt; + +/* Non-standard class-dependent datatype used for abstraction. */ +typedef Elf32_Word Elf32_Size; +typedef Elf32_Sword Elf32_Ssize; + +/* + * ELF header. + */ + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* File identification. */ + Elf32_Half e_type; /* File type. */ + Elf32_Half e_machine; /* Machine architecture. */ + Elf32_Word e_version; /* ELF format version. */ + Elf32_Addr e_entry; /* Entry point. */ + Elf32_Off e_phoff; /* Program header file offset. */ + Elf32_Off e_shoff; /* Section header file offset. */ + Elf32_Word e_flags; /* Architecture-specific flags. */ + Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ + Elf32_Half e_phentsize; /* Size of program header entry. */ + Elf32_Half e_phnum; /* Number of program header entries. */ + Elf32_Half e_shentsize; /* Size of section header entry. */ + Elf32_Half e_shnum; /* Number of section header entries. */ + Elf32_Half e_shstrndx; /* Section name strings section. */ +} Elf32_Ehdr; + +/* + * Shared object information, found in SHT_MIPS_LIBLIST. + */ + +typedef struct { + Elf32_Word l_name; /* The name of a shared object. */ + Elf32_Word l_time_stamp; /* 32-bit timestamp. */ + Elf32_Word l_checksum; /* Checksum of visible symbols, sizes. */ + Elf32_Word l_version; /* Interface version string index. */ + Elf32_Word l_flags; /* Flags (LL_*). */ +} Elf32_Lib; + +/* + * Section header. + */ + +typedef struct { + Elf32_Word sh_name; /* Section name (index into the + section header string table). */ + Elf32_Word sh_type; /* Section type. */ + Elf32_Word sh_flags; /* Section flags. */ + Elf32_Addr sh_addr; /* Address in memory image. */ + Elf32_Off sh_offset; /* Offset in file. */ + Elf32_Word sh_size; /* Size in bytes. */ + Elf32_Word sh_link; /* Index of a related section. */ + Elf32_Word sh_info; /* Depends on section type. */ + Elf32_Word sh_addralign; /* Alignment in bytes. */ + Elf32_Word sh_entsize; /* Size of each entry in section. */ +} Elf32_Shdr; + +/* + * Program header. + */ + +typedef struct { + Elf32_Word p_type; /* Entry type. */ + Elf32_Off p_offset; /* File offset of contents. */ + Elf32_Addr p_vaddr; /* Virtual address in memory image. */ + Elf32_Addr p_paddr; /* Physical address (not used). */ + Elf32_Word p_filesz; /* Size of contents in file. */ + Elf32_Word p_memsz; /* Size of contents in memory. */ + Elf32_Word p_flags; /* Access permission flags. */ + Elf32_Word p_align; /* Alignment in memory and file. */ +} Elf32_Phdr; + +/* + * Dynamic structure. The ".dynamic" section contains an array of them. + */ + +typedef struct { + Elf32_Sword d_tag; /* Entry type. */ + union { + Elf32_Word d_val; /* Integer value. */ + Elf32_Addr d_ptr; /* Address value. */ + } d_un; +} Elf32_Dyn; + +/* + * Relocation entries. + */ + +/* Relocations that don't need an addend field. */ +typedef struct { + Elf32_Addr r_offset; /* Location to be relocated. */ + Elf32_Word r_info; /* Relocation type and symbol index. */ +} Elf32_Rel; + +/* Relocations that need an addend field. */ +typedef struct { + Elf32_Addr r_offset; /* Location to be relocated. */ + Elf32_Word r_info; /* Relocation type and symbol index. */ + Elf32_Sword r_addend; /* Addend. */ +} Elf32_Rela; + +/* Macros for accessing the fields of r_info. */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((unsigned char)(info)) + +/* Macro for constructing r_info from field values. */ +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +/* + * Note entry header + */ +typedef Elf_Note Elf32_Nhdr; + +/* + * Move entry + */ +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +/* + * The macros compose and decompose values for Move.r_info + * + * sym = ELF32_M_SYM(M.m_info) + * size = ELF32_M_SIZE(M.m_info) + * M.m_info = ELF32_M_INFO(sym, size) + */ +#define ELF32_M_SYM(info) ((info)>>8) +#define ELF32_M_SIZE(info) ((unsigned char)(info)) +#define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) + +/* + * Hardware/Software capabilities entry + */ +typedef struct { + Elf32_Word c_tag; /* how to interpret value */ + union { + Elf32_Word c_val; + Elf32_Addr c_ptr; + } c_un; +} Elf32_Cap; + +/* + * Symbol table entries. + */ + +typedef struct { + Elf32_Word st_name; /* String table index of name. */ + Elf32_Addr st_value; /* Symbol value. */ + Elf32_Word st_size; /* Size of associated object. */ + unsigned char st_info; /* Type and binding information. */ + unsigned char st_other; /* Reserved (not used). */ + Elf32_Half st_shndx; /* Section index of symbol. */ +} Elf32_Sym; + +/* Macros for accessing the fields of st_info. */ +#define ELF32_ST_BIND(info) ((info) >> 4) +#define ELF32_ST_TYPE(info) ((info) & 0xf) + +/* Macro for constructing st_info from field values. */ +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Macro for accessing the fields of st_other. */ +#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3) + +/* Structures used by Sun & GNU symbol versioning. */ +typedef struct { + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} Elf32_Verdef; + +typedef struct { + Elf32_Word vda_name; + Elf32_Word vda_next; +} Elf32_Verdaux; + +typedef struct { + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} Elf32_Verneed; + +typedef struct { + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} Elf32_Vernaux; + +typedef Elf32_Half Elf32_Versym; + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + +typedef struct { + Elf32_Word ch_type; + Elf32_Word ch_size; + Elf32_Word ch_addralign; +} Elf32_Chdr; + +#endif /* END _SYS_ELF32_H */ diff --git a/sys/include/sys/elf64.h b/sys/include/sys/elf64.h new file mode 100644 index 0000000..fe825dc --- /dev/null +++ b/sys/include/sys/elf64.h @@ -0,0 +1,267 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_ELF64_H_ +#define _SYS_ELF64_H_ 1 + +#include + +/* + * ELF definitions common to all 64-bit architectures. + */ + +typedef uint64_t Elf64_Addr; +typedef uint16_t Elf64_Half; +typedef uint64_t Elf64_Off; +typedef int32_t Elf64_Sword; +typedef int64_t Elf64_Sxword; +typedef uint32_t Elf64_Word; +typedef uint64_t Elf64_Lword; +typedef uint64_t Elf64_Xword; + +/* + * Types of dynamic symbol hash table bucket and chain elements. + * + * This is inconsistent among 64 bit architectures, so a machine dependent + * typedef is required. + */ + +typedef Elf64_Word Elf64_Hashelt; + +/* Non-standard class-dependent datatype used for abstraction. */ +typedef Elf64_Xword Elf64_Size; +typedef Elf64_Sxword Elf64_Ssize; + +/* + * ELF header. + */ + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* File identification. */ + Elf64_Half e_type; /* File type. */ + Elf64_Half e_machine; /* Machine architecture. */ + Elf64_Word e_version; /* ELF format version. */ + Elf64_Addr e_entry; /* Entry point. */ + Elf64_Off e_phoff; /* Program header file offset. */ + Elf64_Off e_shoff; /* Section header file offset. */ + Elf64_Word e_flags; /* Architecture-specific flags. */ + Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ + Elf64_Half e_phentsize; /* Size of program header entry. */ + Elf64_Half e_phnum; /* Number of program header entries. */ + Elf64_Half e_shentsize; /* Size of section header entry. */ + Elf64_Half e_shnum; /* Number of section header entries. */ + Elf64_Half e_shstrndx; /* Section name strings section. */ +} Elf64_Ehdr; + +/* + * Shared object information, found in SHT_MIPS_LIBLIST. + */ + +typedef struct { + Elf64_Word l_name; /* The name of a shared object. */ + Elf64_Word l_time_stamp; /* 64-bit timestamp. */ + Elf64_Word l_checksum; /* Checksum of visible symbols, sizes. */ + Elf64_Word l_version; /* Interface version string index. */ + Elf64_Word l_flags; /* Flags (LL_*). */ +} Elf64_Lib; + +/* + * Section header. + */ + +typedef struct { + Elf64_Word sh_name; /* Section name (index into the + section header string table). */ + Elf64_Word sh_type; /* Section type. */ + Elf64_Xword sh_flags; /* Section flags. */ + Elf64_Addr sh_addr; /* Address in memory image. */ + Elf64_Off sh_offset; /* Offset in file. */ + Elf64_Xword sh_size; /* Size in bytes. */ + Elf64_Word sh_link; /* Index of a related section. */ + Elf64_Word sh_info; /* Depends on section type. */ + Elf64_Xword sh_addralign; /* Alignment in bytes. */ + Elf64_Xword sh_entsize; /* Size of each entry in section. */ +} Elf64_Shdr; + +/* + * Program header. + */ + +typedef struct { + Elf64_Word p_type; /* Entry type. */ + Elf64_Word p_flags; /* Access permission flags. */ + Elf64_Off p_offset; /* File offset of contents. */ + Elf64_Addr p_vaddr; /* Virtual address in memory image. */ + Elf64_Addr p_paddr; /* Physical address (not used). */ + Elf64_Xword p_filesz; /* Size of contents in file. */ + Elf64_Xword p_memsz; /* Size of contents in memory. */ + Elf64_Xword p_align; /* Alignment in memory and file. */ +} Elf64_Phdr; + +/* + * Dynamic structure. The ".dynamic" section contains an array of them. + */ + +typedef struct { + Elf64_Sxword d_tag; /* Entry type. */ + union { + Elf64_Xword d_val; /* Integer value. */ + Elf64_Addr d_ptr; /* Address value. */ + } d_un; +} Elf64_Dyn; + +/* + * Relocation entries. + */ + +/* Relocations that don't need an addend field. */ +typedef struct { + Elf64_Addr r_offset; /* Location to be relocated. */ + Elf64_Xword r_info; /* Relocation type and symbol index. */ +} Elf64_Rel; + +/* Relocations that need an addend field. */ +typedef struct { + Elf64_Addr r_offset; /* Location to be relocated. */ + Elf64_Xword r_info; /* Relocation type and symbol index. */ + Elf64_Sxword r_addend; /* Addend. */ +} Elf64_Rela; + +/* Macros for accessing the fields of r_info. */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffffL) + +/* Macro for constructing r_info from field values. */ +#define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL)) + +#define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40) +#define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56) +#define ELF64_R_TYPE_INFO(data, type) \ + (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type)) + +/* + * Note entry header + */ +typedef Elf_Note Elf64_Nhdr; + +/* + * Move entry + */ +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Half m_repeat; /* repeat count */ + Elf64_Half m_stride; /* stride info */ +} Elf64_Move; + +#define ELF64_M_SYM(info) ((info)>>8) +#define ELF64_M_SIZE(info) ((unsigned char)(info)) +#define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size)) + +/* + * Hardware/Software capabilities entry + */ +typedef struct { + Elf64_Xword c_tag; /* how to interpret value */ + union { + Elf64_Xword c_val; + Elf64_Addr c_ptr; + } c_un; +} Elf64_Cap; + +/* + * Symbol table entries. + */ + +typedef struct { + Elf64_Word st_name; /* String table index of name. */ + unsigned char st_info; /* Type and binding information. */ + unsigned char st_other; /* Reserved (not used). */ + Elf64_Half st_shndx; /* Section index of symbol. */ + Elf64_Addr st_value; /* Symbol value. */ + Elf64_Xword st_size; /* Size of associated object. */ +} Elf64_Sym; + +/* Macros for accessing the fields of st_info. */ +#define ELF64_ST_BIND(info) ((info) >> 4) +#define ELF64_ST_TYPE(info) ((info) & 0xf) + +/* Macro for constructing st_info from field values. */ +#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Macro for accessing the fields of st_other. */ +#define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3) + +/* Structures used by Sun & GNU-style symbol versioning. */ +typedef struct { + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} Elf64_Verdef; + +typedef struct { + Elf64_Word vda_name; + Elf64_Word vda_next; +} Elf64_Verdaux; + +typedef struct { + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} Elf64_Verneed; + +typedef struct { + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} Elf64_Vernaux; + +typedef Elf64_Half Elf64_Versym; + +typedef struct { + Elf64_Half si_boundto; /* direct bindings - symbol bound to */ + Elf64_Half si_flags; /* per symbol flags */ +} Elf64_Syminfo; + +typedef struct { + Elf64_Word ch_type; + Elf64_Word ch_reserved; + Elf64_Xword ch_size; + Elf64_Xword ch_addralign; +} Elf64_Chdr; + +#endif /* !_SYS_ELF64_H_ */ diff --git a/sys/include/sys/elf_common.h b/sys/include/sys/elf_common.h index 7455de4..8f1cc61 100644 --- a/sys/include/sys/elf_common.h +++ b/sys/include/sys/elf_common.h @@ -1,1340 +1,1340 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF_COMMON_H_ -#define _SYS_ELF_COMMON_H_ 1 - -/* - * ELF definitions that are independent of architecture or word size. - */ - -/* - * Note header. The ".note" section contains an array of notes. Each - * begins with this header, aligned to a word boundary. Immediately - * following the note header is n_namesz bytes of name, padded to the - * next word boundary. Then comes n_descsz bytes of descriptor, again - * padded to a word boundary. The values of n_namesz and n_descsz do - * not include the padding. - */ - -typedef struct { - uint32_t n_namesz; /* Length of name. */ - uint32_t n_descsz; /* Length of descriptor. */ - uint32_t n_type; /* Type of this note. */ -} Elf_Note; - -/* - * Option kinds. - */ -#define ODK_NULL 0 /* undefined */ -#define ODK_REGINFO 1 /* register usage info */ -#define ODK_EXCEPTIONS 2 /* exception processing info */ -#define ODK_PAD 3 /* section padding */ -#define ODK_HWPATCH 4 /* hardware patch applied */ -#define ODK_FILL 5 /* fill value used by the linker */ -#define ODK_TAGS 6 /* reserved space for tools */ -#define ODK_HWAND 7 /* hardware AND patch applied */ -#define ODK_HWOR 8 /* hardware OR patch applied */ -#define ODK_GP_GROUP 9 /* GP group for text/data sections */ -#define ODK_IDENT 10 /* ID information */ -#define ODK_PAGESIZE 11 /* page size information */ - -/* - * ODK_EXCEPTIONS info field masks. - */ -#define OEX_FPU_MIN 0x0000001f /* min FPU exception required */ -#define OEX_FPU_MAX 0x00001f00 /* max FPU exception allowed */ -#define OEX_PAGE0 0x00010000 /* page zero must be mapped */ -#define OEX_SMM 0x00020000 /* run in sequential memory mode */ -#define OEX_PRECISEFP 0x00040000 /* run in precise FP exception mode */ -#define OEX_DISMISS 0x00080000 /* dismiss invalid address traps */ - -/* - * ODK_PAD info field masks. - */ -#define OPAD_PREFIX 0x0001 -#define OPAD_POSTFIX 0x0002 -#define OPAD_SYMBOL 0x0004 - -/* - * ODK_HWPATCH info field masks. - */ -#define OHW_R4KEOP 0x00000001 /* patch for R4000 branch at end-of-page bug */ -#define OHW_R8KPFETCH 0x00000002 /* R8000 prefetch bug may occur */ -#define OHW_R5KEOP 0x00000004 /* patch for R5000 branch at end-of-page bug */ -#define OHW_R5KCVTL 0x00000008 /* R5000 cvt.[ds].l bug: clean == 1 */ -#define OHW_R10KLDL 0x00000010UL /* need patch for R10000 misaligned load */ - -/* - * ODK_HWAND/ODK_HWOR info field and hwp_flags[12] masks. - */ -#define OHWA0_R4KEOP_CHECKED 0x00000001 /* object checked for R4000 end-of-page bug */ -#define OHWA0_R4KEOP_CLEAN 0x00000002 /* object verified clean for R4000 end-of-page bug */ -#define OHWO0_FIXADE 0x00000001 /* object requires call to fixade */ - -/* - * ODK_IDENT/ODK_GP_GROUP info field masks. - */ -#define OGP_GROUP 0x0000ffff /* GP group number */ -#define OGP_SELF 0x00010000 /* GP group is self-contained */ - -/* - * The header for GNU-style hash sections. - */ - -typedef struct { - uint32_t gh_nbuckets; /* Number of hash buckets. */ - uint32_t gh_symndx; /* First visible symbol in .dynsym. */ - uint32_t gh_maskwords; /* #maskwords used in bloom filter. */ - uint32_t gh_shift2; /* Bloom filter shift count. */ -} Elf_GNU_Hash_Header; - -/* Indexes into the e_ident array. Keep synced with - http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ -#define EI_MAG0 0 /* Magic number, byte 0. */ -#define EI_MAG1 1 /* Magic number, byte 1. */ -#define EI_MAG2 2 /* Magic number, byte 2. */ -#define EI_MAG3 3 /* Magic number, byte 3. */ -#define EI_CLASS 4 /* Class of machine. */ -#define EI_DATA 5 /* Data format. */ -#define EI_VERSION 6 /* ELF format version. */ -#define EI_OSABI 7 /* Operating system / ABI identification */ -#define EI_ABIVERSION 8 /* ABI version */ -#define OLD_EI_BRAND 8 /* Start of architecture identification. */ -#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ -#define EI_NIDENT 16 /* Size of e_ident array. */ - -/* Values for the magic number bytes. */ -#define ELFMAG0 0x7f -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" /* magic string */ -#define SELFMAG 4 /* magic string size */ - -/* Values for e_ident[EI_VERSION] and e_version. */ -#define EV_NONE 0 -#define EV_CURRENT 1 - -/* Values for e_ident[EI_CLASS]. */ -#define ELFCLASSNONE 0 /* Unknown class. */ -#define ELFCLASS32 1 /* 32-bit architecture. */ -#define ELFCLASS64 2 /* 64-bit architecture. */ - -/* Values for e_ident[EI_DATA]. */ -#define ELFDATANONE 0 /* Unknown data format. */ -#define ELFDATA2LSB 1 /* 2's complement little-endian. */ -#define ELFDATA2MSB 2 /* 2's complement big-endian. */ - -/* Values for e_ident[EI_OSABI]. */ -#define ELFOSABI_NONE 0 /* UNIX System V ABI */ -#define ELFOSABI_HPUX 1 /* HP-UX operating system */ -#define ELFOSABI_NETBSD 2 /* NetBSD */ -#define ELFOSABI_LINUX 3 /* GNU/Linux */ -#define ELFOSABI_HURD 4 /* GNU/Hurd */ -#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ -#define ELFOSABI_SOLARIS 6 /* Solaris */ -#define ELFOSABI_AIX 7 /* AIX */ -#define ELFOSABI_IRIX 8 /* IRIX */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD */ -#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD */ -#define ELFOSABI_OPENVMS 13 /* Open VMS */ -#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ -#define ELFOSABI_AROS 15 /* Amiga Research OS */ -#define ELFOSABI_FENIXOS 16 /* FenixOS */ -#define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */ -#define ELFOSABI_UBIXOS 18 /* UbixOS */ -#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ -#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ -#define ELFOSABI_GNU ELFOSABI_LINUX - -/* e_ident */ -#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ - (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ - (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ - (ehdr).e_ident[EI_MAG3] == ELFMAG3) - -/* Values for e_type. */ -#define ET_NONE 0 /* Unknown type. */ -#define ET_REL 1 /* Relocatable. */ -#define ET_EXEC 2 /* Executable. */ -#define ET_DYN 3 /* Shared object. */ -#define ET_CORE 4 /* Core file. */ -#define ET_LOOS 0xfe00 /* First operating system specific. */ -#define ET_HIOS 0xfeff /* Last operating system-specific. */ -#define ET_LOPROC 0xff00 /* First processor-specific. */ -#define ET_HIPROC 0xffff /* Last processor-specific. */ - -/* Values for e_machine. */ -#define EM_NONE 0 /* Unknown machine. */ -#define EM_M32 1 /* AT&T WE32100. */ -#define EM_SPARC 2 /* Sun SPARC. */ -#define EM_386 3 /* Intel i386. */ -#define EM_68K 4 /* Motorola 68000. */ -#define EM_88K 5 /* Motorola 88000. */ -#define EM_IAMCU 6 /* Intel MCU. */ -#define EM_860 7 /* Intel i860. */ -#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ -#define EM_S370 9 /* IBM System/370. */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ -#define EM_PARISC 15 /* HP PA-RISC. */ -#define EM_VPP500 17 /* Fujitsu VPP500. */ -#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ -#define EM_960 19 /* Intel 80960. */ -#define EM_PPC 20 /* PowerPC 32-bit. */ -#define EM_PPC64 21 /* PowerPC 64-bit. */ -#define EM_S390 22 /* IBM System/390. */ -#define EM_V800 36 /* NEC V800. */ -#define EM_FR20 37 /* Fujitsu FR20. */ -#define EM_RH32 38 /* TRW RH-32. */ -#define EM_RCE 39 /* Motorola RCE. */ -#define EM_ARM 40 /* ARM. */ -#define EM_SH 42 /* Hitachi SH. */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ -#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ -#define EM_ARC 45 /* Argonaut RISC Core. */ -#define EM_H8_300 46 /* Hitachi H8/300. */ -#define EM_H8_300H 47 /* Hitachi H8/300H. */ -#define EM_H8S 48 /* Hitachi H8S. */ -#define EM_H8_500 49 /* Hitachi H8/500. */ -#define EM_IA_64 50 /* Intel IA-64 Processor. */ -#define EM_MIPS_X 51 /* Stanford MIPS-X. */ -#define EM_COLDFIRE 52 /* Motorola ColdFire. */ -#define EM_68HC12 53 /* Motorola M68HC12. */ -#define EM_MMA 54 /* Fujitsu MMA. */ -#define EM_PCP 55 /* Siemens PCP. */ -#define EM_NCPU 56 /* Sony nCPU. */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ -#define EM_STARCORE 58 /* Motorola Star*Core processor. */ -#define EM_ME16 59 /* Toyota ME16 processor. */ -#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ -#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ -#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ -#define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ -#define EM_PDSP 63 /* Sony DSP Processor. */ -#define EM_FX66 66 /* Siemens FX66 microcontroller. */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 - microcontroller. */ -#define EM_ST7 68 /* STmicroelectronics ST7 8-bit - microcontroller. */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */ -#define EM_SVX 73 /* Silicon Graphics SVx. */ -#define EM_ST19 74 /* STMicroelectronics ST19 8-bit mc. */ -#define EM_VAX 75 /* Digital VAX. */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded - processor. */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded - processor. */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor. */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc. */ -#define EM_HUANY 81 /* Harvard University machine-independent - object files. */ -#define EM_PRISM 82 /* SiTera Prism. */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */ -#define EM_FR30 84 /* Fujitsu FR30. */ -#define EM_D10V 85 /* Mitsubishi D10V. */ -#define EM_D30V 86 /* Mitsubishi D30V. */ -#define EM_V850 87 /* NEC v850. */ -#define EM_M32R 88 /* Mitsubishi M32R. */ -#define EM_MN10300 89 /* Matsushita MN10300. */ -#define EM_MN10200 90 /* Matsushita MN10200. */ -#define EM_PJ 91 /* picoJava. */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor. */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */ -#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */ -#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose - Processor. */ -#define EM_NS32K 97 /* National Semiconductor 32000 series. */ -#define EM_TPC 98 /* Tenor Network TPC processor. */ -#define EM_SNP1K 99 /* Trebia SNP 1000 processor. */ -#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */ -#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family. */ -#define EM_MAX 102 /* MAX Processor. */ -#define EM_CR 103 /* National Semiconductor CompactRISC - microprocessor. */ -#define EM_F2MC16 104 /* Fujitsu F2MC16. */ -#define EM_MSP430 105 /* Texas Instruments embedded microcontroller - msp430. */ -#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor. */ -#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */ -#define EM_SEP 108 /* Sharp embedded microprocessor. */ -#define EM_ARCA 109 /* Arca RISC Microprocessor. */ -#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. - and MPRC of Peking University */ -#define EM_AARCH64 183 /* AArch64 (64-bit ARM) */ -#define EM_RISCV 243 /* RISC-V */ - -/* Non-standard or deprecated. */ -#define EM_486 6 /* Intel i486. */ -#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ -#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ -#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ - -/** - * e_flags - */ -#define EF_ARM_RELEXEC 0x1 -#define EF_ARM_HASENTRY 0x2 -#define EF_ARM_SYMSARESORTED 0x4 -#define EF_ARM_DYNSYMSUSESEGIDX 0x8 -#define EF_ARM_MAPSYMSFIRST 0x10 -#define EF_ARM_LE8 0x00400000 -#define EF_ARM_BE8 0x00800000 -#define EF_ARM_EABIMASK 0xFF000000 -#define EF_ARM_EABI_UNKNOWN 0x00000000 -#define EF_ARM_EABI_VER1 0x01000000 -#define EF_ARM_EABI_VER2 0x02000000 -#define EF_ARM_EABI_VER3 0x03000000 -#define EF_ARM_EABI_VER4 0x04000000 -#define EF_ARM_EABI_VER5 0x05000000 -#define EF_ARM_INTERWORK 0x00000004 -#define EF_ARM_APCS_26 0x00000008 -#define EF_ARM_APCS_FLOAT 0x00000010 -#define EF_ARM_PIC 0x00000020 -#define EF_ARM_ALIGN8 0x00000040 -#define EF_ARM_NEW_ABI 0x00000080 -#define EF_ARM_OLD_ABI 0x00000100 -#define EF_ARM_SOFT_FLOAT 0x00000200 -#define EF_ARM_VFP_FLOAT 0x00000400 -#define EF_ARM_MAVERICK_FLOAT 0x00000800 - -#define EF_MIPS_NOREORDER 0x00000001 -#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ -#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ -#define EF_MIPS_UCODE 0x00000010 -#define EF_MIPS_ABI2 0x00000020 /* N32 */ -#define EF_MIPS_OPTIONS_FIRST 0x00000080 -#define EF_MIPS_ARCH_ASE 0x0F000000 /* Architectural extensions */ -#define EF_MIPS_ARCH_ASE_MDMX 0x08000000 /* MDMX multimedia extension */ -#define EF_MIPS_ARCH_ASE_M16 0x04000000 /* MIPS-16 ISA extensions */ -#define EF_MIPS_ARCH 0xF0000000 /* Architecture field */ - -#define EF_PPC_EMB 0x80000000 -#define EF_PPC_RELOCATABLE 0x00010000 -#define EF_PPC_RELOCATABLE_LIB 0x00008000 - -#define EF_SPARC_EXT_MASK 0x00ffff00 -#define EF_SPARC_32PLUS 0x00000100 -#define EF_SPARC_SUN_US1 0x00000200 -#define EF_SPARC_HAL_R1 0x00000200 -#define EF_SPARC_SUN_US3 0x00000800 - -#define EF_SPARCV9_MM 0x00000003 -#define EF_SPARCV9_TSO 0x00000000 -#define EF_SPARCV9_PSO 0x00000001 -#define EF_SPARCV9_RMO 0x00000002 - -/* Special section indexes. */ -#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ -#define SHN_LORESERVE 0xff00 /* First of reserved range. */ -#define SHN_LOPROC 0xff00 /* First processor-specific. */ -#define SHN_HIPROC 0xff1f /* Last processor-specific. */ -#define SHN_LOOS 0xff20 /* First operating system-specific. */ -#define SHN_FBSD_CACHED SHN_LOOS /* Transient, for sys/kern/link_elf_obj - linker only: Cached global in local - symtab. */ -#define SHN_HIOS 0xff3f /* Last operating system-specific. */ -#define SHN_ABS 0xfff1 /* Absolute values. */ -#define SHN_COMMON 0xfff2 /* Common data. */ -#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ -#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ - -/* sh_type */ -#define SHT_NULL 0 /* inactive */ -#define SHT_PROGBITS 1 /* program defined information */ -#define SHT_SYMTAB 2 /* symbol table section */ -#define SHT_STRTAB 3 /* string table section */ -#define SHT_RELA 4 /* relocation section with addends */ -#define SHT_HASH 5 /* symbol hash table section */ -#define SHT_DYNAMIC 6 /* dynamic section */ -#define SHT_NOTE 7 /* note section */ -#define SHT_NOBITS 8 /* no space section */ -#define SHT_REL 9 /* relocation section - no addends */ -#define SHT_SHLIB 10 /* reserved - purpose unknown */ -#define SHT_DYNSYM 11 /* dynamic symbol table section */ -#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ -#define SHT_FINI_ARRAY 15 /* Termination function pointers. */ -#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ -#define SHT_GROUP 17 /* Section group. */ -#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ -#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ -#define SHT_LOSUNW 0x6ffffff4 -#define SHT_SUNW_dof 0x6ffffff4 -#define SHT_SUNW_cap 0x6ffffff5 -#define SHT_GNU_ATTRIBUTES 0x6ffffff5 -#define SHT_SUNW_SIGNATURE 0x6ffffff6 -#define SHT_GNU_HASH 0x6ffffff6 -#define SHT_GNU_LIBLIST 0x6ffffff7 -#define SHT_SUNW_ANNOTATE 0x6ffffff7 -#define SHT_SUNW_DEBUGSTR 0x6ffffff8 -#define SHT_SUNW_DEBUG 0x6ffffff9 -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_SUNW_verdef 0x6ffffffd -#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */ -#define SHT_SUNW_verneed 0x6ffffffe -#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */ -#define SHT_SUNW_versym 0x6fffffff -#define SHT_GNU_versym 0x6fffffff /* Symbol version table */ -#define SHT_HISUNW 0x6fffffff -#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ -#define SHT_LOPROC 0x70000000 /* reserved range for processor */ -#define SHT_X86_64_UNWIND 0x70000001 /* unwind information */ -#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND - -#define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */ -#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking - pre-emption map. */ -#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility - attributes. */ -#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */ -#define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */ -#define SHT_MIPS_LIBLIST 0x70000000 -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 -#define SHT_MIPS_GPTAB 0x70000003 -#define SHT_MIPS_UCODE 0x70000004 -#define SHT_MIPS_DEBUG 0x70000005 -#define SHT_MIPS_REGINFO 0x70000006 -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 -#define SHT_MIPS_ABIFLAGS 0x7000002a - -#define SHT_SPARC_GOTDATA 0x70000000 - -#define SHTORDERED -#define SHT_HIPROC 0x7fffffff /* specific section header types */ -#define SHT_LOUSER 0x80000000 /* reserved range for application */ -#define SHT_HIUSER 0xffffffff /* specific indexes */ - -/* Flags for sh_flags. */ -#define SHF_WRITE 0x1 /* Section contains writable data. */ -#define SHF_ALLOC 0x2 /* Section occupies memory. */ -#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ -#define SHF_MERGE 0x10 /* Section may be merged. */ -#define SHF_STRINGS 0x20 /* Section contains strings. */ -#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ -#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ -#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ -#define SHF_GROUP 0x200 /* Member of section group. */ -#define SHF_TLS 0x400 /* Section contains TLS data. */ -#define SHF_COMPRESSED 0x800 /* Section contains compressed data. */ -#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ - -/* Flags for section groups. */ -#define GRP_COMDAT 0x1 /* COMDAT semantics. */ - -/* - * Flags / mask for .gnu.versym sections. - */ -#define VERSYM_VERSION 0x7fff -#define VERSYM_HIDDEN 0x8000 - -/* Values for p_type. */ -#define PT_NULL 0 /* Unused entry. */ -#define PT_LOAD 1 /* Loadable segment. */ -#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ -#define PT_INTERP 3 /* Pathname of interpreter. */ -#define PT_NOTE 4 /* Auxiliary information. */ -#define PT_SHLIB 5 /* Reserved (not used). */ -#define PT_PHDR 6 /* Location of program header itself. */ -#define PT_TLS 7 /* Thread local storage segment */ -#define PT_LOOS 0x60000000 /* First OS-specific. */ -#define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */ -#define PT_GNU_EH_FRAME 0x6474e550 -#define PT_GNU_STACK 0x6474e551 -#define PT_GNU_RELRO 0x6474e552 -#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for kernel dumps - (currently arm). */ -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ -#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ -#define PT_SUNWDTRACE 0x6ffffffc /* private */ -#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff /* Last OS-specific. */ -#define PT_LOPROC 0x70000000 /* First processor-specific type. */ -#define PT_ARM_ARCHEXT 0x70000000 /* ARM arch compat information. */ -#define PT_ARM_EXIDX 0x70000001 /* ARM exception unwind tables. */ -#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ - -/* Values for p_flags. */ -#define PF_X 0x1 /* Executable. */ -#define PF_W 0x2 /* Writable. */ -#define PF_R 0x4 /* Readable. */ -#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific. */ - -/* Extended program header index. */ -#define PN_XNUM 0xffff - -/* Values for d_tag. */ -#define DT_NULL 0 /* Terminating entry. */ -#define DT_NEEDED 1 /* String table offset of a needed shared - library. */ -#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ -#define DT_PLTGOT 3 /* Processor-dependent address. */ -#define DT_HASH 4 /* Address of symbol hash table. */ -#define DT_STRTAB 5 /* Address of string table. */ -#define DT_SYMTAB 6 /* Address of symbol table. */ -#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ -#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ -#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ -#define DT_STRSZ 10 /* Size of string table. */ -#define DT_SYMENT 11 /* Size of each symbol table entry. */ -#define DT_INIT 12 /* Address of initialization function. */ -#define DT_FINI 13 /* Address of finalization function. */ -#define DT_SONAME 14 /* String table offset of shared object - name. */ -#define DT_RPATH 15 /* String table offset of library path. [sup] */ -#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ -#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ -#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ -#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ -#define DT_PLTREL 20 /* Type of relocation used for PLT. */ -#define DT_DEBUG 21 /* Reserved (not used). */ -#define DT_TEXTREL 22 /* Indicates there may be relocations in - non-writable segments. [sup] */ -#define DT_JMPREL 23 /* Address of PLT relocations. */ -#define DT_BIND_NOW 24 /* [sup] */ -#define DT_INIT_ARRAY 25 /* Address of the array of pointers to - initialization functions */ -#define DT_FINI_ARRAY 26 /* Address of the array of pointers to - termination functions */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of - initialization functions. */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of - termination functions. */ -#define DT_RUNPATH 29 /* String table offset of a null-terminated - library search path string. */ -#define DT_FLAGS 30 /* Object specific flag values. */ -#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING - and less than DT_LOOS follow the rules for - the interpretation of the d_un union - as follows: even == 'd_ptr', odd == 'd_val' - or none */ -#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to - pre-initialization functions. */ -#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of - pre-initialization functions. */ -#define DT_MAXPOSTAGS 34 /* number of positive tags */ -#define DT_LOOS 0x6000000d /* First OS-specific */ -#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ -#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ -#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ -#define DT_SUNW_CAP 0x60000010 /* hardware/software */ -#define DT_HIOS 0x6ffff000 /* Last OS-specific */ - -/* - * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - * Dyn.d_un.d_val field of the Elf*_Dyn structure. - */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_GNU_PRELINKED 0x6ffffdf5 /* prelinking timestamp */ -#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* size of conflict section */ -#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* size of library list */ -#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ -#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ -#define DT_MOVEENT 0x6ffffdfa /* move table entry size */ -#define DT_MOVESZ 0x6ffffdfb /* move table size */ -#define DT_FEATURE 0x6ffffdfc /* feature holder */ -#define DT_FEATURE_1 DT_FEATURE -#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ -/* the following DT_* entry. */ -/* See DF_P1_* definitions */ -#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ -#define DT_VALRNGHI 0x6ffffdff - -/* - * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - * - * If any adjustment is made to the ELF object after it has been - * built, these entries will need to be adjusted. - */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ -#define DT_TLSDESC_PLT 0x6ffffef6 /* loc. of PLT for tlsdesc resolver */ -#define DT_TLSDESC_GOT 0x6ffffef7 /* loc. of GOT for tlsdesc resolver */ -#define DT_GNU_CONFLICT 0x6ffffef8 /* address of conflict section */ -#define DT_GNU_LIBLIST 0x6ffffef9 /* address of library list */ -#define DT_CONFIG 0x6ffffefa /* configuration information */ -#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ -#define DT_AUDIT 0x6ffffefc /* object auditing */ -#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ -#define DT_MOVETAB 0x6ffffefe /* move table */ -#define DT_SYMINFO 0x6ffffeff /* syminfo table */ -#define DT_ADDRRNGHI 0x6ffffeff - -#define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ -#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ -#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ -#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ -#define DT_VERDEF 0x6ffffffc /* Address of verdef section. */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */ -#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */ - -#define DT_LOPROC 0x70000000 /* First processor-specific type. */ - -#define DT_ARM_SYMTABSZ 0x70000001 -#define DT_ARM_PREEMPTMAP 0x70000002 - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_DEPRECATED_SPARC_REGISTER 0x7000001 - -#define DT_MIPS_RLD_VERSION 0x70000001 -#define DT_MIPS_TIME_STAMP 0x70000002 -#define DT_MIPS_ICHECKSUM 0x70000003 -#define DT_MIPS_IVERSION 0x70000004 -#define DT_MIPS_FLAGS 0x70000005 -#define DT_MIPS_BASE_ADDRESS 0x70000006 -#define DT_MIPS_CONFLICT 0x70000008 -#define DT_MIPS_LIBLIST 0x70000009 -#define DT_MIPS_LOCAL_GOTNO 0x7000000a -#define DT_MIPS_CONFLICTNO 0x7000000b -#define DT_MIPS_LIBLISTNO 0x70000010 -#define DT_MIPS_SYMTABNO 0x70000011 -#define DT_MIPS_UNREFEXTNO 0x70000012 -#define DT_MIPS_GOTSYM 0x70000013 -#define DT_MIPS_HIPAGENO 0x70000014 -#define DT_MIPS_RLD_MAP 0x70000016 -#define DT_MIPS_DELTA_CLASS 0x70000017 -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 -#define DT_MIPS_DELTA_INSTANCE 0x70000019 -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001A -#define DT_MIPS_DELTA_RELOC 0x7000001B -#define DT_MIPS_DELTA_RELOC_NO 0x7000001C -#define DT_MIPS_DELTA_SYM 0x7000001D -#define DT_MIPS_DELTA_SYM_NO 0x7000001E -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 -#define DT_MIPS_CXX_FLAGS 0x70000022 -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 -#define DT_MIPS_INTERFACE 0x7000002A -#define DT_MIPS_DYNSTR_ALIGN 0x7000002B -#define DT_MIPS_INTERFACE_SIZE 0x7000002C -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002D -#define DT_MIPS_PERF_SUFFIX 0x7000002E -#define DT_MIPS_COMPACT_SIZE 0x7000002F -#define DT_MIPS_GP_VALUE 0x70000030 -#define DT_MIPS_AUX_DYNAMIC 0x70000031 -#define DT_MIPS_PLTGOT 0x70000032 -#define DT_MIPS_RLD_OBJ_UPDATE 0x70000033 -#define DT_MIPS_RWPLT 0x70000034 - -#define DT_PPC_GOT 0x70000000 -#define DT_PPC_TLSOPT 0x70000001 - -#define DT_PPC64_GLINK 0x70000000 -#define DT_PPC64_OPD 0x70000001 -#define DT_PPC64_OPDSZ 0x70000002 -#define DT_PPC64_TLSOPT 0x70000003 - -#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ -#define DT_USED 0x7ffffffe /* ignored - same as needed */ -#define DT_FILTER 0x7fffffff /* shared library filter name */ -#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ - -/* Values for DT_FLAGS */ -#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may - make reference to the $ORIGIN substitution - string */ -#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ -#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in - non-writable segments. */ -#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should - process all relocations for the object - containing this entry before transferring - control to the program. */ -#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or - executable contains code using a static - thread-local storage scheme. */ - -/* Values for DT_FLAGS_1 */ -#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ -#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ -#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ -#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */ -#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ -#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ -#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */ -#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */ - -/* Values for l_flags. */ -#define LL_NONE 0x0 /* no flags */ -#define LL_EXACT_MATCH 0x1 /* require an exact match */ -#define LL_IGNORE_INT_VER 0x2 /* ignore version incompatibilities */ -#define LL_REQUIRE_MINOR 0x4 -#define LL_EXPORTS 0x8 -#define LL_DELAY_LOAD 0x10 -#define LL_DELTA 0x20 - -/* Values for n_type used in executables. */ -#define NT_FREEBSD_ABI_TAG 1 -#define NT_FREEBSD_NOINIT_TAG 2 -#define NT_FREEBSD_ARCH_TAG 3 - -/* Values for n_type. Used in core files. */ -#define NT_PRSTATUS 1 /* Process status. */ -#define NT_FPREGSET 2 /* Floating point registers. */ -#define NT_PRPSINFO 3 /* Process state info. */ -#define NT_THRMISC 7 /* Thread miscellaneous info. */ -#define NT_PROCSTAT_PROC 8 /* Procstat proc data. */ -#define NT_PROCSTAT_FILES 9 /* Procstat files data. */ -#define NT_PROCSTAT_VMMAP 10 /* Procstat vmmap data. */ -#define NT_PROCSTAT_GROUPS 11 /* Procstat groups data. */ -#define NT_PROCSTAT_UMASK 12 /* Procstat umask data. */ -#define NT_PROCSTAT_RLIMIT 13 /* Procstat rlimit data. */ -#define NT_PROCSTAT_OSREL 14 /* Procstat osreldate data. */ -#define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ -#define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ -#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ -#define NT_X86_XSTATE 0x202 /* x86 XSAVE extended state. */ - -/* Symbol Binding - ELFNN_ST_BIND - st_info */ -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* like global - lower precedence */ -#define STB_LOOS 10 /* Start of operating system reserved range. */ -#define STB_GNU_UNIQUE 10 /* Unique symbol (GNU) */ -#define STB_HIOS 12 /* End of operating system reserved range. */ -#define STB_LOPROC 13 /* reserved range for processor */ -#define STB_HIPROC 15 /* specific semantics. */ - -/* Symbol type - ELFNN_ST_TYPE - st_info */ -#define STT_NOTYPE 0 /* Unspecified type. */ -#define STT_OBJECT 1 /* Data object. */ -#define STT_FUNC 2 /* Function. */ -#define STT_SECTION 3 /* Section. */ -#define STT_FILE 4 /* Source file. */ -#define STT_COMMON 5 /* Uninitialized common block. */ -#define STT_TLS 6 /* TLS object. */ -#define STT_NUM 7 -#define STT_LOOS 10 /* Reserved range for operating system */ -#define STT_GNU_IFUNC 10 -#define STT_HIOS 12 /* specific semantics. */ -#define STT_LOPROC 13 /* Start of processor reserved range. */ -#define STT_SPARC_REGISTER 13 /* SPARC register information. */ -#define STT_HIPROC 15 /* End of processor reserved range. */ - -/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ -#define STV_DEFAULT 0x0 /* Default visibility (see binding). */ -#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ -#define STV_HIDDEN 0x2 /* Not visible. */ -#define STV_PROTECTED 0x3 /* Visible but not preemptible. */ -#define STV_EXPORTED 0x4 -#define STV_SINGLETON 0x5 -#define STV_ELIMINATE 0x6 - -/* Special symbol table indexes. */ -#define STN_UNDEF 0 /* Undefined symbol index. */ - -/* Symbol versioning flags. */ -#define VER_DEF_CURRENT 1 -#define VER_DEF_IDX(x) VER_NDX(x) - -#define VER_FLG_BASE 0x01 -#define VER_FLG_WEAK 0x02 - -#define VER_NEED_CURRENT 1 -#define VER_NEED_WEAK (1u << 15) -#define VER_NEED_HIDDEN VER_NDX_HIDDEN -#define VER_NEED_IDX(x) VER_NDX(x) - -#define VER_NDX_LOCAL 0 -#define VER_NDX_GLOBAL 1 -#define VER_NDX_GIVEN 2 - -#define VER_NDX_HIDDEN (1u << 15) -#define VER_NDX(x) ((x) & ~(1u << 15)) - -#define CA_SUNW_NULL 0 -#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ -#define CA_SUNW_SF_1 2 /* first software capabilities entry */ - -/* - * Syminfo flag values - */ -#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ -/* to object containing defn. */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ -#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */ -/* lazily-loaded */ -#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ -/* object containing defn. */ -#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ -/* directly bind to this symbol */ -#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ -#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ - -/* - * Syminfo.si_boundto values. - */ -#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ -#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ -#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ - -/* - * Syminfo version values. - */ -#define SYMINFO_NONE 0 /* Syminfo version */ -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - -/* Values for ch_type (compressed section headers). */ -#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE */ -#define ELFCOMPRESS_LOOS 0x60000000 /* OS-specific */ -#define ELFCOMPRESS_HIOS 0x6fffffff -#define ELFCOMPRESS_LOPROC 0x70000000 /* Processor-specific */ -#define ELFCOMPRESS_HIPROC 0x7fffffff - -/* - * Relocation types. - * - * All machine architectures are defined here to allow tools on one to - * handle others. - */ - -#define R_386_NONE 0 /* No relocation. */ -#define R_386_32 1 /* Add symbol value. */ -#define R_386_PC32 2 /* Add PC-relative symbol value. */ -#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ -#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ -#define R_386_COPY 5 /* Copy data from shared object. */ -#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ -#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ -#define R_386_RELATIVE 8 /* Add load address of shared object. */ -#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ -#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ -#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */ -#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */ -#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */ -#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */ -#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */ -#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */ -#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */ -#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */ -#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */ -#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */ -#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */ -#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */ -#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */ -#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */ -#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */ -#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */ -#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */ -#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */ -#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */ -#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */ -#define R_386_IRELATIVE 42 /* PLT entry resolved indirectly at runtime */ - -#define R_AARCH64_NONE 0 /* No relocation */ -#define R_AARCH64_ABS64 257 /* Absolute offset */ -#define R_AARCH64_ABS32 258 /* Absolute, 32-bit overflow check */ -#define R_AARCH64_ABS16 259 /* Absolute, 16-bit overflow check */ -#define R_AARCH64_PREL64 260 /* PC relative */ -#define R_AARCH64_PREL32 261 /* PC relative, 32-bit overflow check */ -#define R_AARCH64_PREL16 262 /* PC relative, 16-bit overflow check */ -#define R_AARCH64_COPY 1024 /* Copy data from shared object */ -#define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */ -#define R_AARCH64_JUMP_SLOT 1026 /* Set GOT entry to code address */ -#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */ -#define R_AARCH64_TLS_DTPREL64 1028 -#define R_AARCH64_TLS_DTPMOD64 1029 -#define R_AARCH64_TLS_TPREL64 1030 -#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */ -#define R_AARCH64_IRELATIVE 1032 - -#define R_ARM_NONE 0 /* No relocation. */ -#define R_ARM_PC24 1 -#define R_ARM_ABS32 2 -#define R_ARM_REL32 3 -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 -#define R_ARM_ABS12 6 -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 -/* TLS relocations */ -#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ -#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ -#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ -#define R_ARM_COPY 20 /* Copy data from shared object. */ -#define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */ -#define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */ -#define R_ARM_RELATIVE 23 /* Add load address of shared object. */ -#define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */ -#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */ -#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */ -#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */ -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS32 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 - -/* Name Value Field Calculation */ -#define R_IA_64_NONE 0 /* None */ -#define R_IA_64_IMM14 0x21 /* immediate14 S + A */ -#define R_IA_64_IMM22 0x22 /* immediate22 S + A */ -#define R_IA_64_IMM64 0x23 /* immediate64 S + A */ -#define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */ -#define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */ -#define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */ -#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */ -#define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */ -#define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */ -#define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */ -#define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */ -#define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */ -#define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */ -#define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */ -#define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */ -#define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */ -#define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */ -#define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */ -#define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */ -#define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */ -#define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */ -#define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */ -#define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */ -#define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */ -#define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */ -#define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */ -#define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */ -#define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */ -#define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */ -#define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */ -#define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */ -#define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */ -#define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */ -#define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */ -#define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */ -#define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */ -#define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */ -#define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */ -#define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */ -#define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */ -#define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */ -#define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */ -#define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */ -#define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */ -#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */ -#define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */ -#define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */ -#define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */ -#define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */ -#define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */ -#define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ -#define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ -#define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ -#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ -#define R_IA_64_SUB 0x85 /* immediate64 A - S */ -#define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ -#define R_IA_64_LDXMOV 0x87 /* immediate22 special */ -#define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */ -#define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */ -#define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */ -#define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */ -#define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */ -#define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */ -#define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */ -#define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */ -#define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */ -#define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */ -#define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */ -#define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */ -#define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */ -#define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */ -#define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */ -#define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */ -#define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */ - -#define R_MIPS_NONE 0 /* No reloc */ -#define R_MIPS_16 1 /* Direct 16 bit */ -#define R_MIPS_32 2 /* Direct 32 bit */ -#define R_MIPS_REL32 3 /* PC relative 32 bit */ -#define R_MIPS_26 4 /* Direct 26 bit shifted */ -#define R_MIPS_HI16 5 /* High 16 bit */ -#define R_MIPS_LO16 6 /* Low 16 bit */ -#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#define R_MIPS_PC16 10 /* PC relative 16 bit */ -#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ -#define R_MIPS_64 18 /* Direct 64 bit */ -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */ -#define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */ -#define R_MIPS_SUB 24 -#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ -#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ -#define R_MIPS_JALR 37 -#define R_MIPS_TLS_GD 42 - -#define R_PPC_NONE 0 /* No relocation. */ -#define R_PPC_ADDR32 1 -#define R_PPC_ADDR24 2 -#define R_PPC_ADDR16 3 -#define R_PPC_ADDR16_LO 4 -#define R_PPC_ADDR16_HI 5 -#define R_PPC_ADDR16_HA 6 -#define R_PPC_ADDR14 7 -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 -#define R_PPC_REL14 11 -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 - -/* - * 64-bit relocations - */ -#define R_PPC64_ADDR64 38 -#define R_PPC64_ADDR16_HIGHER 39 -#define R_PPC64_ADDR16_HIGHERA 40 -#define R_PPC64_ADDR16_HIGHEST 41 -#define R_PPC64_ADDR16_HIGHESTA 42 -#define R_PPC64_UADDR64 43 -#define R_PPC64_REL64 44 -#define R_PPC64_PLT64 45 -#define R_PPC64_PLTREL64 46 -#define R_PPC64_TOC16 47 -#define R_PPC64_TOC16_LO 48 -#define R_PPC64_TOC16_HI 49 -#define R_PPC64_TOC16_HA 50 -#define R_PPC64_TOC 51 -#define R_PPC64_DTPMOD64 68 -#define R_PPC64_TPREL64 73 -#define R_PPC64_DTPREL64 78 - -/* - * TLS relocations - */ -#define R_PPC_TLS 67 -#define R_PPC_DTPMOD32 68 -#define R_PPC_TPREL16 69 -#define R_PPC_TPREL16_LO 70 -#define R_PPC_TPREL16_HI 71 -#define R_PPC_TPREL16_HA 72 -#define R_PPC_TPREL32 73 -#define R_PPC_DTPREL16 74 -#define R_PPC_DTPREL16_LO 75 -#define R_PPC_DTPREL16_HI 76 -#define R_PPC_DTPREL16_HA 77 -#define R_PPC_DTPREL32 78 -#define R_PPC_GOT_TLSGD16 79 -#define R_PPC_GOT_TLSGD16_LO 80 -#define R_PPC_GOT_TLSGD16_HI 81 -#define R_PPC_GOT_TLSGD16_HA 82 -#define R_PPC_GOT_TLSLD16 83 -#define R_PPC_GOT_TLSLD16_LO 84 -#define R_PPC_GOT_TLSLD16_HI 85 -#define R_PPC_GOT_TLSLD16_HA 86 -#define R_PPC_GOT_TPREL16 87 -#define R_PPC_GOT_TPREL16_LO 88 -#define R_PPC_GOT_TPREL16_HI 89 -#define R_PPC_GOT_TPREL16_HA 90 - -/* - * The remaining relocs are from the Embedded ELF ABI, and are not in the - * SVR4 ELF ABI. - */ - -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 - -/* - * RISC-V relocation types. - */ - -/* Relocation types used by the dynamic linker. */ -#define R_RISCV_NONE 0 -#define R_RISCV_32 1 -#define R_RISCV_64 2 -#define R_RISCV_RELATIVE 3 -#define R_RISCV_COPY 4 -#define R_RISCV_JUMP_SLOT 5 -#define R_RISCV_TLS_DTPMOD32 6 -#define R_RISCV_TLS_DTPMOD64 7 -#define R_RISCV_TLS_DTPREL32 8 -#define R_RISCV_TLS_DTPREL64 9 -#define R_RISCV_TLS_TPREL32 10 -#define R_RISCV_TLS_TPREL64 11 - -/* Relocation types not used by the dynamic linker. */ -#define R_RISCV_BRANCH 16 -#define R_RISCV_JAL 17 -#define R_RISCV_CALL 18 -#define R_RISCV_CALL_PLT 19 -#define R_RISCV_GOT_HI20 20 -#define R_RISCV_TLS_GOT_HI20 21 -#define R_RISCV_TLS_GD_HI20 22 -#define R_RISCV_PCREL_HI20 23 -#define R_RISCV_PCREL_LO12_I 24 -#define R_RISCV_PCREL_LO12_S 25 -#define R_RISCV_HI20 26 -#define R_RISCV_LO12_I 27 -#define R_RISCV_LO12_S 28 -#define R_RISCV_TPREL_HI20 29 -#define R_RISCV_TPREL_LO12_I 30 -#define R_RISCV_TPREL_LO12_S 31 -#define R_RISCV_TPREL_ADD 32 -#define R_RISCV_ADD8 33 -#define R_RISCV_ADD16 34 -#define R_RISCV_ADD32 35 -#define R_RISCV_ADD64 36 -#define R_RISCV_SUB8 37 -#define R_RISCV_SUB16 38 -#define R_RISCV_SUB32 39 -#define R_RISCV_SUB64 40 -#define R_RISCV_GNU_VTINHERIT 41 -#define R_RISCV_GNU_VTENTRY 42 -#define R_RISCV_ALIGN 43 -#define R_RISCV_RVC_BRANCH 44 -#define R_RISCV_RVC_JUMP 45 - -#define R_SPARC_NONE 0 -#define R_SPARC_8 1 -#define R_SPARC_16 2 -#define R_SPARC_32 3 -#define R_SPARC_DISP8 4 -#define R_SPARC_DISP16 5 -#define R_SPARC_DISP32 6 -#define R_SPARC_WDISP30 7 -#define R_SPARC_WDISP22 8 -#define R_SPARC_HI22 9 -#define R_SPARC_22 10 -#define R_SPARC_13 11 -#define R_SPARC_LO10 12 -#define R_SPARC_GOT10 13 -#define R_SPARC_GOT13 14 -#define R_SPARC_GOT22 15 -#define R_SPARC_PC10 16 -#define R_SPARC_PC22 17 -#define R_SPARC_WPLT30 18 -#define R_SPARC_COPY 19 -#define R_SPARC_GLOB_DAT 20 -#define R_SPARC_JMP_SLOT 21 -#define R_SPARC_RELATIVE 22 -#define R_SPARC_UA32 23 -#define R_SPARC_PLT32 24 -#define R_SPARC_HIPLT22 25 -#define R_SPARC_LOPLT10 26 -#define R_SPARC_PCPLT32 27 -#define R_SPARC_PCPLT22 28 -#define R_SPARC_PCPLT10 29 -#define R_SPARC_10 30 -#define R_SPARC_11 31 -#define R_SPARC_64 32 -#define R_SPARC_OLO10 33 -#define R_SPARC_HH22 34 -#define R_SPARC_HM10 35 -#define R_SPARC_LM22 36 -#define R_SPARC_PC_HH22 37 -#define R_SPARC_PC_HM10 38 -#define R_SPARC_PC_LM22 39 -#define R_SPARC_WDISP16 40 -#define R_SPARC_WDISP19 41 -#define R_SPARC_GLOB_JMP 42 -#define R_SPARC_7 43 -#define R_SPARC_5 44 -#define R_SPARC_6 45 -#define R_SPARC_DISP64 46 -#define R_SPARC_PLT64 47 -#define R_SPARC_HIX22 48 -#define R_SPARC_LOX10 49 -#define R_SPARC_H44 50 -#define R_SPARC_M44 51 -#define R_SPARC_L44 52 -#define R_SPARC_REGISTER 53 -#define R_SPARC_UA64 54 -#define R_SPARC_UA16 55 -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 - -#define R_X86_64_NONE 0 /* No relocation. */ -#define R_X86_64_64 1 /* Add 64 bit symbol value. */ -#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */ -#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */ -#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */ -#define R_X86_64_COPY 5 /* Copy data from shared object. */ -#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */ -#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */ -#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */ -#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */ -#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */ -#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */ -#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */ -#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */ -#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */ -#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */ -#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ -#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */ -#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */ -#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */ -#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */ -#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ -#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */ -#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */ -#define R_X86_64_PC64 24 /* PC-relative 64 bit signed sym value. */ -#define R_X86_64_GOTOFF64 25 -#define R_X86_64_GOTPC32 26 -#define R_X86_64_GOT64 27 -#define R_X86_64_GOTPCREL64 28 -#define R_X86_64_GOTPC64 29 -#define R_X86_64_GOTPLT64 30 -#define R_X86_64_PLTOFF64 31 -#define R_X86_64_SIZE32 32 -#define R_X86_64_SIZE64 33 -#define R_X86_64_GOTPC32_TLSDESC 34 -#define R_X86_64_TLSDESC_CALL 35 -#define R_X86_64_TLSDESC 36 -#define R_X86_64_IRELATIVE 37 - -#endif /* !_SYS_ELF_COMMON_H_ */ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_ELF_COMMON_H_ +#define _SYS_ELF_COMMON_H_ 1 + +/* + * ELF definitions that are independent of architecture or word size. + */ + +/* + * Note header. The ".note" section contains an array of notes. Each + * begins with this header, aligned to a word boundary. Immediately + * following the note header is n_namesz bytes of name, padded to the + * next word boundary. Then comes n_descsz bytes of descriptor, again + * padded to a word boundary. The values of n_namesz and n_descsz do + * not include the padding. + */ + +typedef struct { + uint32_t n_namesz; /* Length of name. */ + uint32_t n_descsz; /* Length of descriptor. */ + uint32_t n_type; /* Type of this note. */ +} Elf_Note; + +/* + * Option kinds. + */ +#define ODK_NULL 0 /* undefined */ +#define ODK_REGINFO 1 /* register usage info */ +#define ODK_EXCEPTIONS 2 /* exception processing info */ +#define ODK_PAD 3 /* section padding */ +#define ODK_HWPATCH 4 /* hardware patch applied */ +#define ODK_FILL 5 /* fill value used by the linker */ +#define ODK_TAGS 6 /* reserved space for tools */ +#define ODK_HWAND 7 /* hardware AND patch applied */ +#define ODK_HWOR 8 /* hardware OR patch applied */ +#define ODK_GP_GROUP 9 /* GP group for text/data sections */ +#define ODK_IDENT 10 /* ID information */ +#define ODK_PAGESIZE 11 /* page size information */ + +/* + * ODK_EXCEPTIONS info field masks. + */ +#define OEX_FPU_MIN 0x0000001f /* min FPU exception required */ +#define OEX_FPU_MAX 0x00001f00 /* max FPU exception allowed */ +#define OEX_PAGE0 0x00010000 /* page zero must be mapped */ +#define OEX_SMM 0x00020000 /* run in sequential memory mode */ +#define OEX_PRECISEFP 0x00040000 /* run in precise FP exception mode */ +#define OEX_DISMISS 0x00080000 /* dismiss invalid address traps */ + +/* + * ODK_PAD info field masks. + */ +#define OPAD_PREFIX 0x0001 +#define OPAD_POSTFIX 0x0002 +#define OPAD_SYMBOL 0x0004 + +/* + * ODK_HWPATCH info field masks. + */ +#define OHW_R4KEOP 0x00000001 /* patch for R4000 branch at end-of-page bug */ +#define OHW_R8KPFETCH 0x00000002 /* R8000 prefetch bug may occur */ +#define OHW_R5KEOP 0x00000004 /* patch for R5000 branch at end-of-page bug */ +#define OHW_R5KCVTL 0x00000008 /* R5000 cvt.[ds].l bug: clean == 1 */ +#define OHW_R10KLDL 0x00000010UL /* need patch for R10000 misaligned load */ + +/* + * ODK_HWAND/ODK_HWOR info field and hwp_flags[12] masks. + */ +#define OHWA0_R4KEOP_CHECKED 0x00000001 /* object checked for R4000 end-of-page bug */ +#define OHWA0_R4KEOP_CLEAN 0x00000002 /* object verified clean for R4000 end-of-page bug */ +#define OHWO0_FIXADE 0x00000001 /* object requires call to fixade */ + +/* + * ODK_IDENT/ODK_GP_GROUP info field masks. + */ +#define OGP_GROUP 0x0000ffff /* GP group number */ +#define OGP_SELF 0x00010000 /* GP group is self-contained */ + +/* + * The header for GNU-style hash sections. + */ + +typedef struct { + uint32_t gh_nbuckets; /* Number of hash buckets. */ + uint32_t gh_symndx; /* First visible symbol in .dynsym. */ + uint32_t gh_maskwords; /* #maskwords used in bloom filter. */ + uint32_t gh_shift2; /* Bloom filter shift count. */ +} Elf_GNU_Hash_Header; + +/* Indexes into the e_ident array. Keep synced with + http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ +#define EI_MAG0 0 /* Magic number, byte 0. */ +#define EI_MAG1 1 /* Magic number, byte 1. */ +#define EI_MAG2 2 /* Magic number, byte 2. */ +#define EI_MAG3 3 /* Magic number, byte 3. */ +#define EI_CLASS 4 /* Class of machine. */ +#define EI_DATA 5 /* Data format. */ +#define EI_VERSION 6 /* ELF format version. */ +#define EI_OSABI 7 /* Operating system / ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define OLD_EI_BRAND 8 /* Start of architecture identification. */ +#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ +#define EI_NIDENT 16 /* Size of e_ident array. */ + +/* Values for the magic number bytes. */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" /* magic string */ +#define SELFMAG 4 /* magic string size */ + +/* Values for e_ident[EI_VERSION] and e_version. */ +#define EV_NONE 0 +#define EV_CURRENT 1 + +/* Values for e_ident[EI_CLASS]. */ +#define ELFCLASSNONE 0 /* Unknown class. */ +#define ELFCLASS32 1 /* 32-bit architecture. */ +#define ELFCLASS64 2 /* 64-bit architecture. */ + +/* Values for e_ident[EI_DATA]. */ +#define ELFDATANONE 0 /* Unknown data format. */ +#define ELFDATA2LSB 1 /* 2's complement little-endian. */ +#define ELFDATA2MSB 2 /* 2's complement big-endian. */ + +/* Values for e_ident[EI_OSABI]. */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* Open VMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +#define ELFOSABI_FENIXOS 16 /* FenixOS */ +#define ELFOSABI_CLOUDABI 17 /* Nuxi CloudABI */ +#define ELFOSABI_UBIXOS 18 /* UbixOS */ +#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ +#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ +#define ELFOSABI_GNU ELFOSABI_LINUX + +/* e_ident */ +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ + (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ + (ehdr).e_ident[EI_MAG3] == ELFMAG3) + +/* Values for e_type. */ +#define ET_NONE 0 /* Unknown type. */ +#define ET_REL 1 /* Relocatable. */ +#define ET_EXEC 2 /* Executable. */ +#define ET_DYN 3 /* Shared object. */ +#define ET_CORE 4 /* Core file. */ +#define ET_LOOS 0xfe00 /* First operating system specific. */ +#define ET_HIOS 0xfeff /* Last operating system-specific. */ +#define ET_LOPROC 0xff00 /* First processor-specific. */ +#define ET_HIPROC 0xffff /* Last processor-specific. */ + +/* Values for e_machine. */ +#define EM_NONE 0 /* Unknown machine. */ +#define EM_M32 1 /* AT&T WE32100. */ +#define EM_SPARC 2 /* Sun SPARC. */ +#define EM_386 3 /* Intel i386. */ +#define EM_68K 4 /* Motorola 68000. */ +#define EM_88K 5 /* Motorola 88000. */ +#define EM_IAMCU 6 /* Intel MCU. */ +#define EM_860 7 /* Intel i860. */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ +#define EM_S370 9 /* IBM System/370. */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ +#define EM_PARISC 15 /* HP PA-RISC. */ +#define EM_VPP500 17 /* Fujitsu VPP500. */ +#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ +#define EM_960 19 /* Intel 80960. */ +#define EM_PPC 20 /* PowerPC 32-bit. */ +#define EM_PPC64 21 /* PowerPC 64-bit. */ +#define EM_S390 22 /* IBM System/390. */ +#define EM_V800 36 /* NEC V800. */ +#define EM_FR20 37 /* Fujitsu FR20. */ +#define EM_RH32 38 /* TRW RH-32. */ +#define EM_RCE 39 /* Motorola RCE. */ +#define EM_ARM 40 /* ARM. */ +#define EM_SH 42 /* Hitachi SH. */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ +#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ +#define EM_ARC 45 /* Argonaut RISC Core. */ +#define EM_H8_300 46 /* Hitachi H8/300. */ +#define EM_H8_300H 47 /* Hitachi H8/300H. */ +#define EM_H8S 48 /* Hitachi H8S. */ +#define EM_H8_500 49 /* Hitachi H8/500. */ +#define EM_IA_64 50 /* Intel IA-64 Processor. */ +#define EM_MIPS_X 51 /* Stanford MIPS-X. */ +#define EM_COLDFIRE 52 /* Motorola ColdFire. */ +#define EM_68HC12 53 /* Motorola M68HC12. */ +#define EM_MMA 54 /* Fujitsu MMA. */ +#define EM_PCP 55 /* Siemens PCP. */ +#define EM_NCPU 56 /* Sony nCPU. */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ +#define EM_STARCORE 58 /* Motorola Star*Core processor. */ +#define EM_ME16 59 /* Toyota ME16 processor. */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ +#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ +#define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 (compat) */ +#define EM_PDSP 63 /* Sony DSP Processor. */ +#define EM_FX66 66 /* Siemens FX66 microcontroller. */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 + microcontroller. */ +#define EM_ST7 68 /* STmicroelectronics ST7 8-bit + microcontroller. */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller. */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller. */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller. */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller. */ +#define EM_SVX 73 /* Silicon Graphics SVx. */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit mc. */ +#define EM_VAX 75 /* Digital VAX. */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded + processor. */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded + processor. */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor. */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor. */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit proc. */ +#define EM_HUANY 81 /* Harvard University machine-independent + object files. */ +#define EM_PRISM 82 /* SiTera Prism. */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller. */ +#define EM_FR30 84 /* Fujitsu FR30. */ +#define EM_D10V 85 /* Mitsubishi D10V. */ +#define EM_D30V 86 /* Mitsubishi D30V. */ +#define EM_V850 87 /* NEC v850. */ +#define EM_M32R 88 /* Mitsubishi M32R. */ +#define EM_MN10300 89 /* Matsushita MN10300. */ +#define EM_MN10200 90 /* Matsushita MN10200. */ +#define EM_PJ 91 /* picoJava. */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor. */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5. */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture. */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor. */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose + Processor. */ +#define EM_NS32K 97 /* National Semiconductor 32000 series. */ +#define EM_TPC 98 /* Tenor Network TPC processor. */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor. */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller. */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family. */ +#define EM_MAX 102 /* MAX Processor. */ +#define EM_CR 103 /* National Semiconductor CompactRISC + microprocessor. */ +#define EM_F2MC16 104 /* Fujitsu F2MC16. */ +#define EM_MSP430 105 /* Texas Instruments embedded microcontroller + msp430. */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin (DSP) processor. */ +#define EM_SE_C33 107 /* S1C33 Family of Seiko Epson processors. */ +#define EM_SEP 108 /* Sharp embedded microprocessor. */ +#define EM_ARCA 109 /* Arca RISC Microprocessor. */ +#define EM_UNICORE 110 /* Microprocessor series from PKU-Unity Ltd. + and MPRC of Peking University */ +#define EM_AARCH64 183 /* AArch64 (64-bit ARM) */ +#define EM_RISCV 243 /* RISC-V */ + +/* Non-standard or deprecated. */ +#define EM_486 6 /* Intel i486. */ +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ +#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ +#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ + +/** + * e_flags + */ +#define EF_ARM_RELEXEC 0x1 +#define EF_ARM_HASENTRY 0x2 +#define EF_ARM_SYMSARESORTED 0x4 +#define EF_ARM_DYNSYMSUSESEGIDX 0x8 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_LE8 0x00400000 +#define EF_ARM_BE8 0x00800000 +#define EF_ARM_EABIMASK 0xFF000000 +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 +#define EF_ARM_EABI_VER3 0x03000000 +#define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 +#define EF_ARM_INTERWORK 0x00000004 +#define EF_ARM_APCS_26 0x00000008 +#define EF_ARM_APCS_FLOAT 0x00000010 +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_VFP_FLOAT 0x00000400 +#define EF_ARM_MAVERICK_FLOAT 0x00000800 + +#define EF_MIPS_NOREORDER 0x00000001 +#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ +#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ +#define EF_MIPS_UCODE 0x00000010 +#define EF_MIPS_ABI2 0x00000020 /* N32 */ +#define EF_MIPS_OPTIONS_FIRST 0x00000080 +#define EF_MIPS_ARCH_ASE 0x0F000000 /* Architectural extensions */ +#define EF_MIPS_ARCH_ASE_MDMX 0x08000000 /* MDMX multimedia extension */ +#define EF_MIPS_ARCH_ASE_M16 0x04000000 /* MIPS-16 ISA extensions */ +#define EF_MIPS_ARCH 0xF0000000 /* Architecture field */ + +#define EF_PPC_EMB 0x80000000 +#define EF_PPC_RELOCATABLE 0x00010000 +#define EF_PPC_RELOCATABLE_LIB 0x00008000 + +#define EF_SPARC_EXT_MASK 0x00ffff00 +#define EF_SPARC_32PLUS 0x00000100 +#define EF_SPARC_SUN_US1 0x00000200 +#define EF_SPARC_HAL_R1 0x00000200 +#define EF_SPARC_SUN_US3 0x00000800 + +#define EF_SPARCV9_MM 0x00000003 +#define EF_SPARCV9_TSO 0x00000000 +#define EF_SPARCV9_PSO 0x00000001 +#define EF_SPARCV9_RMO 0x00000002 + +/* Special section indexes. */ +#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ +#define SHN_LORESERVE 0xff00 /* First of reserved range. */ +#define SHN_LOPROC 0xff00 /* First processor-specific. */ +#define SHN_HIPROC 0xff1f /* Last processor-specific. */ +#define SHN_LOOS 0xff20 /* First operating system-specific. */ +#define SHN_FBSD_CACHED SHN_LOOS /* Transient, for sys/kern/link_elf_obj + linker only: Cached global in local + symtab. */ +#define SHN_HIOS 0xff3f /* Last operating system-specific. */ +#define SHN_ABS 0xfff1 /* Absolute values. */ +#define SHN_COMMON 0xfff2 /* Common data. */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ +#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ + +/* sh_type */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined information */ +#define SHT_SYMTAB 2 /* symbol table section */ +#define SHT_STRTAB 3 /* string table section */ +#define SHT_RELA 4 /* relocation section with addends */ +#define SHT_HASH 5 /* symbol hash table section */ +#define SHT_DYNAMIC 6 /* dynamic section */ +#define SHT_NOTE 7 /* note section */ +#define SHT_NOBITS 8 /* no space section */ +#define SHT_REL 9 /* relocation section - no addends */ +#define SHT_SHLIB 10 /* reserved - purpose unknown */ +#define SHT_DYNSYM 11 /* dynamic symbol table section */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers. */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ +#define SHT_GROUP 17 /* Section group. */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ +#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ +#define SHT_LOSUNW 0x6ffffff4 +#define SHT_SUNW_dof 0x6ffffff4 +#define SHT_SUNW_cap 0x6ffffff5 +#define SHT_GNU_ATTRIBUTES 0x6ffffff5 +#define SHT_SUNW_SIGNATURE 0x6ffffff6 +#define SHT_GNU_HASH 0x6ffffff6 +#define SHT_GNU_LIBLIST 0x6ffffff7 +#define SHT_SUNW_ANNOTATE 0x6ffffff7 +#define SHT_SUNW_DEBUGSTR 0x6ffffff8 +#define SHT_SUNW_DEBUG 0x6ffffff9 +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd +#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */ +#define SHT_SUNW_verneed 0x6ffffffe +#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */ +#define SHT_SUNW_versym 0x6fffffff +#define SHT_GNU_versym 0x6fffffff /* Symbol version table */ +#define SHT_HISUNW 0x6fffffff +#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ +#define SHT_LOPROC 0x70000000 /* reserved range for processor */ +#define SHT_X86_64_UNWIND 0x70000001 /* unwind information */ +#define SHT_AMD64_UNWIND SHT_X86_64_UNWIND + +#define SHT_ARM_EXIDX 0x70000001 /* Exception index table. */ +#define SHT_ARM_PREEMPTMAP 0x70000002 /* BPABI DLL dynamic linking + pre-emption map. */ +#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility + attributes. */ +#define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details. */ +#define SHT_ARM_OVERLAYSECTION 0x70000005 /* See DBGOVL for details. */ +#define SHT_MIPS_LIBLIST 0x70000000 +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 +#define SHT_MIPS_GPTAB 0x70000003 +#define SHT_MIPS_UCODE 0x70000004 +#define SHT_MIPS_DEBUG 0x70000005 +#define SHT_MIPS_REGINFO 0x70000006 +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 +#define SHT_MIPS_ABIFLAGS 0x7000002a + +#define SHT_SPARC_GOTDATA 0x70000000 + +#define SHTORDERED +#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_LOUSER 0x80000000 /* reserved range for application */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ + +/* Flags for sh_flags. */ +#define SHF_WRITE 0x1 /* Section contains writable data. */ +#define SHF_ALLOC 0x2 /* Section occupies memory. */ +#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ +#define SHF_MERGE 0x10 /* Section may be merged. */ +#define SHF_STRINGS 0x20 /* Section contains strings. */ +#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ +#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ +#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ +#define SHF_GROUP 0x200 /* Member of section group. */ +#define SHF_TLS 0x400 /* Section contains TLS data. */ +#define SHF_COMPRESSED 0x800 /* Section contains compressed data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ + +/* Flags for section groups. */ +#define GRP_COMDAT 0x1 /* COMDAT semantics. */ + +/* + * Flags / mask for .gnu.versym sections. + */ +#define VERSYM_VERSION 0x7fff +#define VERSYM_HIDDEN 0x8000 + +/* Values for p_type. */ +#define PT_NULL 0 /* Unused entry. */ +#define PT_LOAD 1 /* Loadable segment. */ +#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ +#define PT_INTERP 3 /* Pathname of interpreter. */ +#define PT_NOTE 4 /* Auxiliary information. */ +#define PT_SHLIB 5 /* Reserved (not used). */ +#define PT_PHDR 6 /* Location of program header itself. */ +#define PT_TLS 7 /* Thread local storage segment */ +#define PT_LOOS 0x60000000 /* First OS-specific. */ +#define PT_SUNW_UNWIND 0x6464e550 /* amd64 UNWIND program header */ +#define PT_GNU_EH_FRAME 0x6474e550 +#define PT_GNU_STACK 0x6474e551 +#define PT_GNU_RELRO 0x6474e552 +#define PT_DUMP_DELTA 0x6fb5d000 /* va->pa map for kernel dumps + (currently arm). */ +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */ +#define PT_SUNWDTRACE 0x6ffffffc /* private */ +#define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* Last OS-specific. */ +#define PT_LOPROC 0x70000000 /* First processor-specific type. */ +#define PT_ARM_ARCHEXT 0x70000000 /* ARM arch compat information. */ +#define PT_ARM_EXIDX 0x70000001 /* ARM exception unwind tables. */ +#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for p_flags. */ +#define PF_X 0x1 /* Executable. */ +#define PF_W 0x2 /* Writable. */ +#define PF_R 0x4 /* Readable. */ +#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific. */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* Values for d_tag. */ +#define DT_NULL 0 /* Terminating entry. */ +#define DT_NEEDED 1 /* String table offset of a needed shared + library. */ +#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ +#define DT_PLTGOT 3 /* Processor-dependent address. */ +#define DT_HASH 4 /* Address of symbol hash table. */ +#define DT_STRTAB 5 /* Address of string table. */ +#define DT_SYMTAB 6 /* Address of symbol table. */ +#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ +#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ +#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ +#define DT_STRSZ 10 /* Size of string table. */ +#define DT_SYMENT 11 /* Size of each symbol table entry. */ +#define DT_INIT 12 /* Address of initialization function. */ +#define DT_FINI 13 /* Address of finalization function. */ +#define DT_SONAME 14 /* String table offset of shared object + name. */ +#define DT_RPATH 15 /* String table offset of library path. [sup] */ +#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ +#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ +#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ +#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ +#define DT_PLTREL 20 /* Type of relocation used for PLT. */ +#define DT_DEBUG 21 /* Reserved (not used). */ +#define DT_TEXTREL 22 /* Indicates there may be relocations in + non-writable segments. [sup] */ +#define DT_JMPREL 23 /* Address of PLT relocations. */ +#define DT_BIND_NOW 24 /* [sup] */ +#define DT_INIT_ARRAY 25 /* Address of the array of pointers to + initialization functions */ +#define DT_FINI_ARRAY 26 /* Address of the array of pointers to + termination functions */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of + initialization functions. */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of + termination functions. */ +#define DT_RUNPATH 29 /* String table offset of a null-terminated + library search path string. */ +#define DT_FLAGS 30 /* Object specific flag values. */ +#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING + and less than DT_LOOS follow the rules for + the interpretation of the d_un union + as follows: even == 'd_ptr', odd == 'd_val' + or none */ +#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to + pre-initialization functions. */ +#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of + pre-initialization functions. */ +#define DT_MAXPOSTAGS 34 /* number of positive tags */ +#define DT_LOOS 0x6000000d /* First OS-specific */ +#define DT_SUNW_AUXILIARY 0x6000000d /* symbol auxiliary name */ +#define DT_SUNW_RTLDINF 0x6000000e /* ld.so.1 info (private) */ +#define DT_SUNW_FILTER 0x6000000f /* symbol filter name */ +#define DT_SUNW_CAP 0x60000010 /* hardware/software */ +#define DT_HIOS 0x6ffff000 /* Last OS-specific */ + +/* + * DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + * Dyn.d_un.d_val field of the Elf*_Dyn structure. + */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 /* prelinking timestamp */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* size of conflict section */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* size of library list */ +#define DT_CHECKSUM 0x6ffffdf8 /* elf checksum */ +#define DT_PLTPADSZ 0x6ffffdf9 /* pltpadding size */ +#define DT_MOVEENT 0x6ffffdfa /* move table entry size */ +#define DT_MOVESZ 0x6ffffdfb /* move table size */ +#define DT_FEATURE 0x6ffffdfc /* feature holder */ +#define DT_FEATURE_1 DT_FEATURE +#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */ +/* the following DT_* entry. */ +/* See DF_P1_* definitions */ +#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */ +#define DT_VALRNGHI 0x6ffffdff + +/* + * DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + * + * If any adjustment is made to the ELF object after it has been + * built, these entries will need to be adjusted. + */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table */ +#define DT_TLSDESC_PLT 0x6ffffef6 /* loc. of PLT for tlsdesc resolver */ +#define DT_TLSDESC_GOT 0x6ffffef7 /* loc. of GOT for tlsdesc resolver */ +#define DT_GNU_CONFLICT 0x6ffffef8 /* address of conflict section */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* address of library list */ +#define DT_CONFIG 0x6ffffefa /* configuration information */ +#define DT_DEPAUDIT 0x6ffffefb /* dependency auditing */ +#define DT_AUDIT 0x6ffffefc /* object auditing */ +#define DT_PLTPAD 0x6ffffefd /* pltpadding (sparcv9) */ +#define DT_MOVETAB 0x6ffffefe /* move table */ +#define DT_SYMINFO 0x6ffffeff /* syminfo table */ +#define DT_ADDRRNGHI 0x6ffffeff + +#define DT_VERSYM 0x6ffffff0 /* Address of versym section. */ +#define DT_RELACOUNT 0x6ffffff9 /* number of RELATIVE relocations */ +#define DT_RELCOUNT 0x6ffffffa /* number of RELATIVE relocations */ +#define DT_FLAGS_1 0x6ffffffb /* state flags - see DF_1_* defs */ +#define DT_VERDEF 0x6ffffffc /* Address of verdef section. */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of elems in verdef section */ +#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */ + +#define DT_LOPROC 0x70000000 /* First processor-specific type. */ + +#define DT_ARM_SYMTABSZ 0x70000001 +#define DT_ARM_PREEMPTMAP 0x70000002 + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_DEPRECATED_SPARC_REGISTER 0x7000001 + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_LOCAL_GOTNO 0x7000000a +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 +#define DT_MIPS_DELTA_CLASS 0x70000017 +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 +#define DT_MIPS_DELTA_INSTANCE 0x70000019 +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001A +#define DT_MIPS_DELTA_RELOC 0x7000001B +#define DT_MIPS_DELTA_RELOC_NO 0x7000001C +#define DT_MIPS_DELTA_SYM 0x7000001D +#define DT_MIPS_DELTA_SYM_NO 0x7000001E +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 +#define DT_MIPS_CXX_FLAGS 0x70000022 +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 +#define DT_MIPS_INTERFACE 0x7000002A +#define DT_MIPS_DYNSTR_ALIGN 0x7000002B +#define DT_MIPS_INTERFACE_SIZE 0x7000002C +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002D +#define DT_MIPS_PERF_SUFFIX 0x7000002E +#define DT_MIPS_COMPACT_SIZE 0x7000002F +#define DT_MIPS_GP_VALUE 0x70000030 +#define DT_MIPS_AUX_DYNAMIC 0x70000031 +#define DT_MIPS_PLTGOT 0x70000032 +#define DT_MIPS_RLD_OBJ_UPDATE 0x70000033 +#define DT_MIPS_RWPLT 0x70000034 + +#define DT_PPC_GOT 0x70000000 +#define DT_PPC_TLSOPT 0x70000001 + +#define DT_PPC64_GLINK 0x70000000 +#define DT_PPC64_OPD 0x70000001 +#define DT_PPC64_OPDSZ 0x70000002 +#define DT_PPC64_TLSOPT 0x70000003 + +#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */ +#define DT_USED 0x7ffffffe /* ignored - same as needed */ +#define DT_FILTER 0x7fffffff /* shared library filter name */ +#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for DT_FLAGS */ +#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may + make reference to the $ORIGIN substitution + string */ +#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ +#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in + non-writable segments. */ +#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should + process all relocations for the object + containing this entry before transferring + control to the program. */ +#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or + executable contains code using a static + thread-local storage scheme. */ + +/* Values for DT_FLAGS_1 */ +#define DF_1_BIND_NOW 0x00000001 /* Same as DF_BIND_NOW */ +#define DF_1_GLOBAL 0x00000002 /* Set the RTLD_GLOBAL for object */ +#define DF_1_NODELETE 0x00000008 /* Set the RTLD_NODELETE for object */ +#define DF_1_LOADFLTR 0x00000010 /* Immediate loading of filtees */ +#define DF_1_NOOPEN 0x00000040 /* Do not allow loading on dlopen() */ +#define DF_1_ORIGIN 0x00000080 /* Process $ORIGIN */ +#define DF_1_INTERPOSE 0x00000400 /* Interpose all objects but main */ +#define DF_1_NODEFLIB 0x00000800 /* Do not search default paths */ + +/* Values for l_flags. */ +#define LL_NONE 0x0 /* no flags */ +#define LL_EXACT_MATCH 0x1 /* require an exact match */ +#define LL_IGNORE_INT_VER 0x2 /* ignore version incompatibilities */ +#define LL_REQUIRE_MINOR 0x4 +#define LL_EXPORTS 0x8 +#define LL_DELAY_LOAD 0x10 +#define LL_DELTA 0x20 + +/* Values for n_type used in executables. */ +#define NT_FREEBSD_ABI_TAG 1 +#define NT_FREEBSD_NOINIT_TAG 2 +#define NT_FREEBSD_ARCH_TAG 3 + +/* Values for n_type. Used in core files. */ +#define NT_PRSTATUS 1 /* Process status. */ +#define NT_FPREGSET 2 /* Floating point registers. */ +#define NT_PRPSINFO 3 /* Process state info. */ +#define NT_THRMISC 7 /* Thread miscellaneous info. */ +#define NT_PROCSTAT_PROC 8 /* Procstat proc data. */ +#define NT_PROCSTAT_FILES 9 /* Procstat files data. */ +#define NT_PROCSTAT_VMMAP 10 /* Procstat vmmap data. */ +#define NT_PROCSTAT_GROUPS 11 /* Procstat groups data. */ +#define NT_PROCSTAT_UMASK 12 /* Procstat umask data. */ +#define NT_PROCSTAT_RLIMIT 13 /* Procstat rlimit data. */ +#define NT_PROCSTAT_OSREL 14 /* Procstat osreldate data. */ +#define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ +#define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ +#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ +#define NT_X86_XSTATE 0x202 /* x86 XSAVE extended state. */ + +/* Symbol Binding - ELFNN_ST_BIND - st_info */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* like global - lower precedence */ +#define STB_LOOS 10 /* Start of operating system reserved range. */ +#define STB_GNU_UNIQUE 10 /* Unique symbol (GNU) */ +#define STB_HIOS 12 /* End of operating system reserved range. */ +#define STB_LOPROC 13 /* reserved range for processor */ +#define STB_HIPROC 15 /* specific semantics. */ + +/* Symbol type - ELFNN_ST_TYPE - st_info */ +#define STT_NOTYPE 0 /* Unspecified type. */ +#define STT_OBJECT 1 /* Data object. */ +#define STT_FUNC 2 /* Function. */ +#define STT_SECTION 3 /* Section. */ +#define STT_FILE 4 /* Source file. */ +#define STT_COMMON 5 /* Uninitialized common block. */ +#define STT_TLS 6 /* TLS object. */ +#define STT_NUM 7 +#define STT_LOOS 10 /* Reserved range for operating system */ +#define STT_GNU_IFUNC 10 +#define STT_HIOS 12 /* specific semantics. */ +#define STT_LOPROC 13 /* Start of processor reserved range. */ +#define STT_SPARC_REGISTER 13 /* SPARC register information. */ +#define STT_HIPROC 15 /* End of processor reserved range. */ + +/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ +#define STV_DEFAULT 0x0 /* Default visibility (see binding). */ +#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ +#define STV_HIDDEN 0x2 /* Not visible. */ +#define STV_PROTECTED 0x3 /* Visible but not preemptible. */ +#define STV_EXPORTED 0x4 +#define STV_SINGLETON 0x5 +#define STV_ELIMINATE 0x6 + +/* Special symbol table indexes. */ +#define STN_UNDEF 0 /* Undefined symbol index. */ + +/* Symbol versioning flags. */ +#define VER_DEF_CURRENT 1 +#define VER_DEF_IDX(x) VER_NDX(x) + +#define VER_FLG_BASE 0x01 +#define VER_FLG_WEAK 0x02 + +#define VER_NEED_CURRENT 1 +#define VER_NEED_WEAK (1u << 15) +#define VER_NEED_HIDDEN VER_NDX_HIDDEN +#define VER_NEED_IDX(x) VER_NDX(x) + +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 +#define VER_NDX_GIVEN 2 + +#define VER_NDX_HIDDEN (1u << 15) +#define VER_NDX(x) ((x) & ~(1u << 15)) + +#define CA_SUNW_NULL 0 +#define CA_SUNW_HW_1 1 /* first hardware capabilities entry */ +#define CA_SUNW_SF_1 2 /* first software capabilities entry */ + +/* + * Syminfo flag values + */ +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */ +/* to object containing defn. */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */ +/* lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */ +/* object containing defn. */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */ +/* directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +/* + * Syminfo.si_boundto values. + */ +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +/* + * Syminfo version values. + */ +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* Values for ch_type (compressed section headers). */ +#define ELFCOMPRESS_ZLIB 1 /* ZLIB/DEFLATE */ +#define ELFCOMPRESS_LOOS 0x60000000 /* OS-specific */ +#define ELFCOMPRESS_HIOS 0x6fffffff +#define ELFCOMPRESS_LOPROC 0x70000000 /* Processor-specific */ +#define ELFCOMPRESS_HIPROC 0x7fffffff + +/* + * Relocation types. + * + * All machine architectures are defined here to allow tools on one to + * handle others. + */ + +#define R_386_NONE 0 /* No relocation. */ +#define R_386_32 1 /* Add symbol value. */ +#define R_386_PC32 2 /* Add PC-relative symbol value. */ +#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ +#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ +#define R_386_COPY 5 /* Copy data from shared object. */ +#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_386_RELATIVE 8 /* Add load address of shared object. */ +#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ +#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ +#define R_386_TLS_TPOFF 14 /* Negative offset in static TLS block */ +#define R_386_TLS_IE 15 /* Absolute address of GOT for -ve static TLS */ +#define R_386_TLS_GOTIE 16 /* GOT entry for negative static TLS block */ +#define R_386_TLS_LE 17 /* Negative offset relative to static TLS */ +#define R_386_TLS_GD 18 /* 32 bit offset to GOT (index,off) pair */ +#define R_386_TLS_LDM 19 /* 32 bit offset to GOT (index,zero) pair */ +#define R_386_TLS_GD_32 24 /* 32 bit offset to GOT (index,off) pair */ +#define R_386_TLS_GD_PUSH 25 /* pushl instruction for Sun ABI GD sequence */ +#define R_386_TLS_GD_CALL 26 /* call instruction for Sun ABI GD sequence */ +#define R_386_TLS_GD_POP 27 /* popl instruction for Sun ABI GD sequence */ +#define R_386_TLS_LDM_32 28 /* 32 bit offset to GOT (index,zero) pair */ +#define R_386_TLS_LDM_PUSH 29 /* pushl instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDM_CALL 30 /* call instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDM_POP 31 /* popl instruction for Sun ABI LD sequence */ +#define R_386_TLS_LDO_32 32 /* 32 bit offset from start of TLS block */ +#define R_386_TLS_IE_32 33 /* 32 bit offset to GOT static TLS offset entry */ +#define R_386_TLS_LE_32 34 /* 32 bit offset within static TLS block */ +#define R_386_TLS_DTPMOD32 35 /* GOT entry containing TLS index */ +#define R_386_TLS_DTPOFF32 36 /* GOT entry containing TLS offset */ +#define R_386_TLS_TPOFF32 37 /* GOT entry of -ve static TLS offset */ +#define R_386_IRELATIVE 42 /* PLT entry resolved indirectly at runtime */ + +#define R_AARCH64_NONE 0 /* No relocation */ +#define R_AARCH64_ABS64 257 /* Absolute offset */ +#define R_AARCH64_ABS32 258 /* Absolute, 32-bit overflow check */ +#define R_AARCH64_ABS16 259 /* Absolute, 16-bit overflow check */ +#define R_AARCH64_PREL64 260 /* PC relative */ +#define R_AARCH64_PREL32 261 /* PC relative, 32-bit overflow check */ +#define R_AARCH64_PREL16 262 /* PC relative, 16-bit overflow check */ +#define R_AARCH64_COPY 1024 /* Copy data from shared object */ +#define R_AARCH64_GLOB_DAT 1025 /* Set GOT entry to data address */ +#define R_AARCH64_JUMP_SLOT 1026 /* Set GOT entry to code address */ +#define R_AARCH64_RELATIVE 1027 /* Add load address of shared object */ +#define R_AARCH64_TLS_DTPREL64 1028 +#define R_AARCH64_TLS_DTPMOD64 1029 +#define R_AARCH64_TLS_TPREL64 1030 +#define R_AARCH64_TLSDESC 1031 /* Identify the TLS descriptor */ +#define R_AARCH64_IRELATIVE 1032 + +#define R_ARM_NONE 0 /* No relocation. */ +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ +#define R_ARM_COPY 20 /* Copy data from shared object. */ +#define R_ARM_GLOB_DAT 21 /* Set GOT entry to data address. */ +#define R_ARM_JUMP_SLOT 22 /* Set GOT entry to code address. */ +#define R_ARM_RELATIVE 23 /* Add load address of shared object. */ +#define R_ARM_GOTOFF 24 /* Add GOT-relative symbol address. */ +#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */ +#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */ +#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +/* Name Value Field Calculation */ +#define R_IA_64_NONE 0 /* None */ +#define R_IA_64_IMM14 0x21 /* immediate14 S + A */ +#define R_IA_64_IMM22 0x22 /* immediate22 S + A */ +#define R_IA_64_IMM64 0x23 /* immediate64 S + A */ +#define R_IA_64_DIR32MSB 0x24 /* word32 MSB S + A */ +#define R_IA_64_DIR32LSB 0x25 /* word32 LSB S + A */ +#define R_IA_64_DIR64MSB 0x26 /* word64 MSB S + A */ +#define R_IA_64_DIR64LSB 0x27 /* word64 LSB S + A */ +#define R_IA_64_GPREL22 0x2a /* immediate22 @gprel(S + A) */ +#define R_IA_64_GPREL64I 0x2b /* immediate64 @gprel(S + A) */ +#define R_IA_64_GPREL32MSB 0x2c /* word32 MSB @gprel(S + A) */ +#define R_IA_64_GPREL32LSB 0x2d /* word32 LSB @gprel(S + A) */ +#define R_IA_64_GPREL64MSB 0x2e /* word64 MSB @gprel(S + A) */ +#define R_IA_64_GPREL64LSB 0x2f /* word64 LSB @gprel(S + A) */ +#define R_IA_64_LTOFF22 0x32 /* immediate22 @ltoff(S + A) */ +#define R_IA_64_LTOFF64I 0x33 /* immediate64 @ltoff(S + A) */ +#define R_IA_64_PLTOFF22 0x3a /* immediate22 @pltoff(S + A) */ +#define R_IA_64_PLTOFF64I 0x3b /* immediate64 @pltoff(S + A) */ +#define R_IA_64_PLTOFF64MSB 0x3e /* word64 MSB @pltoff(S + A) */ +#define R_IA_64_PLTOFF64LSB 0x3f /* word64 LSB @pltoff(S + A) */ +#define R_IA_64_FPTR64I 0x43 /* immediate64 @fptr(S + A) */ +#define R_IA_64_FPTR32MSB 0x44 /* word32 MSB @fptr(S + A) */ +#define R_IA_64_FPTR32LSB 0x45 /* word32 LSB @fptr(S + A) */ +#define R_IA_64_FPTR64MSB 0x46 /* word64 MSB @fptr(S + A) */ +#define R_IA_64_FPTR64LSB 0x47 /* word64 LSB @fptr(S + A) */ +#define R_IA_64_PCREL60B 0x48 /* immediate60 form1 S + A - P */ +#define R_IA_64_PCREL21B 0x49 /* immediate21 form1 S + A - P */ +#define R_IA_64_PCREL21M 0x4a /* immediate21 form2 S + A - P */ +#define R_IA_64_PCREL21F 0x4b /* immediate21 form3 S + A - P */ +#define R_IA_64_PCREL32MSB 0x4c /* word32 MSB S + A - P */ +#define R_IA_64_PCREL32LSB 0x4d /* word32 LSB S + A - P */ +#define R_IA_64_PCREL64MSB 0x4e /* word64 MSB S + A - P */ +#define R_IA_64_PCREL64LSB 0x4f /* word64 LSB S + A - P */ +#define R_IA_64_LTOFF_FPTR22 0x52 /* immediate22 @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64I 0x53 /* immediate64 @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR32MSB 0x54 /* word32 MSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR32LSB 0x55 /* word32 LSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64MSB 0x56 /* word64 MSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_LTOFF_FPTR64LSB 0x57 /* word64 LSB @ltoff(@fptr(S + A)) */ +#define R_IA_64_SEGREL32MSB 0x5c /* word32 MSB @segrel(S + A) */ +#define R_IA_64_SEGREL32LSB 0x5d /* word32 LSB @segrel(S + A) */ +#define R_IA_64_SEGREL64MSB 0x5e /* word64 MSB @segrel(S + A) */ +#define R_IA_64_SEGREL64LSB 0x5f /* word64 LSB @segrel(S + A) */ +#define R_IA_64_SECREL32MSB 0x64 /* word32 MSB @secrel(S + A) */ +#define R_IA_64_SECREL32LSB 0x65 /* word32 LSB @secrel(S + A) */ +#define R_IA_64_SECREL64MSB 0x66 /* word64 MSB @secrel(S + A) */ +#define R_IA_64_SECREL64LSB 0x67 /* word64 LSB @secrel(S + A) */ +#define R_IA_64_REL32MSB 0x6c /* word32 MSB BD + A */ +#define R_IA_64_REL32LSB 0x6d /* word32 LSB BD + A */ +#define R_IA_64_REL64MSB 0x6e /* word64 MSB BD + A */ +#define R_IA_64_REL64LSB 0x6f /* word64 LSB BD + A */ +#define R_IA_64_LTV32MSB 0x74 /* word32 MSB S + A */ +#define R_IA_64_LTV32LSB 0x75 /* word32 LSB S + A */ +#define R_IA_64_LTV64MSB 0x76 /* word64 MSB S + A */ +#define R_IA_64_LTV64LSB 0x77 /* word64 LSB S + A */ +#define R_IA_64_PCREL21BI 0x79 /* immediate21 form1 S + A - P */ +#define R_IA_64_PCREL22 0x7a /* immediate22 S + A - P */ +#define R_IA_64_PCREL64I 0x7b /* immediate64 S + A - P */ +#define R_IA_64_IPLTMSB 0x80 /* function descriptor MSB special */ +#define R_IA_64_IPLTLSB 0x81 /* function descriptor LSB speciaal */ +#define R_IA_64_SUB 0x85 /* immediate64 A - S */ +#define R_IA_64_LTOFF22X 0x86 /* immediate22 special */ +#define R_IA_64_LDXMOV 0x87 /* immediate22 special */ +#define R_IA_64_TPREL14 0x91 /* imm14 @tprel(S + A) */ +#define R_IA_64_TPREL22 0x92 /* imm22 @tprel(S + A) */ +#define R_IA_64_TPREL64I 0x93 /* imm64 @tprel(S + A) */ +#define R_IA_64_TPREL64MSB 0x96 /* word64 MSB @tprel(S + A) */ +#define R_IA_64_TPREL64LSB 0x97 /* word64 LSB @tprel(S + A) */ +#define R_IA_64_LTOFF_TPREL22 0x9a /* imm22 @ltoff(@tprel(S+A)) */ +#define R_IA_64_DTPMOD64MSB 0xa6 /* word64 MSB @dtpmod(S + A) */ +#define R_IA_64_DTPMOD64LSB 0xa7 /* word64 LSB @dtpmod(S + A) */ +#define R_IA_64_LTOFF_DTPMOD22 0xaa /* imm22 @ltoff(@dtpmod(S+A)) */ +#define R_IA_64_DTPREL14 0xb1 /* imm14 @dtprel(S + A) */ +#define R_IA_64_DTPREL22 0xb2 /* imm22 @dtprel(S + A) */ +#define R_IA_64_DTPREL64I 0xb3 /* imm64 @dtprel(S + A) */ +#define R_IA_64_DTPREL32MSB 0xb4 /* word32 MSB @dtprel(S + A) */ +#define R_IA_64_DTPREL32LSB 0xb5 /* word32 LSB @dtprel(S + A) */ +#define R_IA_64_DTPREL64MSB 0xb6 /* word64 MSB @dtprel(S + A) */ +#define R_IA_64_DTPREL64LSB 0xb7 /* word64 LSB @dtprel(S + A) */ +#define R_IA_64_LTOFF_DTPREL22 0xba /* imm22 @ltoff(@dtprel(S+A)) */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ +#define R_MIPS_64 18 /* Direct 64 bit */ +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 /* GOT HI 16 bit */ +#define R_MIPS_GOT_LO16 23 /* GOT LO 16 bit */ +#define R_MIPS_SUB 24 +#define R_MIPS_CALLHI16 30 /* upper 16 bit GOT entry for function */ +#define R_MIPS_CALLLO16 31 /* lower 16 bit GOT entry for function */ +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_GD 42 + +#define R_PPC_NONE 0 /* No relocation. */ +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* + * 64-bit relocations + */ +#define R_PPC64_ADDR64 38 +#define R_PPC64_ADDR16_HIGHER 39 +#define R_PPC64_ADDR16_HIGHERA 40 +#define R_PPC64_ADDR16_HIGHEST 41 +#define R_PPC64_ADDR16_HIGHESTA 42 +#define R_PPC64_UADDR64 43 +#define R_PPC64_REL64 44 +#define R_PPC64_PLT64 45 +#define R_PPC64_PLTREL64 46 +#define R_PPC64_TOC16 47 +#define R_PPC64_TOC16_LO 48 +#define R_PPC64_TOC16_HI 49 +#define R_PPC64_TOC16_HA 50 +#define R_PPC64_TOC 51 +#define R_PPC64_DTPMOD64 68 +#define R_PPC64_TPREL64 73 +#define R_PPC64_DTPREL64 78 + +/* + * TLS relocations + */ +#define R_PPC_TLS 67 +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 + +/* + * The remaining relocs are from the Embedded ELF ABI, and are not in the + * SVR4 ELF ABI. + */ + +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + +/* + * RISC-V relocation types. + */ + +/* Relocation types used by the dynamic linker. */ +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JUMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 + +/* Relocation types not used by the dynamic linker. */ +#define R_RISCV_BRANCH 16 +#define R_RISCV_JAL 17 +#define R_RISCV_CALL 18 +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 +#define R_RISCV_LO12_I 27 +#define R_RISCV_LO12_S 28 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 +#define R_RISCV_GNU_VTENTRY 42 +#define R_RISCV_ALIGN 43 +#define R_RISCV_RVC_BRANCH 44 +#define R_RISCV_RVC_JUMP 45 + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 +#define R_SPARC_DISP64 46 +#define R_SPARC_PLT64 47 +#define R_SPARC_HIX22 48 +#define R_SPARC_LOX10 49 +#define R_SPARC_H44 50 +#define R_SPARC_M44 51 +#define R_SPARC_L44 52 +#define R_SPARC_REGISTER 53 +#define R_SPARC_UA64 54 +#define R_SPARC_UA16 55 +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_X86_64_NONE 0 /* No relocation. */ +#define R_X86_64_64 1 /* Add 64 bit symbol value. */ +#define R_X86_64_PC32 2 /* PC-relative 32 bit signed sym value. */ +#define R_X86_64_GOT32 3 /* PC-relative 32 bit GOT offset. */ +#define R_X86_64_PLT32 4 /* PC-relative 32 bit PLT offset. */ +#define R_X86_64_COPY 5 /* Copy data from shared object. */ +#define R_X86_64_GLOB_DAT 6 /* Set GOT entry to data address. */ +#define R_X86_64_JMP_SLOT 7 /* Set GOT entry to code address. */ +#define R_X86_64_RELATIVE 8 /* Add load address of shared object. */ +#define R_X86_64_GOTPCREL 9 /* Add 32 bit signed pcrel offset to GOT. */ +#define R_X86_64_32 10 /* Add 32 bit zero extended symbol value */ +#define R_X86_64_32S 11 /* Add 32 bit sign extended symbol value */ +#define R_X86_64_16 12 /* Add 16 bit zero extended symbol value */ +#define R_X86_64_PC16 13 /* Add 16 bit signed extended pc relative symbol value */ +#define R_X86_64_8 14 /* Add 8 bit zero extended symbol value */ +#define R_X86_64_PC8 15 /* Add 8 bit signed extended pc relative symbol value */ +#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ +#define R_X86_64_DTPOFF64 17 /* Offset in TLS block */ +#define R_X86_64_TPOFF64 18 /* Offset in static TLS block */ +#define R_X86_64_TLSGD 19 /* PC relative offset to GD GOT entry */ +#define R_X86_64_TLSLD 20 /* PC relative offset to LD GOT entry */ +#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ +#define R_X86_64_GOTTPOFF 22 /* PC relative offset to IE GOT entry */ +#define R_X86_64_TPOFF32 23 /* Offset in static TLS block */ +#define R_X86_64_PC64 24 /* PC-relative 64 bit signed sym value. */ +#define R_X86_64_GOTOFF64 25 +#define R_X86_64_GOTPC32 26 +#define R_X86_64_GOT64 27 +#define R_X86_64_GOTPCREL64 28 +#define R_X86_64_GOTPC64 29 +#define R_X86_64_GOTPLT64 30 +#define R_X86_64_PLTOFF64 31 +#define R_X86_64_SIZE32 32 +#define R_X86_64_SIZE64 33 +#define R_X86_64_GOTPC32_TLSDESC 34 +#define R_X86_64_TLSDESC_CALL 35 +#define R_X86_64_TLSDESC 36 +#define R_X86_64_IRELATIVE 37 + +#endif /* !_SYS_ELF_COMMON_H_ */ diff --git a/sys/include/sys/elf_generic.h b/sys/include/sys/elf_generic.h index a5b89ed..3350856 100644 --- a/sys/include/sys/elf_generic.h +++ b/sys/include/sys/elf_generic.h @@ -1,89 +1,89 @@ -/*- - * Copyright (c) 2002-2018 The UbixOS Project. - * All rights reserved. - * - * This was developed by Christopher W. Olsen for the UbixOS Project. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted - * provided that the following conditions are met: - * - * 1) Redistributions of source code must retain the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors. - * 2) Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions, the following disclaimer and the list of authors in the documentation and/or - * other materials provided with the distribution. - * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to - * endorse or promote products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_ELF_GENERIC_H_ -#define _SYS_ELF_GENERIC_H_ 1 - -#include - -/* - * Definitions of generic ELF names which relieve applications from - * needing to know the word size. - */ - -#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 -#error "__ELF_WORD_SIZE must be defined as 32 or 64" -#endif - -#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define ELF_DATA ELFDATA2LSB -#elif BYTE_ORDER == BIG_ENDIAN -#define ELF_DATA ELFDATA2MSB -#else -#error "Unknown byte order" -#endif - -#define __elfN(x) __CONCAT(__CONCAT(__CONCAT(elf,__ELF_WORD_SIZE),_),x) -#define __ElfN(x) __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) -#define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) -#define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) - -__ElfType(Addr); -__ElfType(Half); -__ElfType(Off); -__ElfType(Sword); -__ElfType(Word); -__ElfType(Ehdr); -__ElfType(Shdr); -__ElfType(Phdr); -__ElfType(Dyn); -__ElfType(Rel); -__ElfType(Rela); -__ElfType(Sym); -__ElfType(Verdef); -__ElfType(Verdaux); -__ElfType(Verneed); -__ElfType(Vernaux); -__ElfType(Versym); - -/* Non-standard ELF types. */ -__ElfType(Hashelt); -__ElfType(Size); -__ElfType(Ssize); - -#define ELF_R_SYM __ELFN(R_SYM) -#define ELF_R_TYPE __ELFN(R_TYPE) -#define ELF_R_INFO __ELFN(R_INFO) -#define ELF_ST_BIND __ELFN(ST_BIND) -#define ELF_ST_TYPE __ELFN(ST_TYPE) -#define ELF_ST_INFO __ELFN(ST_INFO) -#define ELF_ST_VISIBILITY __ELFN(ST_VISIBILITY) - -#endif /* !_SYS_ELF_GENERIC_H_ */ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_ELF_GENERIC_H_ +#define _SYS_ELF_GENERIC_H_ 1 + +#include + +/* + * Definitions of generic ELF names which relieve applications from + * needing to know the word size. + */ + +#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 +#error "__ELF_WORD_SIZE must be defined as 32 or 64" +#endif + +#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define ELF_DATA ELFDATA2LSB +#elif BYTE_ORDER == BIG_ENDIAN +#define ELF_DATA ELFDATA2MSB +#else +#error "Unknown byte order" +#endif + +#define __elfN(x) __CONCAT(__CONCAT(__CONCAT(elf,__ELF_WORD_SIZE),_),x) +#define __ElfN(x) __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) +#define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) +#define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) + +__ElfType(Addr); +__ElfType(Half); +__ElfType(Off); +__ElfType(Sword); +__ElfType(Word); +__ElfType(Ehdr); +__ElfType(Shdr); +__ElfType(Phdr); +__ElfType(Dyn); +__ElfType(Rel); +__ElfType(Rela); +__ElfType(Sym); +__ElfType(Verdef); +__ElfType(Verdaux); +__ElfType(Verneed); +__ElfType(Vernaux); +__ElfType(Versym); + +/* Non-standard ELF types. */ +__ElfType(Hashelt); +__ElfType(Size); +__ElfType(Ssize); + +#define ELF_R_SYM __ELFN(R_SYM) +#define ELF_R_TYPE __ELFN(R_TYPE) +#define ELF_R_INFO __ELFN(R_INFO) +#define ELF_ST_BIND __ELFN(ST_BIND) +#define ELF_ST_TYPE __ELFN(ST_TYPE) +#define ELF_ST_INFO __ELFN(ST_INFO) +#define ELF_ST_VISIBILITY __ELFN(ST_VISIBILITY) + +#endif /* !_SYS_ELF_GENERIC_H_ */ diff --git a/sys/include/sys/idt.h b/sys/include/sys/idt.h new file mode 100644 index 0000000..e5c114a --- /dev/null +++ b/sys/include/sys/idt.h @@ -0,0 +1,47 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _IDT_H +#define _IDT_H + +#include +#include + +#define EFLAG_TF 0x100 +#define EFLAG_IF 0x200 +#define EFLAG_IOPL3 0x3000 +#define EFLAG_VM 0x20000 + +int idt_init(); +void setVector(void *handler, unsigned char interrupt, unsigned short controlMajor); +void setTaskVector(uInt8 interrupt, uInt16 controlMajor, uInt8 selector); + + +void timerInt(); + +#endif diff --git a/sys/include/sys/io.h b/sys/include/sys/io.h new file mode 100644 index 0000000..9d118d7 --- /dev/null +++ b/sys/include/sys/io.h @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _IO_H_ +#define _IO_H_ + +unsigned char inportByte(unsigned int); +unsigned short inportWord(unsigned int); +unsigned long inportDWord(unsigned int); + +void outportByte(unsigned int, unsigned char); +void outportByteP(unsigned int port, unsigned char value); +void outportWord(unsigned int, unsigned short); +void outportDWord(unsigned int port, unsigned long value); + +#endif + +/*** + $Log: io.h,v $ + Revision 1.1.1.1 2006/06/01 12:46:15 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:37 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:52 reddawg + no message + + Revision 1.3 2004/07/22 20:14:34 reddawg + still working here + + Revision 1.2 2004/05/21 15:12:17 reddawg + Cleaned up + + + END + ***/ diff --git a/sys/include/sys/kern_sysctl.h b/sys/include/sys/kern_sysctl.h new file mode 100644 index 0000000..9aeb258 --- /dev/null +++ b/sys/include/sys/kern_sysctl.h @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_KERN_SYSCTL_H +#define _SYS_KERN_SYSCTL_H + +#include +#include + +#define CTL_MAXNAME 24 /* largest number of components supported */ + +/* + * Top-level identifiers + */ +#define CTL_UNSPEC 0 /* unused */ +#define CTL_KERN 1 /* "high kernel": proc, limits */ +#define CTL_VM 2 /* virtual memory */ +#define CTL_VFS 3 /* filesystem, mount type is next */ +#define CTL_NET 4 /* network, see socket.h */ +#define CTL_DEBUG 5 /* debugging parameters */ +#define CTL_HW 6 /* generic cpu/io */ +#define CTL_MACHDEP 7 /* machine dependent */ +#define CTL_USER 8 /* user-level */ +#define CTL_P1003_1B 9 /* POSIX 1003.1B */ +#define CTL_UBIX 10 /* ubixos */ + +#define CTL_KERN_OPENFILES 1 /* kernel openfiles */ + +#define EINVAL -1 /* */ + +struct sysctl_entry { + struct sysctl_entry *prev; + struct sysctl_entry *next; + struct sysctl_entry *children; + char name[32]; + int id; + void *value; + int val_len; + }; + +int kern_sysctl(int *name,u_int namelen,void *old,size_t *oldlenp,void *new,size_t newlen,size_t *retval,int flags); +int sysctl_add(int *,int,char *,void *,int); +int sysctl_init(); + +extern bool sysctl_enabled; +#endif /* END _SYS_KERN_SYSCTL_H */ diff --git a/sys/include/sys/select.h b/sys/include/sys/select.h new file mode 100644 index 0000000..ce0d6e9 --- /dev/null +++ b/sys/include/sys/select.h @@ -0,0 +1,100 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H + +#include +#include +#include +#include + +#include + +typedef unsigned long __fd_mask; +typedef __fd_mask fd_mask; + +#ifndef _SIGSET_T_DECLARED +#define _SIGSET_T_DECLARED +typedef __sigset_t sigset_t; +#endif + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 1024 +#endif + +#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */ +#define NFDBITS _NFDBITS + +#ifndef _howmany +#define _howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif + +typedef struct fd_set { + __fd_mask __fds_bits [_howmany(FD_SETSIZE, _NFDBITS)]; +} fd_set; + +#define fds_bits __fds_bits + +#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) +#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) +#define FD_COPY(f, t) (void)(*(t) = *(f)) +#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) +#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) +#define FD_ZERO(p) do { \ + fd_set *_p; \ + __size_t _n; \ + \ + _p = (p); \ + _n = _howmany(FD_SETSIZE, _NFDBITS); \ + while (_n > 0) \ + _p->__fds_bits[--_n] = 0; \ +} while (0) + +#ifndef _KERNEL + +__BEGIN_DECLS +int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict); + +#ifndef _SELECT_DECLARED +#define _SELECT_DECLARED +/* XXX missing restrict type-qualifier */ +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#endif +__END_DECLS +#endif /* !_KERNEL */ + + + +#endif /* END _SYS_SELECT_H */ diff --git a/sys/include/sys/signal.h b/sys/include/sys/signal.h new file mode 100644 index 0000000..0ffe9b8 --- /dev/null +++ b/sys/include/sys/signal.h @@ -0,0 +1,105 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_SIGNAL_H +#define _SYS_SIGNAL_H + +#include + +#define _SIG_WORDS 4 +#define _SIG_MAXSIG 128 +#define _SIG_IDX(sig) ((sig) - 1) +#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) +#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) +#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) + +// Flags for sigprocmask: +#define SIG_BLOCK 1 /* block specified signal set */ +#define SIG_UNBLOCK 2 /* unblock specified signal set */ +#define SIG_SETMASK 3 /* set specified signal set */ + +union sigval { + /* Members as suggested by Annex C of POSIX 1003.1b. */ + int sival_int; + void *sival_ptr; + /* 6.0 compatibility */ + int sigval_int; + void *sigval_ptr; +}; + +typedef struct __siginfo { + int si_signo; /* signal number */ + int si_errno; /* errno association */ + /* + * Cause of signal, one of the SI_ macros or signal-specific + * values, i.e. one of the FPE_... values for SIGFPE. This + * value is equivalent to the second argument to an old-style + * FreeBSD signal handler. + */ + int si_code; /* signal code */ + __pid_t si_pid; /* sending process */ + __uid_t si_uid; /* sender's ruid */ + int si_status; /* exit value */ + void *si_addr; /* faulting instruction */ + union sigval si_value; /* signal value */ + union { + struct { + int _trapno;/* machine specific trap code */ + } _fault; + struct { + int _timerid; + int _overrun; + } _timer; + struct { + int _mqd; + } _mesgq; + struct { + long _band; /* band event for SIGPOLL */ + } _poll; /* was this ever used ? */ + struct { + long __spare1__; + int __spare2__[7]; + } __spare__; + } _reason; +} siginfo_t; + + +// Signal vector "template" used in sigaction call. +struct sigaction { + union { + void (*__sa_handler)(int); + void (*__sa_sigaction)(int, struct __siginfo *, void *); + } __sigaction_u; /* signal handler */ + int sa_flags; /* see signal options below */ + sigset_t sa_mask; /* signal mask to apply */ +}; + +#define sa_handler __sigaction_u.__sa_handler +#define sa_sigaction __sigaction_u.__sa_sigaction + +#endif /* END _SYS_SIGNAL_H */ diff --git a/sys/include/sys/stdatomic.h b/sys/include/sys/stdatomic.h new file mode 100644 index 0000000..11f09a9 --- /dev/null +++ b/sys/include/sys/stdatomic.h @@ -0,0 +1,411 @@ +/*- + * Copyright (c) 2011 Ed Schouten + * David Chisnall + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: releng/11.1/sys/sys/stdatomic.h 263998 2014-04-01 14:46:11Z tijl $ + */ + +#ifndef _STDATOMIC_H_ +#define _STDATOMIC_H_ + +#include +#include + +#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#define __CLANG_ATOMICS +#elif __GNUC_PREREQ__(4, 7) +#define __GNUC_ATOMICS +#elif defined(__GNUC__) +#define __SYNC_ATOMICS +#else +#error "stdatomic.h does not support your compiler" +#endif + +/* + * 7.17.1 Atomic lock-free macros. + */ + +#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/* + * 7.17.2 Initialization. + */ + +#if defined(__CLANG_ATOMICS) +#define ATOMIC_VAR_INIT(value) (value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) +#else +#define ATOMIC_VAR_INIT(value) { .__val = (value) } +#define atomic_init(obj, value) ((void)((obj)->__val = (value))) +#endif + +/* + * Clang and recent GCC both provide predefined macros for the memory + * orderings. If we are using a compiler that doesn't define them, use the + * clang values - these will be ignored in the fallback path. + */ + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + +/* + * 7.17.3 Order and consistency. + * + * The memory_order_* constants that denote the barrier behaviour of the + * atomic operations. + */ + +typedef enum { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +/* + * 7.17.4 Fences. + */ + +static __inline void +atomic_thread_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_thread_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_thread_fence(__order); +#else + __sync_synchronize(); +#endif +} + +static __inline void +atomic_signal_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_signal_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_signal_fence(__order); +#else + __asm volatile ("" ::: "memory"); +#endif +} + +/* + * 7.17.5 Lock-free property. + */ + +#if defined(_KERNEL) +/* Atomics in kernelspace are always lock-free. */ +#define atomic_is_lock_free(obj) \ + ((void)(obj), (_Bool)1) +#elif defined(__CLANG_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof(*(obj)), obj) +#elif defined(__GNUC_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) +#else +#define atomic_is_lock_free(obj) \ + ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) +#endif + +/* + * 7.17.6 Atomic integer types. + */ + +typedef _Atomic(_Bool) atomic_bool; +typedef _Atomic(char) atomic_char; +typedef _Atomic(signed char) atomic_schar; +typedef _Atomic(unsigned char) atomic_uchar; +typedef _Atomic(short) atomic_short; +typedef _Atomic(unsigned short) atomic_ushort; +typedef _Atomic(int) atomic_int; +typedef _Atomic(unsigned int) atomic_uint; +typedef _Atomic(long) atomic_long; +typedef _Atomic(unsigned long) atomic_ulong; +typedef _Atomic(long long) atomic_llong; +typedef _Atomic(unsigned long long) atomic_ullong; +typedef _Atomic(__char16_t) atomic_char16_t; +typedef _Atomic(__char32_t) atomic_char32_t; +typedef _Atomic(___wchar_t) atomic_wchar_t; +typedef _Atomic(__int_least8_t) atomic_int_least8_t; +typedef _Atomic(__uint_least8_t) atomic_uint_least8_t; +typedef _Atomic(__int_least16_t) atomic_int_least16_t; +typedef _Atomic(__uint_least16_t) atomic_uint_least16_t; +typedef _Atomic(__int_least32_t) atomic_int_least32_t; +typedef _Atomic(__uint_least32_t) atomic_uint_least32_t; +typedef _Atomic(__int_least64_t) atomic_int_least64_t; +typedef _Atomic(__uint_least64_t) atomic_uint_least64_t; +typedef _Atomic(__int_fast8_t) atomic_int_fast8_t; +typedef _Atomic(__uint_fast8_t) atomic_uint_fast8_t; +typedef _Atomic(__int_fast16_t) atomic_int_fast16_t; +typedef _Atomic(__uint_fast16_t) atomic_uint_fast16_t; +typedef _Atomic(__int_fast32_t) atomic_int_fast32_t; +typedef _Atomic(__uint_fast32_t) atomic_uint_fast32_t; +typedef _Atomic(__int_fast64_t) atomic_int_fast64_t; +typedef _Atomic(__uint_fast64_t) atomic_uint_fast64_t; +typedef _Atomic(__intptr_t) atomic_intptr_t; +typedef _Atomic(__uintptr_t) atomic_uintptr_t; +typedef _Atomic(__size_t) atomic_size_t; +typedef _Atomic(__ptrdiff_t) atomic_ptrdiff_t; +typedef _Atomic(__intmax_t) atomic_intmax_t; +typedef _Atomic(__uintmax_t) atomic_uintmax_t; + +/* + * 7.17.7 Operations on atomic types. + */ + +/* + * Compiler-specific operations. + */ + +#if defined(__CLANG_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ + success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ + success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __c11_atomic_exchange(object, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __c11_atomic_fetch_add(object, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __c11_atomic_fetch_and(object, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __c11_atomic_fetch_or(object, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __c11_atomic_fetch_sub(object, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __c11_atomic_fetch_xor(object, operand, order) +#define atomic_load_explicit(object, order) \ + __c11_atomic_load(object, order) +#define atomic_store_explicit(object, desired, order) \ + __c11_atomic_store(object, desired, order) +#elif defined(__GNUC_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 0, success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 1, success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __atomic_exchange_n(&(object)->__val, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __atomic_fetch_add(&(object)->__val, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __atomic_fetch_and(&(object)->__val, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __atomic_fetch_or(&(object)->__val, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __atomic_fetch_sub(&(object)->__val, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __atomic_fetch_xor(&(object)->__val, operand, order) +#define atomic_load_explicit(object, order) \ + __atomic_load_n(&(object)->__val, order) +#define atomic_store_explicit(object, desired, order) \ + __atomic_store_n(&(object)->__val, desired, order) +#else +#define __atomic_apply_stride(object, operand) \ + (((__typeof__((object)->__val))0) + (operand)) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) __extension__ ({ \ + __typeof__(expected) __ep = (expected); \ + __typeof__(*__ep) __e = *__ep; \ + (void)(success); (void)(failure); \ + (_Bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ + __e, desired)) == __e); \ +}) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) +#if __has_builtin(__sync_swap) +/* Clang provides a full-barrier atomic exchange - use it if available. */ +#define atomic_exchange_explicit(object, desired, order) \ + ((void)(order), __sync_swap(&(object)->__val, desired)) +#else +/* + * __sync_lock_test_and_set() is only an acquire barrier in theory (although in + * practice it is usually a full barrier) so we need an explicit barrier before + * it. + */ +#define atomic_exchange_explicit(object, desired, order) \ +__extension__ ({ \ + __typeof__(object) __o = (object); \ + __typeof__(desired) __d = (desired); \ + (void)(order); \ + __sync_synchronize(); \ + __sync_lock_test_and_set(&(__o)->__val, __d); \ +}) +#endif +#define atomic_fetch_add_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_and_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) +#define atomic_fetch_or_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) +#define atomic_fetch_sub_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_xor_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) +#define atomic_load_explicit(object, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) +#define atomic_store_explicit(object, desired, order) \ + ((void)atomic_exchange_explicit(object, desired, order)) +#endif + +/* + * Convenience functions. + * + * Don't provide these in kernel space. In kernel space, we should be + * disciplined enough to always provide explicit barriers. + */ + +#ifndef _KERNEL +#define atomic_compare_exchange_strong(object, expected, desired) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_weak_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_exchange(object, desired) \ + atomic_exchange_explicit(object, desired, memory_order_seq_cst) +#define atomic_fetch_add(object, operand) \ + atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_and(object, operand) \ + atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_or(object, operand) \ + atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_sub(object, operand) \ + atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_xor(object, operand) \ + atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) +#define atomic_load(object) \ + atomic_load_explicit(object, memory_order_seq_cst) +#define atomic_store(object, desired) \ + atomic_store_explicit(object, desired, memory_order_seq_cst) +#endif /* !_KERNEL */ + +/* + * 7.17.8 Atomic flag type and operations. + * + * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some + * kind of compiler built-in type we could use? + */ + +typedef struct { + atomic_bool __flag; +} atomic_flag; + +#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } + +static __inline _Bool +atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, + memory_order __order) +{ + return (atomic_exchange_explicit(&__object->__flag, 1, __order)); +} + +static __inline void +atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) +{ + + atomic_store_explicit(&__object->__flag, 0, __order); +} + +#ifndef _KERNEL +static __inline _Bool +atomic_flag_test_and_set(volatile atomic_flag *__object) +{ + + return (atomic_flag_test_and_set_explicit(__object, + memory_order_seq_cst)); +} + +static __inline void +atomic_flag_clear(volatile atomic_flag *__object) +{ + + atomic_flag_clear_explicit(__object, memory_order_seq_cst); +} +#endif /* !_KERNEL */ + +#endif /* !_STDATOMIC_H_ */ diff --git a/sys/include/sys/sysproto.h b/sys/include/sys/sysproto.h new file mode 100644 index 0000000..678756a --- /dev/null +++ b/sys/include/sys/sysproto.h @@ -0,0 +1,97 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_SYSPROTO_H +#define _SYS_SYSPROTO_H + +#include + +typedef int register_t; + +#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? 0 : sizeof(register_t) - sizeof(t)) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define PADL_(t) 0 +#define PADR_(t) PAD_(t) +#else +#define PADL_(t) PAD_(t) +#define PADR_(t) 0 +#endif + +//Protos +struct sys_mpiCreateMbox_args { + char name_l_[PADL_(char *)]; + char *name; + char name_r_[PADR_(char *)]; +}; + +struct sys_mpiDestroyMbox_args { + char name_l_[PADL_(char *)]; + char *name; + char name_r_[PADR_(char *)]; +}; + +struct sys_mpiFetchMessage_args { + char name_l_[PADL_(char *)]; + char *name; + char name_r_[PADR_(char *)]; + char msg_l_[PADL_(const void *)]; + const void * msg; + char msg_r_[PADR_(const void *)]; +}; + +struct sys_mpiPostMessage_args { + char name_l_[PADL_(char *)]; + char *name; + char name_r_[PADR_(char *)]; + char type_l_[PADL_(uint32_t)]; + uint32_t type; + char type_r_[PADR_(uint32_t)]; + char msg_l_[PADL_(const void *)]; + const void *msg; + char msg_r_[PADR_(const void *)]; +}; + +struct sys_sde_args { + char cmd_l_[PADL_(uint32_t)]; + uint32_t cmd; + char cmd_r_[PADR_(uint32_t)]; + char ptr_l_[PADL_(uint32_t)]; + uint32_t ptr; + char ptr_r_[PADR_(uint32_t)]; +}; + + +//Func Defs +int sys_invalid(struct thread *, void *); +int sys_mpiCreateMbox(struct thread *, struct sys_mpiCreateMbox_args *); +int sys_mpiDestroyMbox(struct thread *, struct sys_mpiDestroyMbox_args *); +int sys_mpiFetchMessage(struct thread *, struct sys_mpiFetchMessage_args *); +int sys_mpiPostMessage(struct thread *, struct sys_mpiPostMessage_args *); + +#endif diff --git a/sys/include/sys/tss.h b/sys/include/sys/tss.h new file mode 100644 index 0000000..c4d7379 --- /dev/null +++ b/sys/include/sys/tss.h @@ -0,0 +1,109 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_TSS_H +#define _SYS_TSS_H + +#include + +struct tssStruct { + short back_link; + short back_link_reserved; + long esp0; + short ss0; + short ss0_reserved; + long esp1; + short ss1; + short ss1_reserved; + long esp2; + short ss2; + short ss2_reserved; + long cr3; + long eip; + long eflags; + long eax, ecx, edx, ebx; + long esp; + long ebp; + long esi; + long edi; + short es; + short es_reserved; + short cs; + short cs_reserved; + short ss; + short ss_reserved; + short ds; + short ds_reserved; + short fs; + short fs_reserved; + short gs; + short gs_reserved; + short ldt; + short ldt_reserved; + short trace_bitmap; + short io_map; + char io_space[8192]; +}; + +struct i387Struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct i386_frame { + uint32_t gs; + uint32_t fs; + uint32_t es; + uint32_t ds; + uint32_t ss; + uint32_t edi; + uint32_t esi; + uint32_t ebp; + uint32_t esp; + uint32_t ebx; + uint32_t edx; + uint32_t ecx; + uint32_t eax; + /* + uint32_t vector; + uint32_t error_code; + */ + uint32_t eip; + uint32_t cs; + uint32_t flags; + uint32_t user_esp; + uint32_t user_ss; +}; + +#endif /* END _SYS_TSS_H */ diff --git a/sys/include/sys/video.h b/sys/include/sys/video.h new file mode 100644 index 0000000..5d940cf --- /dev/null +++ b/sys/include/sys/video.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_VIDEO_H +#define _SYS_VIDEO_H + +#include + +#define defaultColor 0x0F + +extern int printColor; + +void clearScreen(); +void kprint(char *string); +void backSpace(); + +#endif /* END _SYS_VIDEO_H */ diff --git a/sys/include/ubixfs/dirCache.h b/sys/include/ubixfs/dirCache.h new file mode 100644 index 0000000..710904c --- /dev/null +++ b/sys/include/ubixfs/dirCache.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXFS_DIRCACHE_H +#define _UBIXFS_DIRCACHE_H + +/* #include "ubixfs.h" */ +#include + +struct cacheNode { + char * name; + struct cacheNode * prev; + struct cacheNode * next; + struct cacheNode * parent; + struct cacheNode * fileListHead; + struct cacheNode * fileListTail; + void * info; + int * size; + int present; + int dirty; + uInt32 * startCluster; + uInt16 * attributes; + uInt16 * permissions; +}; +/* cacheNode */ + +struct cacheNode * ubixfs_cacheFind(struct cacheNode *, char *); +struct cacheNode * ubixfs_cacheNew(const char *); +void ubixfs_cacheDelete(struct cacheNode **); +struct cacheNode * ubixfs_cacheAdd(struct cacheNode *, struct cacheNode *); + +#endif /* END _UBIXFS_DIRCACHE_H */ diff --git a/sys/include/ubixfs/ubixfs.h b/sys/include/ubixfs/ubixfs.h new file mode 100644 index 0000000..877c9cb --- /dev/null +++ b/sys/include/ubixfs/ubixfs.h @@ -0,0 +1,154 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXFS_UBIXFS_H +#define _UBIXFS_UBIXFS_H + +#include +#include +#include +#include +#include + +#define UBIXFS_BLOCKSIZE_BYTES blockSize*512 +#define UBIXFS_ALIGN(size) (size + ((((size) % (UBIXFS_BLOCKSIZE_BYTES)) == 0)? 0 : ((UBIXFS_BLOCKSIZE_BYTES) - ((size) % (UBIXFS_BLOCKSIZE_BYTES))))) + +#define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */ +#define MAXUBIXPARTITIONS 16 +#define blockSize 8 + +#define EOBC -1 + +#define typeFile 1 +#define typeContainer 2 +#define typeDirectory 4 +#define typeDeleted 8 + +/* Start */ +struct directoryList { + char dirName[256]; + char *dirCache; + uInt32 dirBlock; + struct directoryList *next; + struct directoryList *prev; +}; + +typedef struct directoryList * dirList_t; + +dirList_t ubixFSLoadDir(char *); +/* End */ + +//Partition Information +struct ubixDiskLabel { + uInt32 magicNum; + uInt32 magicNum2; + uInt16 driveType; + uInt16 numPartitions; + struct ubixPartitions { //the partition table + uInt32 pSize; //number of sectors in partition + uInt32 pOffset; //starting sector + uInt32 pFsSize; //filesystem basic fragment size + uInt32 pBatSize; //BAT size + uInt8 pFsType; //filesystem type, see below + uInt8 pFrag; //filesystem fragments per block + } partitions[MAXUBIXPARTITIONS]; +}; + +struct partitionInformation { + uInt32 size; //Size In Sectors + uInt32 startSector; //Base Sector Of Partition + uInt32 blockAllocationTable; //Base Sector Of BAT + uInt32 rootDirectory; //Base Sector Of Root Directory +}; + +//Block Allocation Table Entry +struct blockAllocationTableEntry { + long attributes; //Block Attributes + long realSector; //Real Sector + long nextBlock; //Sector Of Next Block + long reserved; //Reserved +}; + +//UbixFS Directory Entry +struct directoryEntry { + uInt32 startCluster; //Starting Cluster Of File + uInt32 size; //Size Of File + uInt32 creationDate; //Date Created + uInt32 lastModified; //Date Last Modified + uInt32 uid; //UID Of Owner + uInt32 gid; //GID Of Owner + uInt16 attributes; //Files Attributes + uInt16 permissions; //Files Permissions + char fileName[256]; //File Name +}; + +struct bootSect { + uInt8 jmp[4]; + uInt8 id[6]; + uInt16 version; + uInt16 tmp; + uInt16 fsStart; + uInt16 tmp2; + uInt32 krnl_start; + uInt BytesPerSector; + uInt SectersPerTrack; + uInt TotalHeads; + uInt32 TotalSectors; + uInt8 code[479]; +}; + +struct ubixFSInfo { + struct blockAllocationTableEntry *blockAllocationTable; + struct cacheNode * dirCache; + uInt32 batEntries; + uInt32 rootDir; +}; +/* ubixFSInfo */ + +int readFile(char *file); +int writeFileByte(int ch, fileDescriptor_t *fd, long offset); +//int openFileUbixFS(char *file,fileDescriptor_t *fd); +int getFreeBlocks(int count, fileDescriptor_t *fd); +//extern struct ubixDiskLabel *diskLabel; + +//Good Functions +//void initUbixFS(struct mountPoints *mp); + +int readUbixFS(fileDescriptor_t *fd, char *data, uInt32, long size); +int writeUbixFS(fileDescriptor_t *fd, char *data, long offset, long size); +void syncBat(struct vfs_mountPoint *mp); +int freeBlocks(int block, fileDescriptor_t *fd); +int addDirEntry(struct directoryEntry *dir, fileDescriptor_t *fd); +void ubixFSUnlink(char *path, struct vfs_mountPoint *mp); +int ubixFSmkDir(char *dir, fileDescriptor_t *fd); + +int ubixfs_init(); +int ubixfs_initialize(); +void ubixfs_thread(); + +#endif /* END _UBIXFS_UBIXFS_H */ diff --git a/sys/include/ubixos/access.h b/sys/include/ubixos/access.h new file mode 100644 index 0000000..773102a --- /dev/null +++ b/sys/include/ubixos/access.h @@ -0,0 +1,49 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_ACCESS_H +#define _UBIXOS_ACCESS_H + +#include + +struct sys_setUID_args { + uint32_t uid; +}; + +struct sys_setGID_args { + uint32_t gid; +}; + +int sys_getUID(struct thread *, void *); +int sys_getEUID(struct thread *, void *); +int sys_setUID(struct thread *, struct sys_setUID_args *); + +int sys_getGID(struct thread *, void *); +int sys_setGID(struct thread *, struct sys_setGID_args *); + +#endif /* END _UBIXOS_ACCESS_H */ diff --git a/sys/include/ubixos/fork.h b/sys/include/ubixos/fork.h new file mode 100644 index 0000000..ad66125 --- /dev/null +++ b/sys/include/ubixos/fork.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_FORK_H +#define _UBIXOS_FORK_H + +#include +#include + +//void sysFork(); +int sysFork(struct thread *, void *); + +#endif /* END _UBIXOS_FORK_H */ diff --git a/sys/include/ubixos/init.h b/sys/include/ubixos/init.h new file mode 100644 index 0000000..e837858 --- /dev/null +++ b/sys/include/ubixos/init.h @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_INIT_H +#define _UBIXOS_INIT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef int (*intFunctionPTR)(void); + +intFunctionPTR init_tasks[] = { static_constructors, i8259_init, idt_init, vitals_init, sysctl_init, vfs_init, sched_init, pit_init, atkbd_init, time_init, pci_init, devfs_init, tty_init, ufs_init, initHardDisk, initLNC, net_init }; + +//ne2k_init, +//ubixfs_init, +//fdc_init, + +int init_tasksTotal = sizeof(init_tasks) / sizeof(intFunctionPTR); + +#endif /* END _UBIXOS_INIT_H */ diff --git a/sys/include/ubixos/kmod.h b/sys/include/ubixos/kmod.h new file mode 100644 index 0000000..39a3660 --- /dev/null +++ b/sys/include/ubixos/kmod.h @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_KMOD_H +#define _UBIXOS_KMOD_H + +#include + +#define LD_START 0x1000000 + +typedef struct kmod_struct { + struct kmod_struct *next; + struct kmod_struct *prev; + uInt16 id; + uInt16 refs; + uInt32 address; + char name[128]; +} kmod_t; + +uInt32 kmod_load(const char *); +uInt32 kmod_add(const char *, const char *name); + +#endif diff --git a/sys/include/ubixos/ld.h b/sys/include/ubixos/ld.h new file mode 100644 index 0000000..2790ec4 --- /dev/null +++ b/sys/include/ubixos/ld.h @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_LD_H +#define _UBIXOS_LD_H + +#include + +#define LD_START 0xAAA00000 //0x1000000 + +uInt32 ldEnable(); + +#endif /* END _UBIXOS_LD_H */ diff --git a/sys/include/ubixos/sched.h b/sys/include/ubixos/sched.h new file mode 100644 index 0000000..3388bec --- /dev/null +++ b/sys/include/ubixos/sched.h @@ -0,0 +1,113 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_SCHED_H +#define _UBIXOS_SCHED_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include +#include + +#define NO_GROUP -1 +#define NR_GROUPS 32 + +typedef enum { + PLACEHOLDER = -2, DEAD = -1, NEW = 0, READY = 1, RUNNING = 2, IDLE = 3, FORK = 4, WAIT = 5, UNINTERRUPTIBLE = 6, INTERRUPTIBLE = 7 +} tState; + +struct osInfo { + uInt8 timer; + uInt8 v86Task; + bool v86If; + uInt32 vmStart; + uInt32 stdinSize; + uInt32 controlKeys; + char *stdin; + char cwd[1024]; /* current working dir */ + uint8_t gpf; +}; + +typedef struct taskStruct { + pidType id; + char name[256]; + struct taskStruct *prev; + struct taskStruct *next; + struct tssStruct tss; + struct i387Struct i387; + struct osInfo oInfo; + //fileDescriptor *imageFd; + fileDescriptor_t *files[MAX_OFILES]; + tState state; + uint32_t uid, gid; + uint16_t euid, suid; + uint16_t egid, sgid; + uInt16 usedMath; + tty_term *term; + struct thread td; + struct { + struct inode *pwd; + struct inode *root; + struct inode *exec; + } inodes; + uint32_t counter; + uint16_t groups[NR_GROUPS]; + pidType ppid; + uint32_t pgrp; + uint32_t children; // Hack for WAIT + uint32_t last_exit; // Hack For WAIT + struct taskStruct *parent; +} kTask_t; + +int sched_init(); +int sched_setStatus(pidType, tState); +int sched_deleteTask(pidType); +int sched_addDelTask(kTask_t *); +kTask_t *sched_getDelTask(); +void sched_yield(); +void sched(); + +void schedEndTask(pidType pid); +kTask_t *schedNewTask(); +kTask_t *schedFindTask(uInt32 id); + +extern kTask_t *_current; +extern kTask_t *_usedMath; + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/sys/include/ubixos/sem.h b/sys/include/ubixos/sem.h new file mode 100644 index 0000000..7afd3de --- /dev/null +++ b/sys/include/ubixos/sem.h @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_SEM_H +#define _UBIXOS_SEM_H + +#include +#include +#include + +struct sys_sem { + uint32_t signaled; + ubthread_cond_t cond; + ubthread_mutex_t mutex; +}; + +typedef struct sys_sem sys_sem_t; + +typedef uint32_t semID_t; +struct timespec; + +int sem_close(semID_t id); +int sem_post(semID_t id); +int sem_wait(semID_t id); +int sem_trywait(semID_t id); +int sem_timedwait(semID_t id, const struct timespec *); +int sem_init(sys_sem_t **, uint8_t); +int sem_open(semID_t *id, const char *name, int oflag, mode_t mode, unsigned int value); +int sem_unlink(const char *name); +int sem_getvalue(semID_t id, int *val); +int sem_destroy(sys_sem_t **); + +#endif /* END _UBIXOS_SEM_H */ diff --git a/sys/include/ubixos/syscall.h b/sys/include/ubixos/syscall.h new file mode 100644 index 0000000..e824415 --- /dev/null +++ b/sys/include/ubixos/syscall.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_SYSCALL_H +#define _UBIXOS_SYSCALL_H + +#include + +void _sys_call(); +void sys_call(struct trapframe *frame); +int invalidCall(); +void invalidCallINT(int); + +#endif diff --git a/sys/include/ubixos/syscall_posix.h b/sys/include/ubixos/syscall_posix.h new file mode 100644 index 0000000..65b2f09 --- /dev/null +++ b/sys/include/ubixos/syscall_posix.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_SYSCALL_POSIX_H +#define _UBIXOS_SYSCALL_POSIX_H + +#include + +void _sys_call_posix(); +void sys_call_posix(struct trapframe *frame); + +#endif diff --git a/sys/include/ubixos/time.h b/sys/include/ubixos/time.h new file mode 100644 index 0000000..d9ab30d --- /dev/null +++ b/sys/include/ubixos/time.h @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_TIME_H +#define _UBIXOS_TIME_H + +#include +#include +#include + +typedef long suseconds_t; + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +#define MINUTE 60 +#define HOUR (60*MINUTE) +#define DAY (24*HOUR) +#define YEAR (365*DAY) + + +struct timeStruct { + int sec; + int min; + int hour; + int day; + int mon; + int year; +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +int gettimeofday(struct timeval *tp, struct timezone *tzp); + +int time_init(); +uInt32 timeMake(struct timeStruct *time); + +#endif + +/*** + $Log: time.h,v $ + Revision 1.1.1.1 2006/06/01 12:46:14 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:37 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:56 reddawg + no message + + Revision 1.4 2004/07/09 13:37:30 reddawg + time: timeInit to time_init + Adjusted initialization routines + + Revision 1.3 2004/06/29 11:41:44 reddawg + Fixed some global variables + + Revision 1.2 2004/05/21 15:20:00 reddawg + Cleaned up + + END + ***/ diff --git a/sys/include/ubixos/times.h b/sys/include/ubixos/times.h new file mode 100644 index 0000000..eb575b1 --- /dev/null +++ b/sys/include/ubixos/times.h @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _TIMES_H +#define _TIMES_H + +#include + +#ifndef _CLOCK_T_DECLARED +typedef __clock_t clock_t; +#define _CLOCK_T_DECLARED +#endif + +struct tms { + clock_t tms_utime; /* User CPU time */ + clock_t tms_stime; /* System CPU time */ + clock_t tms_cutime; /* User CPU time of terminated child procs */ + clock_t tms_cstime; /* System CPU time of terminated child procs */ +}; + +#endif + +/*** + $Log: times.h,v $ + Revision 1.1.1.1 2006/06/01 12:46:14 reddawg + ubix2 + + Revision 1.2 2005/10/12 00:13:37 reddawg + Removed + + Revision 1.1.1.1 2005/09/26 17:23:57 reddawg + no message + + Revision 1.2 2004/05/21 15:20:00 reddawg + Cleaned up + + + END + ***/ diff --git a/sys/include/ubixos/tty.h b/sys/include/ubixos/tty.h new file mode 100644 index 0000000..4389db6 --- /dev/null +++ b/sys/include/ubixos/tty.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_TTY_H +#define _UBIXOS_TTY_H + +#include + +#define TTY_MAX_TERMS 5 + +typedef struct tty_termNode { + char *tty_buffer; + char *tty_pointer; + uint8_t tty_colour; + uint16_t tty_x; + uint16_t tty_y; + pidType owner; + char stdin[512]; + int stdinSize; +} tty_term; + +int tty_init(); +int tty_change(uInt16); +tty_term *tty_find(uInt16); +int tty_print(char *, tty_term *); + +extern tty_term *tty_foreground; + +#endif diff --git a/sys/include/ubixos/ubthread.h b/sys/include/ubixos/ubthread.h new file mode 100644 index 0000000..26a07f4 --- /dev/null +++ b/sys/include/ubixos/ubthread.h @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBTHREAD_H +#define _UBTHREAD_H + +#include +#include +#include + +#define LOCKED 1 +#define UNLOCKED 0 + +typedef struct ubthread *ubthread_t; +typedef struct ubthread_cond *ubthread_cond_t; +typedef struct ubthread_mutex *ubthread_mutex_t; + +struct ubthread { + struct taskStruct *task; +}; + +struct ubthread_cond { + int id; + bool lock; +}; + +struct ubthread_mutex { + int id; + bool lock; + pidType pid; +}; + +struct ubthread_list { + struct ubthread_list *next; + ubthread_t thread; +}; + +struct ubthread_cond_list { + struct ubthread_cond_list *next; + ubthread_cond_t *cond; +}; + +struct ubthread_mutex_list { + struct ubthread_mutex_list *next; + ubthread_mutex_t *mutex; +}; + +struct taskStruct *ubthread_self(); +int ubthread_cond_init(ubthread_cond_t *cond, const uInt32 attr); +int ubthread_mutex_init(ubthread_mutex_t *mutex, const uInt32 attr); +int ubthread_cond_destroy(ubthread_cond_t *cond); +int ubthread_mutex_destroy(ubthread_mutex_t *mutex); +int ubthread_create(struct taskStruct **thread, const uInt32 *attr, void (*tproc)(void), void *arg); +int ubthread_mutex_lock(ubthread_mutex_t *mutex); +int ubthread_mutex_unlock(ubthread_mutex_t *mutex); +int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime); +int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex); +int ubthread_cond_signal(ubthread_cond_t *cond); +int ubthread_cond_broadcast(ubthread_cond_t *cond); + +#endif diff --git a/sys/include/ubixos/uthread.h b/sys/include/ubixos/uthread.h new file mode 100644 index 0000000..ac8b160 --- /dev/null +++ b/sys/include/ubixos/uthread.h @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_UTHREAD_H +#define _UBIXOS_UTHREAD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + struct uthread { + struct uthread *uthread_pointer; + size_t uthread_size; + unsigned long uthread_flags; + void *tls_master_mmap; + size_t tls_master_size; + size_t tls_master_align; + void *tls_mmap; + size_t stack_size; + void *arg_mmap; + size_t arg_size; + size_t __uthread_reserved[4]; + }; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/sys/include/ubixos/vitals.h b/sys/include/ubixos/vitals.h new file mode 100644 index 0000000..8c81915 --- /dev/null +++ b/sys/include/ubixos/vitals.h @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_VITALS_H +#define _UBIXOS_VITALS_H + +#include +#include +#include + +typedef struct vitalsStruct { + uint32_t sysTicks; // 0 - Do Not Change Order + uint32_t sysUptime; // 4 - Do Not Change Order + uint32_t quantum; // 8 - Do Not Change Order + uint32_t dQuantum; // 12 - Do Not Change Order + uint32_t openFiles; + uint32_t lastFD; + uint32_t freePages; + struct fileSystem *fileSystems; + struct vfs_mountPoint *mountPoints; + uint32_t timeStart; + void *screen; + void *font; + char *packet; + uint32_t packetLength; +} vitalsNode; + +extern vitalsNode *systemVitals; +extern spinLock_t vitals_lock; + +int vitals_init(); + +#endif diff --git a/sys/include/ubixos/wait.h b/sys/include/ubixos/wait.h new file mode 100644 index 0000000..9c9f703 --- /dev/null +++ b/sys/include/ubixos/wait.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _UBIXOS_WAIT_H +#define _UBIXOS_WAIT_H + +struct taskStruct; + +struct wait_queue { + struct taskStruct *task; + struct wait_queue *next; +}; + +struct semaphore { + int sount; + struct wait_queue *wait; +}; + +#define sti() __asm__ __volatile__ ("sti": : :"memory") +#define cli() __asm__ __volatile__ ("cli": : :"memory") +#define nop() __asm__ __volatile__ ("nop") + +#define save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=r" (x): /* no input */ :"memory") + +#define restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"r" (x):"memory") + +#endif diff --git a/sys/include/ufs/ffs/fs.h b/sys/include/ufs/ffs/fs.h new file mode 100644 index 0000000..7a50ab5 --- /dev/null +++ b/sys/include/ufs/ffs/fs.h @@ -0,0 +1,778 @@ +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fs.h 8.13 (Berkeley) 3/21/95 + * $FreeBSD: releng/11.1/sys/ufs/ffs/fs.h 298804 2016-04-29 20:43:51Z pfg $ + */ + +#ifndef _UFS_FFS_FS_H_ +#define _UFS_FFS_FS_H_ + +#include +#include + +/* + * Each disk drive contains some number of filesystems. + * A filesystem consists of a number of cylinder groups. + * Each cylinder group has inodes and data. + * + * A filesystem is described by its super-block, which in turn + * describes the cylinder groups. The super-block is critical + * data and is replicated in each cylinder group to protect against + * catastrophic loss. This is done at `newfs' time and the critical + * super-block data does not change, so the copies need not be + * referenced further unless disaster strikes. + * + * For filesystem fs, the offsets of the various blocks of interest + * are given in the super block as: + * [fs->fs_sblkno] Super-block + * [fs->fs_cblkno] Cylinder group block + * [fs->fs_iblkno] Inode blocks + * [fs->fs_dblkno] Data blocks + * The beginning of cylinder group cg in fs, is given by + * the ``cgbase(fs, cg)'' macro. + * + * Depending on the architecture and the media, the superblock may + * reside in any one of four places. For tiny media where every block + * counts, it is placed at the very front of the partition. Historically, + * UFS1 placed it 8K from the front to leave room for the disk label and + * a small bootstrap. For UFS2 it got moved to 64K from the front to leave + * room for the disk label and a bigger bootstrap, and for really piggy + * systems we check at 256K from the front if the first three fail. In + * all cases the size of the superblock will be SBLOCKSIZE. All values are + * given in byte-offset form, so they do not imply a sector size. The + * SBLOCKSEARCH specifies the order in which the locations should be searched. + */ +#define SBLOCK_FLOPPY 0 +#define SBLOCK_UFS1 8192 +#define SBLOCK_UFS2 65536 +#define SBLOCK_PIGGY 262144 +#define SBLOCKSIZE 8192 +#define SBLOCKSEARCH \ + { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } + +/* + * Max number of fragments per block. This value is NOT tweakable. + */ +#define MAXFRAG 8 + +/* + * Addresses stored in inodes are capable of addressing fragments + * of `blocks'. File system blocks of at most size MAXBSIZE can + * be optionally broken into 2, 4, or 8 pieces, each of which is + * addressable; these pieces may be DEV_BSIZE, or some multiple of + * a DEV_BSIZE unit. + * + * Large files consist of exclusively large data blocks. To avoid + * undue wasted disk space, the last data block of a small file may be + * allocated as only as many fragments of a large block as are + * necessary. The filesystem format retains only a single pointer + * to such a fragment, which is a piece of a single large block that + * has been divided. The size of such a fragment is determinable from + * information in the inode, using the ``blksize(fs, ip, lbn)'' macro. + * + * The filesystem records space availability at the fragment level; + * to determine block availability, aligned fragments are examined. + */ + +/* + * MINBSIZE is the smallest allowable block size. + * In order to insure that it is possible to create files of size + * 2^32 with only two levels of indirection, MINBSIZE is set to 4096. + * MINBSIZE must be big enough to hold a cylinder group block, + * thus changes to (struct cg) must keep its size within MINBSIZE. + * Note that super blocks are always of size SBLOCKSIZE, + * and that both SBLOCKSIZE and MAXBSIZE must be >= MINBSIZE. + */ +#define MINBSIZE 4096 + +/* + * The path name on which the filesystem is mounted is maintained + * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in + * the super block for this name. + */ +#define MAXMNTLEN 468 + +/* + * The volume name for this filesystem is maintained in fs_volname. + * MAXVOLLEN defines the length of the buffer allocated. + */ +#define MAXVOLLEN 32 + +/* + * There is a 128-byte region in the superblock reserved for in-core + * pointers to summary information. Originally this included an array + * of pointers to blocks of struct csum; now there are just a few + * pointers and the remaining space is padded with fs_ocsp[]. + * + * NOCSPTRS determines the size of this padding. One pointer (fs_csp) + * is taken away to point to a contiguous array of struct csum for + * all cylinder groups; a second (fs_maxcluster) points to an array + * of cluster sizes that is computed as cylinder groups are inspected, + * and the third points to an array that tracks the creation of new + * directories. A fourth pointer, fs_active, is used when creating + * snapshots; it points to a bitmap of cylinder groups for which the + * free-block bitmap has changed since the snapshot operation began. + */ +#define NOCSPTRS ((128 / sizeof(void *)) - 4) + +/* + * A summary of contiguous blocks of various sizes is maintained + * in each cylinder group. Normally this is set by the initial + * value of fs_maxcontig. To conserve space, a maximum summary size + * is set by FS_MAXCONTIG. + */ +#define FS_MAXCONTIG 16 + +/* + * MINFREE gives the minimum acceptable percentage of filesystem + * blocks which may be free. If the freelist drops below this level + * only the superuser may continue to allocate blocks. This may + * be set to 0 if no reserve of free blocks is deemed necessary, + * however throughput drops by fifty percent if the filesystem + * is run at between 95% and 100% full; thus the minimum default + * value of fs_minfree is 5%. However, to get good clustering + * performance, 10% is a better choice. hence we use 10% as our + * default value. With 10% free space, fragmentation is not a + * problem, so we choose to optimize for time. + */ +#define MINFREE 8 +#define DEFAULTOPT FS_OPTTIME + +/* + * Grigoriy Orlov has done some extensive work to fine + * tune the layout preferences for directories within a filesystem. + * His algorithm can be tuned by adjusting the following parameters + * which tell the system the average file size and the average number + * of files per directory. These defaults are well selected for typical + * filesystems, but may need to be tuned for odd cases like filesystems + * being used for squid caches or news spools. + */ +#define AVFILESIZ 16384 /* expected average file size */ +#define AFPDIR 64 /* expected number of files per directory */ + +/* + * The maximum number of snapshot nodes that can be associated + * with each filesystem. This limit affects only the number of + * snapshot files that can be recorded within the superblock so + * that they can be found when the filesystem is mounted. However, + * maintaining too many will slow the filesystem performance, so + * having this limit is a good idea. + */ +#define FSMAXSNAP 20 + +/* + * Used to identify special blocks in snapshots: + * + * BLK_NOCOPY - A block that was unallocated at the time the snapshot + * was taken, hence does not need to be copied when written. + * BLK_SNAP - A block held by another snapshot that is not needed by this + * snapshot. When the other snapshot is freed, the BLK_SNAP entries + * are converted to BLK_NOCOPY. These are needed to allow fsck to + * identify blocks that are in use by other snapshots (which are + * expunged from this snapshot). + */ +#define BLK_NOCOPY ((ufs2_daddr_t)(1)) +#define BLK_SNAP ((ufs2_daddr_t)(2)) + +/* + * Sysctl values for the fast filesystem. + */ +#define FFS_ADJ_REFCNT 1 /* adjust inode reference count */ +#define FFS_ADJ_BLKCNT 2 /* adjust inode used block count */ +#define FFS_BLK_FREE 3 /* free range of blocks in map */ +#define FFS_DIR_FREE 4 /* free specified dir inodes in map */ +#define FFS_FILE_FREE 5 /* free specified file inodes in map */ +#define FFS_SET_FLAGS 6 /* set filesystem flags */ +#define FFS_ADJ_NDIR 7 /* adjust number of directories */ +#define FFS_ADJ_NBFREE 8 /* adjust number of free blocks */ +#define FFS_ADJ_NIFREE 9 /* adjust number of free inodes */ +#define FFS_ADJ_NFFREE 10 /* adjust number of free frags */ +#define FFS_ADJ_NUMCLUSTERS 11 /* adjust number of free clusters */ +#define FFS_SET_CWD 12 /* set current directory */ +#define FFS_SET_DOTDOT 13 /* set inode number for ".." */ +#define FFS_UNLINK 14 /* remove a name in the filesystem */ +#define FFS_SET_INODE 15 /* update an on-disk inode */ +#define FFS_SET_BUFOUTPUT 16 /* set buffered writing on descriptor */ +#define FFS_MAXID 16 /* number of valid ffs ids */ + +/* + * Command structure passed in to the filesystem to adjust filesystem values. + */ +#define FFS_CMD_VERSION 0x19790518 /* version ID */ +struct fsck_cmd { + int32_t version; /* version of command structure */ + int32_t handle; /* reference to filesystem to be changed */ + int64_t value; /* inode or block number to be affected */ + int64_t size; /* amount or range to be adjusted */ + int64_t spare; /* reserved for future use */ +}; + +/* + * Per cylinder group information; summarized in blocks allocated + * from first cylinder group data blocks. These blocks have to be + * read in from fs_csaddr (size fs_cssize) in addition to the + * super block. + */ +struct csum { + int32_t cs_ndir; /* number of directories */ + int32_t cs_nbfree; /* number of free blocks */ + int32_t cs_nifree; /* number of free inodes */ + int32_t cs_nffree; /* number of free frags */ +}; +struct csum_total { + int64_t cs_ndir; /* number of directories */ + int64_t cs_nbfree; /* number of free blocks */ + int64_t cs_nifree; /* number of free inodes */ + int64_t cs_nffree; /* number of free frags */ + int64_t cs_numclusters; /* number of free clusters */ + int64_t cs_spare[3]; /* future expansion */ +}; + +/* + * Super block for an FFS filesystem. + */ +struct fs { + int32_t fs_firstfield; /* historic filesystem linked list, */ + int32_t fs_unused_1; /* used for incore super blocks */ + int32_t fs_sblkno; /* offset of super-block in filesys */ + int32_t fs_cblkno; /* offset of cyl-block in filesys */ + int32_t fs_iblkno; /* offset of inode-blocks in filesys */ + int32_t fs_dblkno; /* offset of first data after cg */ + int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */ + int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */ + int32_t fs_old_time; /* last time written */ + int32_t fs_old_size; /* number of blocks in fs */ + int32_t fs_old_dsize; /* number of data blocks in fs */ + u_int32_t fs_ncg; /* number of cylinder groups */ + int32_t fs_bsize; /* size of basic blocks in fs */ + int32_t fs_fsize; /* size of frag blocks in fs */ + int32_t fs_frag; /* number of frags in a block in fs */ +/* these are configuration parameters */ + int32_t fs_minfree; /* minimum percentage of free blocks */ + int32_t fs_old_rotdelay; /* num of ms for optimal next block */ + int32_t fs_old_rps; /* disk revolutions per second */ +/* these fields can be computed from the others */ + int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ + int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ + int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ + int32_t fs_fshift; /* ``numfrags'' calc number of frags */ +/* these are configuration parameters */ + int32_t fs_maxcontig; /* max number of contiguous blks */ + int32_t fs_maxbpg; /* max number of blks per cyl group */ +/* these fields can be computed from the others */ + int32_t fs_fragshift; /* block to frag shift */ + int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fs_sbsize; /* actual size of super block */ + int32_t fs_spare1[2]; /* old fs_csmask */ + /* old fs_csshift */ + int32_t fs_nindir; /* value of NINDIR */ + u_int32_t fs_inopb; /* value of INOPB */ + int32_t fs_old_nspf; /* value of NSPF */ +/* yet another configuration parameter */ + int32_t fs_optim; /* optimization preference, see below */ + int32_t fs_old_npsect; /* # sectors/track including spares */ + int32_t fs_old_interleave; /* hardware sector interleave */ + int32_t fs_old_trackskew; /* sector 0 skew, per track */ + int32_t fs_id[2]; /* unique filesystem id */ +/* sizes determined by number of cylinder groups and their sizes */ + int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */ + int32_t fs_cssize; /* size of cyl grp summary area */ + int32_t fs_cgsize; /* cylinder group size */ + int32_t fs_spare2; /* old fs_ntrak */ + int32_t fs_old_nsect; /* sectors per track */ + int32_t fs_old_spc; /* sectors per cylinder */ + int32_t fs_old_ncyl; /* cylinders in filesystem */ + int32_t fs_old_cpg; /* cylinders per group */ + u_int32_t fs_ipg; /* inodes per group */ + int32_t fs_fpg; /* blocks per group * fs_frag */ +/* this data must be re-computed after crashes */ + struct csum fs_old_cstotal; /* cylinder summary information */ +/* these fields are cleared at mount time */ + int8_t fs_fmod; /* super block modified flag */ + int8_t fs_clean; /* filesystem is clean flag */ + int8_t fs_ronly; /* mounted read-only flag */ + int8_t fs_old_flags; /* old FS_ flags */ + u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ + u_char fs_volname[MAXVOLLEN]; /* volume name */ + u_int64_t fs_swuid; /* system-wide uid */ + int32_t fs_pad; /* due to alignment of fs_swuid */ +/* these fields retain the current block allocation info */ + int32_t fs_cgrotor; /* last cg searched */ + void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ + u_int8_t *fs_contigdirs; /* (u) # of contig. allocated dirs */ + struct csum *fs_csp; /* (u) cg summary info buffer */ + int32_t *fs_maxcluster; /* (u) max cluster in each cyl group */ + u_int *fs_active; /* (u) used by snapshots to track fs */ + int32_t fs_old_cpc; /* cyl per cycle in postbl */ + int32_t fs_maxbsize; /* maximum blocking factor permitted */ + int64_t fs_unrefs; /* number of unreferenced inodes */ + int64_t fs_providersize; /* size of underlying GEOM provider */ + int64_t fs_metaspace; /* size of area reserved for metadata */ + int64_t fs_sparecon64[14]; /* old rotation block list head */ + int64_t fs_sblockloc; /* byte offset of standard superblock */ + struct csum_total fs_cstotal; /* (u) cylinder summary information */ + ufs_time_t fs_time; /* last time written */ + int64_t fs_size; /* number of blocks in fs */ + int64_t fs_dsize; /* number of data blocks in fs */ + ufs2_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */ + int64_t fs_pendingblocks; /* (u) blocks being freed */ + u_int32_t fs_pendinginodes; /* (u) inodes being freed */ + uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ + u_int32_t fs_avgfilesize; /* expected average file size */ + u_int32_t fs_avgfpdir; /* expected # of files per directory */ + int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ + ufs_time_t fs_mtime; /* Last mount or fsck time. */ + int32_t fs_sujfree; /* SUJ free list */ + int32_t fs_sparecon32[23]; /* reserved for future constants */ + int32_t fs_flags; /* see FS_ flags below */ + int32_t fs_contigsumsize; /* size of cluster summary array */ + int32_t fs_maxsymlinklen; /* max length of an internal symlink */ + int32_t fs_old_inodefmt; /* format of on-disk inodes */ + u_int64_t fs_maxfilesize; /* maximum representable file size */ + int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ + int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ + int32_t fs_state; /* validate fs_clean field */ + int32_t fs_old_postblformat; /* format of positional layout tables */ + int32_t fs_old_nrpos; /* number of rotational positions */ + int32_t fs_spare5[2]; /* old fs_postbloff */ + /* old fs_rotbloff */ + int32_t fs_magic; /* magic number */ +}; + +/* Sanity checking. */ +#ifdef CTASSERT +CTASSERT(sizeof(struct fs) == 1376); +#endif + +/* + * Filesystem identification + */ +#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast filesystem magic number */ +#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast filesystem magic number */ +#define FS_BAD_MAGIC 0x19960408 /* UFS incomplete newfs magic number */ +#define FS_OKAY 0x7c269d38 /* superblock checksum */ +#define FS_42INODEFMT -1 /* 4.2BSD inode format */ +#define FS_44INODEFMT 2 /* 4.4BSD inode format */ + +/* + * Preference for optimization. + */ +#define FS_OPTTIME 0 /* minimize allocation time */ +#define FS_OPTSPACE 1 /* minimize disk fragmentation */ + +/* + * Filesystem flags. + * + * The FS_UNCLEAN flag is set by the kernel when the filesystem was + * mounted with fs_clean set to zero. The FS_DOSOFTDEP flag indicates + * that the filesystem should be managed by the soft updates code. + * Note that the FS_NEEDSFSCK flag is set and cleared only by the + * fsck utility. It is set when background fsck finds an unexpected + * inconsistency which requires a traditional foreground fsck to be + * run. Such inconsistencies should only be found after an uncorrectable + * disk error. A foreground fsck will clear the FS_NEEDSFSCK flag when + * it has successfully cleaned up the filesystem. The kernel uses this + * flag to enforce that inconsistent filesystems be mounted read-only. + * The FS_INDEXDIRS flag when set indicates that the kernel maintains + * on-disk auxiliary indexes (such as B-trees) for speeding directory + * accesses. Kernels that do not support auxiliary indices clear the + * flag to indicate that the indices need to be rebuilt (by fsck) before + * they can be used. + * + * FS_ACLS indicates that POSIX.1e ACLs are administratively enabled + * for the file system, so they should be loaded from extended attributes, + * observed for access control purposes, and be administered by object + * owners. FS_NFS4ACLS indicates that NFSv4 ACLs are administratively + * enabled. This flag is mutually exclusive with FS_ACLS. FS_MULTILABEL + * indicates that the TrustedBSD MAC Framework should attempt to back MAC + * labels into extended attributes on the file system rather than maintain + * a single mount label for all objects. + */ +#define FS_UNCLEAN 0x0001 /* filesystem not clean at mount */ +#define FS_DOSOFTDEP 0x0002 /* filesystem using soft dependencies */ +#define FS_NEEDSFSCK 0x0004 /* filesystem needs sync fsck before mount */ +#define FS_SUJ 0x0008 /* Filesystem using softupdate journal */ +#define FS_ACLS 0x0010 /* file system has POSIX.1e ACLs enabled */ +#define FS_MULTILABEL 0x0020 /* file system is MAC multi-label */ +#define FS_GJOURNAL 0x0040 /* gjournaled file system */ +#define FS_FLAGS_UPDATED 0x0080 /* flags have been moved to new location */ +#define FS_NFS4ACLS 0x0100 /* file system has NFSv4 ACLs enabled */ +#define FS_INDEXDIRS 0x0200 /* kernel supports indexed directories */ +#define FS_TRIM 0x0400 /* issue BIO_DELETE for deleted blocks */ + +/* + * Macros to access bits in the fs_active array. + */ +#define ACTIVECGNUM(fs, cg) ((fs)->fs_active[(cg) / (NBBY * sizeof(int))]) +#define ACTIVECGOFF(cg) (1 << ((cg) % (NBBY * sizeof(int)))) +#define ACTIVESET(fs, cg) do { \ + if ((fs)->fs_active) \ + ACTIVECGNUM((fs), (cg)) |= ACTIVECGOFF((cg)); \ +} while (0) +#define ACTIVECLEAR(fs, cg) do { \ + if ((fs)->fs_active) \ + ACTIVECGNUM((fs), (cg)) &= ~ACTIVECGOFF((cg)); \ +} while (0) + +/* + * The size of a cylinder group is calculated by CGSIZE. The maximum size + * is limited by the fact that cylinder groups are at most one block. + * Its size is derived from the size of the maps maintained in the + * cylinder group and the (struct cg) size. + */ +#define CGSIZE(fs) \ + /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \ + /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \ + /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \ + /* inode map */ howmany((fs)->fs_ipg, NBBY) + \ + /* block map */ howmany((fs)->fs_fpg, NBBY) +\ + /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \ + /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \ + /* cluster map */ howmany(fragstoblks(fs, (fs)->fs_fpg), NBBY))) + +/* + * The minimal number of cylinder groups that should be created. + */ +#define MINCYLGRPS 4 + +/* + * Convert cylinder group to base address of its global summary info. + */ +#define fs_cs(fs, indx) fs_csp[indx] + +/* + * Cylinder group block for a filesystem. + */ +#define CG_MAGIC 0x090255 +struct cg { + int32_t cg_firstfield; /* historic cyl groups linked list */ + int32_t cg_magic; /* magic number */ + int32_t cg_old_time; /* time last written */ + u_int32_t cg_cgx; /* we are the cgx'th cylinder group */ + int16_t cg_old_ncyl; /* number of cyl's this cg */ + int16_t cg_old_niblk; /* number of inode blocks this cg */ + u_int32_t cg_ndblk; /* number of data blocks this cg */ + struct csum cg_cs; /* cylinder summary information */ + u_int32_t cg_rotor; /* position of last used block */ + u_int32_t cg_frotor; /* position of last used frag */ + u_int32_t cg_irotor; /* position of last used inode */ + u_int32_t cg_frsum[MAXFRAG]; /* counts of available frags */ + int32_t cg_old_btotoff; /* (int32) block totals per cylinder */ + int32_t cg_old_boff; /* (u_int16) free block positions */ + u_int32_t cg_iusedoff; /* (u_int8) used inode map */ + u_int32_t cg_freeoff; /* (u_int8) free block map */ + u_int32_t cg_nextfreeoff; /* (u_int8) next available space */ + u_int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */ + u_int32_t cg_clusteroff; /* (u_int8) free cluster map */ + u_int32_t cg_nclusterblks; /* number of clusters this cg */ + u_int32_t cg_niblk; /* number of inode blocks this cg */ + u_int32_t cg_initediblk; /* last initialized inode */ + u_int32_t cg_unrefs; /* number of unreferenced inodes */ + int32_t cg_sparecon32[2]; /* reserved for future use */ + ufs_time_t cg_time; /* time last written */ + int64_t cg_sparecon64[3]; /* reserved for future use */ + u_int8_t cg_space[1]; /* space for cylinder group maps */ +/* actually longer */ +}; + +/* + * Macros for access to cylinder group array structures + */ +#define cg_chkmagic(cgp) ((cgp)->cg_magic == CG_MAGIC) +#define cg_inosused(cgp) \ + ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_iusedoff)) +#define cg_blksfree(cgp) \ + ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_freeoff)) +#define cg_clustersfree(cgp) \ + ((u_int8_t *)((u_int8_t *)(cgp) + (cgp)->cg_clusteroff)) +#define cg_clustersum(cgp) \ + ((int32_t *)((uintptr_t)(cgp) + (cgp)->cg_clustersumoff)) + +/* + * Turn filesystem block numbers into disk block addresses. + * This maps filesystem blocks to device size blocks. + */ +#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb) +#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) + +/* + * Cylinder group macros to locate things in cylinder groups. + * They calc filesystem addresses of cylinder group data structures. + */ +#define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c)) +#define cgdata(fs, c) (cgdmin(fs, c) + (fs)->fs_metaspace) /* data zone */ +#define cgmeta(fs, c) (cgdmin(fs, c)) /* meta data */ +#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ +#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ +#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ +#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ +#define cgstart(fs, c) \ + ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : \ + (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask)))) + +/* + * Macros for handling inode numbers: + * inode number to filesystem block offset. + * inode number to cylinder group number. + * inode number to filesystem block address. + */ +#define ino_to_cg(fs, x) (((ino_t)(x)) / (fs)->fs_ipg) +#define ino_to_fsba(fs, x) \ + ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) + \ + (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs)))))) +#define ino_to_fsbo(fs, x) (((ino_t)(x)) % INOPB(fs)) + +/* + * Give cylinder group number for a filesystem block. + * Give cylinder group block number for a filesystem block. + */ +#define dtog(fs, d) ((d) / (fs)->fs_fpg) +#define dtogd(fs, d) ((d) % (fs)->fs_fpg) + +/* + * Extract the bits for a block from a map. + * Compute the cylinder and rotational position of a cyl block addr. + */ +#define blkmap(fs, map, loc) \ + (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) + +/* + * The following macros optimize certain frequently calculated + * quantities by using shifts and masks in place of divisions + * modulos and multiplications. + */ +#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ + ((loc) & (fs)->fs_qbmask) +#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ + ((loc) & (fs)->fs_qfmask) +#define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \ + (((off_t)(frag)) << (fs)->fs_fshift) +#define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \ + (((off_t)(blk)) << (fs)->fs_bshift) +/* Use this only when `blk' is known to be small, e.g., < NDADDR. */ +#define smalllblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \ + ((blk) << (fs)->fs_bshift) +#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \ + ((loc) >> (fs)->fs_bshift) +#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \ + ((loc) >> (fs)->fs_fshift) +#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ + (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask) +#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ + (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) +#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \ + ((frags) >> (fs)->fs_fragshift) +#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \ + ((blks) << (fs)->fs_fragshift) +#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \ + ((fsb) & ((fs)->fs_frag - 1)) +#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ + ((fsb) &~ ((fs)->fs_frag - 1)) + +/* + * Determine the number of available frags given a + * percentage to hold in reserve. + */ +#define freespace(fs, percentreserved) \ + (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ + (fs)->fs_cstotal.cs_nffree - \ + (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100)) + +/* + * Determining the size of a file block in the filesystem. + */ +#define blksize(fs, ip, lbn) \ + (((lbn) >= NDADDR || (ip)->i_size >= smalllblktosize(fs, (lbn) + 1)) \ + ? (fs)->fs_bsize \ + : (fragroundup(fs, blkoff(fs, (ip)->i_size)))) +#define sblksize(fs, size, lbn) \ + (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \ + ? (fs)->fs_bsize \ + : (fragroundup(fs, blkoff(fs, (size))))) + +/* + * Number of indirects in a filesystem block. + */ +#define NINDIR(fs) ((fs)->fs_nindir) + +/* + * Indirect lbns are aligned on NDADDR addresses where single indirects + * are the negated address of the lowest lbn reachable, double indirects + * are this lbn - 1 and triple indirects are this lbn - 2. This yields + * an unusual bit order to determine level. + */ +static inline int +lbn_level(ufs_lbn_t lbn) +{ + if (lbn >= 0) + return 0; + switch (lbn & 0x3) { + case 0: + return (0); + case 1: + break; + case 2: + return (2); + case 3: + return (1); + default: + break; + } + return (-1); +} + +static inline ufs_lbn_t +lbn_offset(struct fs *fs, int level) +{ + ufs_lbn_t res; + + for (res = 1; level > 0; level--) + res *= NINDIR(fs); + return (res); +} + +/* + * Number of inodes in a secondary storage block/fragment. + */ +#define INOPB(fs) ((fs)->fs_inopb) +#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) + +/* + * Softdep journal record format. + */ + +#define JOP_ADDREF 1 /* Add a reference to an inode. */ +#define JOP_REMREF 2 /* Remove a reference from an inode. */ +#define JOP_NEWBLK 3 /* Allocate a block. */ +#define JOP_FREEBLK 4 /* Free a block or a tree of blocks. */ +#define JOP_MVREF 5 /* Move a reference from one off to another. */ +#define JOP_TRUNC 6 /* Partial truncation record. */ +#define JOP_SYNC 7 /* fsync() complete record. */ + +#define JREC_SIZE 32 /* Record and segment header size. */ + +#define SUJ_MIN (4 * 1024 * 1024) /* Minimum journal size */ +#define SUJ_MAX (32 * 1024 * 1024) /* Maximum journal size */ +#define SUJ_FILE ".sujournal" /* Journal file name */ + +/* + * Size of the segment record header. There is at most one for each disk + * block in the journal. The segment header is followed by an array of + * records. fsck depends on the first element in each record being 'op' + * and the second being 'ino'. Segments may span multiple disk blocks but + * the header is present on each. + */ +struct jsegrec { + uint64_t jsr_seq; /* Our sequence number */ + uint64_t jsr_oldest; /* Oldest valid sequence number */ + uint16_t jsr_cnt; /* Count of valid records */ + uint16_t jsr_blocks; /* Count of device bsize blocks. */ + uint32_t jsr_crc; /* 32bit crc of the valid space */ + ufs_time_t jsr_time; /* timestamp for mount instance */ +}; + +/* + * Reference record. Records a single link count modification. + */ +struct jrefrec { + uint32_t jr_op; + uint32_t jr_ino; + uint32_t jr_parent; + uint16_t jr_nlink; + uint16_t jr_mode; + int64_t jr_diroff; + uint64_t jr_unused; +}; + +/* + * Move record. Records a reference moving within a directory block. The + * nlink is unchanged but we must search both locations. + */ +struct jmvrec { + uint32_t jm_op; + uint32_t jm_ino; + uint32_t jm_parent; + uint16_t jm_unused; + int64_t jm_oldoff; + int64_t jm_newoff; +}; + +/* + * Block record. A set of frags or tree of blocks starting at an indirect are + * freed or a set of frags are allocated. + */ +struct jblkrec { + uint32_t jb_op; + uint32_t jb_ino; + ufs2_daddr_t jb_blkno; + ufs_lbn_t jb_lbn; + uint16_t jb_frags; + uint16_t jb_oldfrags; + uint32_t jb_unused; +}; + +/* + * Truncation record. Records a partial truncation so that it may be + * completed at check time. Also used for sync records. + */ +struct jtrncrec { + uint32_t jt_op; + uint32_t jt_ino; + int64_t jt_size; + uint32_t jt_extsize; + uint32_t jt_pad[3]; +}; + +union jrec { + struct jsegrec rec_jsegrec; + struct jrefrec rec_jrefrec; + struct jmvrec rec_jmvrec; + struct jblkrec rec_jblkrec; + struct jtrncrec rec_jtrncrec; +}; + +#ifdef CTASSERT +CTASSERT(sizeof(struct jsegrec) == JREC_SIZE); +CTASSERT(sizeof(struct jrefrec) == JREC_SIZE); +CTASSERT(sizeof(struct jmvrec) == JREC_SIZE); +CTASSERT(sizeof(struct jblkrec) == JREC_SIZE); +CTASSERT(sizeof(struct jtrncrec) == JREC_SIZE); +CTASSERT(sizeof(union jrec) == JREC_SIZE); +#endif + +extern int inside[], around[]; +extern u_char *fragtbl[]; + +/* + * IOCTLs used for filesystem write suspension. + */ +#define UFSSUSPEND _IOW('U', 1, fsid_t) +#define UFSRESUME _IO('U', 2) + +#endif diff --git a/sys/include/ufs/ufs.h b/sys/include/ufs/ufs.h new file mode 100644 index 0000000..8667d28 --- /dev/null +++ b/sys/include/ufs/ufs.h @@ -0,0 +1,279 @@ +/***************************************************************************************** + Copyright (c) 2002-2004, 2017 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id: ufs.h 141 2016-01-17 02:05:18Z reddawg $ + + *****************************************************************************************/ + +#ifndef _UFS_H +#define _UFS_H + +#include +#include + +#define DT_REG 8 +#define MAXNAMLEN 255 +#define ROOTINO ((ino_t)2) +#define DT_DIR 4 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define DEV_BSIZE (1<fs_nindir) + +/* + * Cylinder group macros to locate things in cylinder groups. + * They calc filesystem addresses of cylinder group data structures. + */ +#define cgbase(fs, c) (((ufs2_daddr_t)(fs)->fs_fpg) * (c)) +#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ +#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ +#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ +#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ +#define cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC ? cgbase(fs, c) : (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask)))) + +#define fsbtodb(fs, b) ((daddr_t)(b) << (fs)->fs_fsbtodb) +#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) + +/* + * Macros for handling inode numbers: + * inode number to filesystem block offset. + * inode number to cylinder group number. + * inode number to filesystem block address. + */ +#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg) +#define ino_to_fsba(fs, x) ((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs)))))) +#define ino_to_fsbo(fs, x) ((x) % INOPB(fs)) + +#define blkoff(fs, loc) ((loc) & (fs)->fs_qbmask) // calculates (loc % fs->fs_bsize) +#define lblkno(fs, loc) ((loc) >> (fs)->fs_bshift) // calculates (loc / fs->fs_bsize) +#define fragroundup(fs, size) (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) // calculates roundup(size, fs->fs_fsize) + +#define sblksize(fs, size, lbn) (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) ? (fs)->fs_bsize : (fragroundup(fs, blkoff(fs, (size))))) + +typedef int32_t ufs1_daddr_t; +typedef int64_t ufs2_daddr_t; +typedef int64_t ufs_lbn_t; +typedef int64_t ufs_time_t; +// MrOlsen (2016-01-16) NOTE: typedef __int64_t daddr_t; + +struct dirent { + __uint32_t d_fileno; /* file number of entry */ + __uint16_t d_reclen; /* length of this record */ + __uint8_t d_type; /* file type, see below */ + __uint8_t d_namlen; /* length of string in d_name */ + char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ +}; + +#define NXADDR 2 /* External addresses in inode. */ +#define NDADDR 12 /* Direct addresses in inode. */ +#define NIADDR 3 /* Indirect addresses in inode. */ + +struct ufs2_dinode { + u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + uint32_t di_uid; /* 4: File owner. */ + uint32_t di_gid; /* 8: File group. */ + uint32_t di_blksize; /* 12: Inode blocksize. */ + u_int64_t di_size; /* 16: File byte count. */ + u_int64_t di_blocks; /* 24: Bytes actually held. */ + ufs_time_t di_atime; /* 32: Last access time. */ + ufs_time_t di_mtime; /* 40: Last modified time. */ + ufs_time_t di_ctime; /* 48: Last inode change time. */ + ufs_time_t di_birthtime; /* 56: Inode creation time. */ + int32_t di_mtimensec; /* 64: Last modified time. */ + int32_t di_atimensec; /* 68: Last access time. */ + int32_t di_ctimensec; /* 72: Last inode change time. */ + int32_t di_birthnsec; /* 76: Inode creation time. */ + int32_t di_gen; /* 80: Generation number. */ + uint32_t di_kernflags; /* 84: Kernel flags. */ + uint32_t di_flags; /* 88: Status flags (chflags). */ + int32_t di_extsize; /* 92: External attributes block. */ + ufs2_daddr_t di_extb[NXADDR];/* 96: External attributes block. */ + ufs2_daddr_t di_db[NDADDR]; /* 112: Direct disk blocks. */ + ufs2_daddr_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */ + int64_t di_spare[3]; /* 232: Reserved; currently unused */ +}; + +struct ufs1_dinode { + u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ + int16_t di_nlink; /* 2: File link count. */ + union { + u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ + } di_u; + u_int64_t di_size; /* 8: File byte count. */ + int32_t di_atime; /* 16: Last access time. */ + int32_t di_atimensec; /* 20: Last access time. */ + int32_t di_mtime; /* 24: Last modified time. */ + int32_t di_mtimensec; /* 28: Last modified time. */ + int32_t di_ctime; /* 32: Last inode change time. */ + int32_t di_ctimensec; /* 36: Last inode change time. */ + ufs1_daddr_t di_db[NDADDR]; /* 40: Direct disk blocks. */ + ufs1_daddr_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ + uint32_t di_flags; /* 100: Status flags (chflags). */ + int32_t di_blocks; /* 104: Blocks actually held. */ + int32_t di_gen; /* 108: Generation number. */ + uint32_t di_uid; /* 112: File owner. */ + uint32_t di_gid; /* 116: File group. */ + int32_t di_spare[2]; /* 120: Reserved; currently unused */ +}; + +struct csum { + int32_t cs_ndir; /* number of directories */ + int32_t cs_nbfree; /* number of free blocks */ + int32_t cs_nifree; /* number of free inodes */ + int32_t cs_nffree; /* number of free frags */ +}; +struct csum_total { + int64_t cs_ndir; /* number of directories */ + int64_t cs_nbfree; /* number of free blocks */ + int64_t cs_nifree; /* number of free inodes */ + int64_t cs_nffree; /* number of free frags */ + int64_t cs_numclusters; /* number of free clusters */ + int64_t cs_spare[3]; /* future expansion */ +}; + +struct fs { + int32_t fs_firstfield; /* historic filesystem linked list, */ + int32_t fs_unused_1; /* used for incore super blocks */ + int32_t fs_sblkno; /* offset of super-block in filesys */ + int32_t fs_cblkno; /* offset of cyl-block in filesys */ + int32_t fs_iblkno; /* offset of inode-blocks in filesys */ + int32_t fs_dblkno; /* offset of first data after cg */ + int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */ + int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */ + int32_t fs_old_time; /* last time written */ + int32_t fs_old_size; /* number of blocks in fs */ + int32_t fs_old_dsize; /* number of data blocks in fs */ + int32_t fs_ncg; /* number of cylinder groups */ + int32_t fs_bsize; /* size of basic blocks in fs */ + int32_t fs_fsize; /* size of frag blocks in fs */ + int32_t fs_frag; /* number of frags in a block in fs */ + /* these are configuration parameters */ + int32_t fs_minfree; /* minimum percentage of free blocks */ + int32_t fs_old_rotdelay; /* num of ms for optimal next block */ + int32_t fs_old_rps; /* disk revolutions per second */ + /* these fields can be computed from the others */ + int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ + int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ + int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ + int32_t fs_fshift; /* ``numfrags'' calc number of frags */ + /* these are configuration parameters */ + int32_t fs_maxcontig; /* max number of contiguous blks */ + int32_t fs_maxbpg; /* max number of blks per cyl group */ + /* these fields can be computed from the others */ + int32_t fs_fragshift; /* block to frag shift */ + int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ + int32_t fs_sbsize; /* actual size of super block */ + int32_t fs_spare1[2]; /* old fs_csmask */ + /* old fs_csshift */ + int32_t fs_nindir; /* value of NINDIR */ + int32_t fs_inopb; /* value of INOPB */ + int32_t fs_old_nspf; /* value of NSPF */ + /* yet another configuration parameter */ + int32_t fs_optim; /* optimization preference, see below */ + int32_t fs_old_npsect; /* # sectors/track including spares */ + int32_t fs_old_interleave; /* hardware sector interleave */ + int32_t fs_old_trackskew; /* sector 0 skew, per track */ + int32_t fs_id[2]; /* unique filesystem id */ + /* sizes determined by number of cylinder groups and their sizes */ + int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */ + int32_t fs_cssize; /* size of cyl grp summary area */ + int32_t fs_cgsize; /* cylinder group size */ + int32_t fs_spare2; /* old fs_ntrak */ + int32_t fs_old_nsect; /* sectors per track */ + int32_t fs_old_spc; /* sectors per cylinder */ + int32_t fs_old_ncyl; /* cylinders in filesystem */ + int32_t fs_old_cpg; /* cylinders per group */ + int32_t fs_ipg; /* inodes per group */ + int32_t fs_fpg; /* blocks per group * fs_frag */ + /* this data must be re-computed after crashes */ + struct csum fs_old_cstotal; /* cylinder summary information */ + /* these fields are cleared at mount time */ + int8_t fs_fmod; /* super block modified flag */ + int8_t fs_clean; /* filesystem is clean flag */ + int8_t fs_ronly; /* mounted read-only flag */ + int8_t fs_old_flags; /* old FS_ flags */ + u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ + u_char fs_volname[MAXVOLLEN]; /* volume name */ + u_int64_t fs_swuid; /* system-wide uid */ + int32_t fs_pad; /* due to alignment of fs_swuid */ + /* these fields retain the current block allocation info */ + int32_t fs_cgrotor; /* last cg searched */ + void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ + u_int8_t *fs_contigdirs; /* (u) # of contig. allocated dirs */ + struct csum *fs_csp; /* (u) cg summary info buffer */ + int32_t *fs_maxcluster; /* (u) max cluster in each cyl group */ + u_int *fs_active; /* (u) used by snapshots to track fs */ + int32_t fs_old_cpc; /* cyl per cycle in postbl */ + int32_t fs_maxbsize; /* maximum blocking factor permitted */ + int64_t fs_sparecon64[17]; /* old rotation block list head */ + int64_t fs_sblockloc; /* byte offset of standard superblock */ + struct csum_total fs_cstotal; /* (u) cylinder summary information */ + ufs_time_t fs_time; /* last time written */ + int64_t fs_size; /* number of blocks in fs */ + int64_t fs_dsize; /* number of data blocks in fs */ + ufs2_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */ + int64_t fs_pendingblocks; /* (u) blocks being freed */ + int32_t fs_pendinginodes; /* (u) inodes being freed */ + int32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ + int32_t fs_avgfilesize; /* expected average file size */ + int32_t fs_avgfpdir; /* expected # of files per directory */ + int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ + int32_t fs_sparecon32[26]; /* reserved for future constants */ + int32_t fs_flags; /* see FS_ flags below */ + int32_t fs_contigsumsize; /* size of cluster summary array */ + int32_t fs_maxsymlinklen; /* max length of an internal symlink */ + int32_t fs_old_inodefmt; /* format of on-disk inodes */ + u_int64_t fs_maxfilesize; /* maximum representable file size */ + int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ + int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ + int32_t fs_state; /* validate fs_clean field */ + int32_t fs_old_postblformat; /* format of positional layout tables */ + int32_t fs_old_nrpos; /* number of rotational positions */ + int32_t fs_spare5[2]; /* old fs_postbloff */ + /* old fs_rotbloff */ + int32_t fs_magic; /* magic number */ +}; + +int ufs_init(); +int ufs_initialize(); + +#endif + +/*** + END + ***/ diff --git a/sys/include/vfs/file.h b/sys/include/vfs/file.h new file mode 100644 index 0000000..eee6c04 --- /dev/null +++ b/sys/include/vfs/file.h @@ -0,0 +1,119 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _VFS_FILE_H_ +#define _VFS_FILE_H_ 1 + +#include + +#include +#include +#include +#include +#include + +/* HACK */ +int getchar(); + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#define VBLKSHIFT 12 +#define VBLKSIZE (1 << VBLKSHIFT) +#define SBLOCKSIZE 8192 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define DEV_BSIZE (1< + +#define MFSNAMELEN 16 /* length of type name including null */ +#define MNAMELEN 88 /* size of on/from name bufs */ + +typedef struct fsid { + int32_t val[2]; +} fsid_t; /* filesystem id type */ + +struct statfs { + uint32_t f_version; /* structure version number */ + uint32_t f_type; /* type of filesystem */ + u_int64_t f_flags; /* copy of mount exported flags */ + u_int64_t f_bsize; /* filesystem fragment size */ + u_int64_t f_iosize; /* optimal transfer block size */ + u_int64_t f_blocks; /* total data blocks in filesystem */ + u_int64_t f_bfree; /* free blocks in filesystem */ + int64_t f_bavail; /* free blocks avail to non-superuser */ + u_int64_t f_files; /* total file nodes in filesystem */ + int64_t f_ffree; /* free nodes avail to non-superuser */ + u_int64_t f_syncwrites; /* count of sync writes since mount */ + u_int64_t f_asyncwrites; /* count of async writes since mount */ + u_int64_t f_syncreads; /* count of sync reads since mount */ + u_int64_t f_asyncreads; /* count of async reads since mount */ + u_int64_t f_spare[10]; /* unused spare */ + uint32_t f_namemax; /* maximum filename length */ + uid_t f_owner; /* user that mounted the filesystem */ + fsid_t f_fsid; /* filesystem id */ + char f_charspare[80]; /* spare string space */ + char f_fstypename[MFSNAMELEN]; /* filesystem type name */ + char f_mntfromname[MNAMELEN]; /* mounted filesystem */ + char f_mntonname[MNAMELEN]; /* directory on which mounted */ +}; + +struct vfs_mountPoint { + struct vfs_mountPoint *prev; + struct vfs_mountPoint *next; + struct fileSystem *fs; + struct device_node *device; + struct ubixDiskLabel *diskLabel; + void *fsInfo; + int partition; + char mountPoint[1024]; + char perms; +}; + +int vfs_mount(int major, int minor, int partition, int fsType, char *mountPoint, char *perms); +int vfs_addMount(struct vfs_mountPoint *mp); +struct vfs_mountPoint *vfs_findMount(char *mountPoint); + +#endif + +/*** + END + ***/ diff --git a/sys/include/vfs/vfs.h b/sys/include/vfs/vfs.h new file mode 100644 index 0000000..3a48d5e --- /dev/null +++ b/sys/include/vfs/vfs.h @@ -0,0 +1,130 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _VFS_VFS_H +#define _VFS_VFS_H + +#include +#include +#include +#include +#include +#include +#include + +#define MAY_EXEC 1 +#define MAY_WRITE 2 +#define MAY_READ 4 + +#define maxFd 32 +#define fdAvail 1 +#define fdOpen 2 +#define fdRead 3 +#define fdEof 4 + +#define fileRead 0x0001 +#define fileWrite 0x0002 +#define fileBinary 0x0004 +#define fileAppend 0x0008 + +/*! + \brief filesSystem Structure + + not sure if we should allow function to point to NULL + */ +struct fileSystem { + struct fileSystem *prev; + struct fileSystem *next; + int (*vfsInitFS)(void *); /*!< pointer to inialization routine */ + int (*vfsRead)(void *, char *, long, long); /*!< pointer to read routine */ + int (*vfsWrite)(void *, char *, long, long); /*!< pointer to write routine */ + int (*vfsOpenFile)(void *, void *); /*!< pointer to openfile routine */ + int (*vfsUnlink)(char *, void *); /*!< pointer to unlink routine */ + int (*vfsMakeDir)(char *, void *); /*!< pointer to makedir routine */ + int (*vfsRemDir)(char *); /*!< pointer to remdir routine */ + int (*vfsSync)(void); /*!< pointer to sync routine */ + int vfsType; /*!< vfs type id */ +}; + +struct inode_operations { + struct file_operations * default_file_ops; + int (*create)(struct inode *, const char *, int, int, struct inode **); + int (*lookup)(struct inode *, const char *, int, struct inode **); + int (*link)(struct inode *, struct inode *, const char *, int); + int (*unlink)(struct inode *, const char *, int); + int (*symlink)(struct inode *, const char *, int, const char *); + int (*mkdir)(struct inode *, const char *, int, int); + int (*rmdir)(struct inode *, const char *, int); + int (*mknod)(struct inode *, const char *, int, int, int); + int (*rename)(struct inode *, const char *, int, struct inode *, const char *, int); + int (*readlink)(struct inode *, char *, int); + int (*follow_link)(struct inode *, struct inode *, int, int, struct inode **); + int (*bmap)(struct inode *, int); + void (*truncate)(struct inode *); + int (*permission)(struct inode *, int); +}; + +/* VFS Functions */ +int vfs_init(); +int vfsRegisterFS(struct fileSystem); +struct fileSystem *vfs_findFS(int); + +struct super_operations { + void (*read_inode)(struct inode *); + int (*notify_change)(int flags, struct inode *); + void (*write_inode)(struct inode *); + void (*put_inode)(struct inode *); + void (*put_super)(struct super_block *); + void (*write_super)(struct super_block *); + void (*statfs)(struct super_block *, struct statfs *); + int (*remount_fs)(struct super_block *, int *, char *); +}; + +struct super_block { + __dev_t s_dev; + unsigned long s_blocksize; + unsigned char s_blocksize_bits; + unsigned char s_lock; + unsigned char s_rd_only; + unsigned char s_dirt; + struct super_operations *s_op; + unsigned long s_flags; + unsigned long s_magic; + unsigned long s_time; + struct inode * s_covered; + struct inode * s_mounted; + struct wait_queue * s_wait; + union { + struct msdos_sb_info msdos_sb; +/* + struct fs ufs1_sb; + struct fs ufs2_sb; +*/ + } u; +}; + +#endif diff --git a/sys/include/vmm/paging.h b/sys/include/vmm/paging.h new file mode 100644 index 0000000..6186705 --- /dev/null +++ b/sys/include/vmm/paging.h @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _VMM_PAGING_H_ +#define _VMM_PAGING_H_ + +#include +#include +#include + +#define PAGE_SHIFT 12 // Page Shift +#define PAGE_SIZE 0x1000 // Page Size +#define PAGE_MASK (PAGE_SIZE-1) // Page Mask + +#define PD_INDEX(v_addr) (v_addr >> 22) // Calc Page Directory Index +#define PD_OFFSET(v_addr) (v_addr >> 0xA) // Calc Page Directory OFfset +#define PT_INDEX(v_addr) ((v_addr >> 12) & 0x03FF) // Calc Page Table Offset +#define PD_BASE_ADDR2 ((PAGE_SIZE << 0xA) + VMM_KERN_START) // Find Out What This Was For + +#define PD_BASE_ADDR 0xC0400000 // Page Directory Addressable Base Address +#define PT_BASE_ADDR 0xC0000000 // Page Table Addressable Base Address + +#define PD_ENTRIES (PAGE_SIZE/4) //Return Page Directory Entries +#define PT_ENTRIES (PAGE_SIZE/4) //Return Page Table Entries + +#define VM_THRD 0 // Thread +#define VM_TASK 1 // Task + +// Page Flags +#define PAGE_PRESENT 0x00000001 +#define PAGE_WRITE 0x00000002 +#define PAGE_USER 0x00000004 +#define PAGE_WRITE_THROUGH 0x00000008 +#define PAGE_CACHE_DISABLED 0x00000010 +#define PAGE_ACCESSED 0x00000020 +#define PAGE_DIRTY 0x00000040 +#define PAGE_GLOBAL 0x00000080 +#define PAGE_ 0x00000100 +#define PAGE_COW 0x00000200 +#define PAGE_STACK 0x00000400 +#define PAGE_WIRED 0x00000800 + +#define PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE|PAGE_USER) +#define KERNEL_PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE) + +#define trunc_page(x) ((x) & ~PAGE_MASK) +#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) + +#define ctob(x) ((x)<>PAGE_SHIFT) + +int vmmClearVirtualPage(uint32_t pageAddr); + +void *vmm_mapFromTask(pidType, void *, uint32_t); +void *vmm_copyVirtualSpace(pidType); +void *vmm_getFreePage(pidType); +void *vmm_getFreeKernelPage(pidType pid, uint16_t count); +void *vmm_createVirtualSpace(pidType); +void *vmm_getFreeVirtualPage(pidType, int, int); + +uint32_t vmm_getPhysicalAddr(uint32_t); +uint32_t vmm_getRealAddr(uint32_t); +int vmm_setPageAttributes(uint32_t, uint16_t); +int vmm_remapPage(uint32_t, uint32_t, uint16_t, pidType, int haveLock); +int vmm_pagingInit(); +void *vmm_getFreeMallocPage(uint16_t count); +//void vmm_pageFault( uint32_t, uint32_t, uint32_t ); +void vmm_pageFault(struct trapframe *, uint32_t); +void _vmm_pageFault(); +int mmap(struct thread *, struct sys_mmap_args *); +int obreak(struct thread *, struct obreak_args *); +int munmap(struct thread *, struct sys_munmap_args *); + +int vmm_cleanVirtualSpace(uint32_t); +void *vmm_getFreeVirtualPage(pidType pid, int count, int type); + +extern uint32_t *kernelPageDirectory; + +#endif diff --git a/sys/include/vmm/vmm.h b/sys/include/vmm/vmm.h new file mode 100644 index 0000000..bb769b1 --- /dev/null +++ b/sys/include/vmm/vmm.h @@ -0,0 +1,133 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _VMM_VMM_H +#define _VMM_VMM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define STACK_ADDR 0xBFFFFFFF//0xC800000 // Default App Stack Address + +#define memAvail 1 +#define memNotavail 2 +#define vmmID -3 + + /* + #define vmmMemoryMapAddr 0xE6667000 + #define VMM_MMAP_ADDR_PMODE2 0xE6667000 + */ + +#define VMM_MMAP_ADDR_PMODE VMM_KERN_START /* (PD_BASE_ADDR + PAGE_SIZE) */ +#define VMM_MMAP_ADDR_RMODE 0x101000 + +#define VMM_KERN_CODE_START 0x00000000 +#define VMM_KERN_CODE_END 0x007FEFFF + +#define VMM_USER_LDT 0x007FF000 + +#define VMM_USER_START 0x00800000 +#define VMM_USER_END 0xBFFFFFFF + +#define VMM_PAGE_DIRS 0xC0000000 +#define VMM_PAGE_DIR 0xC0400000 + +#define VMM_KERN_START 0xC0800000 //TMP ADDED 1000 +#define VMM_KERN_END 0xFDFFFFFF + +#define VMM_KERN_STACK_START 0xFE000000 +#define VMM_KERN_STACK_END 0xFFFFFFFF + + extern struct spinLock pdSpinLock; + + + struct freebsd6_mmap_args { + char addr_l_[PADL_(caddr_t)]; + caddr_t addr; + char addr_r_[PADR_(caddr_t)]; + + char len_l_[PADL_(size_t)]; + size_t len; + char len_r_[PADR_(size_t)]; + + char prot_l_[PADL_(int)]; + int prot; + char prot_r_[PADR_(int)]; + char flags_l_[PADL_(int)]; + + int flags; + char flags_r_[PADR_(int)]; + char fd_l_[PADL_(int)]; + int fd; + char fd_r_[PADR_(int)]; + + char pad_l_[PADL_(int)]; + int pad; + char pad_r_[PADR_(int)]; + + char pos_l_[PADL_(off_t)]; + off_t pos; + char pos_r_[PADR_(off_t)]; + }; + + typedef struct { + uint32_t pageAddr; + u_int16_t status; + u_int16_t reserved; + pid_t pid; + int cowCounter; + } mMap; + + typedef enum { + VMM_FREE = 0, VMM_KEEP = 1 + } unmapFlags_t; + + extern int numPages; + extern mMap *vmmMemoryMap; + + int vmm_init(); + int vmm_memMapInit(); + int countMemory(); + uint32_t vmm_findFreePage(pidType pid); + int freePage(uint32_t pageAddr); + int adjustCowCounter(uint32_t baseAddr, int adjustment); + void vmm_freeProcessPages(pidType pid); + + int vmm_allocPageTable(uint32_t, pidType); + void vmm_unmapPage(uint32_t, unmapFlags_t); + void vmm_unmapPages(void *, uint32_t, unmapFlags_t); + +#ifdef __cplusplus +} +#endif + +#endif // _VMM_VMM_H diff --git a/sys/init/main.c b/sys/init/main.c index 939622e..8b4ebbe 100644 --- a/sys/init/main.c +++ b/sys/init/main.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -109,8 +109,8 @@ union descriptorTableUnion *gdt __attribute__ ((packed)); } loadGDT = { (11 * sizeof(union descriptorTableUnion) - 1), ubixGDT }; -static char *argv_init[2] = { "init", NULL, }; /* ARGV For Initial Proccess */ -static char *envp_init[6] = { "HOME=/", "PWD=/", "PATH=/bin:/sbin:/usr/bin:/usr/sbin", "USER=root", "GROUP=admin", NULL, }; /* ENVP For Initial Proccess */ +static char *argv_init[2] = { "init", NULL, }; // ARGV For Initial Proccess +static char *envp_init[6] = { "HOME=/", "PWD=/", "PATH=/bin:/sbin:/usr/bin:/usr/sbin", "USER=root", "GROUP=admin", NULL, }; //ENVP For Initial Proccess struct bootinfo _bootinfo; char _kernelname[512]; diff --git a/sys/isa/fdc.c b/sys/isa/fdc.c index 3513d9d..8e53ed1 100644 --- a/sys/isa/fdc.c +++ b/sys/isa/fdc.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include static struct spinLock fdcSpinLock = SPIN_LOCK_INITIALIZER; diff --git a/sys/kernel/ld.c b/sys/kernel/ld.c index 571ef0a..725b6ad 100644 --- a/sys/kernel/ld.c +++ b/sys/kernel/ld.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sys/kernel/vfs_calls.c b/sys/kernel/vfs_calls.c index c9a14d1..dd465ec 100644 --- a/sys/kernel/vfs_calls.c +++ b/sys/kernel/vfs_calls.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include int sys_open(struct thread *td, struct sys_open_args *args) { int error = 0x0; diff --git a/sys/lib/kprintf.c b/sys/lib/kprintf.c index c3982a4..66d096a 100644 --- a/sys/lib/kprintf.c +++ b/sys/lib/kprintf.c @@ -30,7 +30,6 @@ #include #include #include -#include static char *ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper); @@ -223,8 +222,7 @@ u[j] = LHALF(u[j] + t); } q[j] = qhat; - } - while (++j <= m); /* D7: loop on j. */ + } while (++j <= m); /* D7: loop on j. */ /* * If caller wants the remainder, we have to calculate it as @@ -266,7 +264,6 @@ va_start(ap, fmt); retval = kvprintf(fmt, NULL, &buf, 10, ap); - buf[retval] = '\0'; va_end(ap); @@ -279,18 +276,13 @@ } int sprintf(char *buf, const char *fmt, ...) { - va_list args; int i; - va_start(args, fmt); - - /* i = vsprintf( buf, fmt, args ); */ +//i = vsprintf( buf, fmt, args ); i = kvprintf(fmt, NULL, buf, 10, args); - va_end(args); return (i); - } /* @@ -321,9 +313,7 @@ */ int kvprintf(const char *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap) { - #define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; } - char nbuf[MAXNBUF]; char *d; const char *p, *percent, *q; @@ -349,16 +339,13 @@ radix = 10; for (;;) { - padc = ' '; width = 0; - while ((ch = (u_char) *fmt++) != '%' || stop) { if (ch == '\0') return (retval); PCHAR(ch); } - percent = fmt - 1; qflag = 0; lflag = 0; @@ -374,307 +361,302 @@ jflag = 0; tflag = 0; zflag = 0; - reswitch: switch (ch = (u_char) *fmt++) { - case '.': - dot = 1; - goto reswitch; - case '#': - sharpflag = 1; - goto reswitch; - case '+': - sign = 1; - goto reswitch; - case '-': - ladjust = 1; - goto reswitch; - case '%': - PCHAR(ch) - ; - break; - case '*': - if (!dot) { - width = va_arg(ap, int); - if (width < 0) { - ladjust = !ladjust; - width = -width; - } - } - else { - dwidth = va_arg(ap, int); - } - goto reswitch; - case '0': - if (!dot) { - padc = '0'; + case '.': + dot = 1; goto reswitch; - } - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - for (n = 0;; ++fmt) { - n = n * 10 + ch - '0'; - ch = *fmt; - if (ch < '0' || ch > '9') + case '#': + sharpflag = 1; + goto reswitch; + case '+': + sign = 1; + goto reswitch; + case '-': + ladjust = 1; + goto reswitch; + case '%': + PCHAR(ch) + ; + break; + case '*': + if (!dot) { + width = va_arg(ap, int); + if (width < 0) { + ladjust = !ladjust; + width = -width; + } + } + else { + dwidth = va_arg(ap, int); + } + goto reswitch; + case '0': + if (!dot) { + padc = '0'; + goto reswitch; + } + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + for (n = 0;; ++fmt) { + n = n * 10 + ch - '0'; + ch = *fmt; + if (ch < '0' || ch > '9') + break; + } + if (dot) + dwidth = n; + else + width = n; + goto reswitch; + case 'b': + num = (u_int) va_arg(ap, int); + p = va_arg(ap, char *); + for (q = ksprintn(nbuf, num, *p++, NULL, 0); *q;) + PCHAR(*q--) + ; + + if (num == 0) break; - } - if (dot) - dwidth = n; - else - width = n; - goto reswitch; - case 'b': - num = (u_int) va_arg(ap, int); - p = va_arg(ap, char *); - for (q = ksprintn(nbuf, num, *p++, NULL, 0); *q;) - PCHAR(*q--) - ; - if (num == 0) - break; - - for (tmp = 0; *p;) { - n = *p++; - if (num & (1 << (n - 1))) { - PCHAR(tmp ? ',' : '<'); - for (; (n = *p) > ' '; ++p) - PCHAR(n); - tmp = 1; + for (tmp = 0; *p;) { + n = *p++; + if (num & (1 << (n - 1))) { + PCHAR(tmp ? ',' : '<'); + for (; (n = *p) > ' '; ++p) + PCHAR(n); + tmp = 1; + } + else + for (; *p > ' '; ++p) + continue; + } + if (tmp) + PCHAR('>') + ; + break; + case 'c': + PCHAR(va_arg(ap, int)) + ; + break; + case 'D': + up = va_arg(ap, u_char *); + p = va_arg(ap, char *); + if (!width) + width = 16; + while (width--) { + PCHAR(hex2ascii( *up >> 4 )); + PCHAR(hex2ascii( *up & 0x0f )); + up++; + if (width) + for (q = p; *q; q++) + PCHAR(*q); + } + break; + case 'd': + case 'i': + base = 10; + sign = 1; + goto handle_sign; + case 'h': + if (hflag) { + hflag = 0; + cflag = 1; } else - for (; *p > ' '; ++p) - continue; - } - if (tmp) - PCHAR('>') - ; + hflag = 1; + goto reswitch; + case 'j': + jflag = 1; + goto reswitch; + case 'l': + if (lflag) { + lflag = 0; + qflag = 1; + } + else + lflag = 1; + goto reswitch; + case 'n': + if (jflag) + *(va_arg(ap, intmax_t *)) = retval; + else if (qflag) + *(va_arg(ap, quad_t *)) = retval; + else if (lflag) + *(va_arg(ap, long *)) = retval; + else if (zflag) + *(va_arg(ap, size_t *)) = retval; + else if (hflag) + *(va_arg(ap, short *)) = retval; + else if (cflag) + *(va_arg(ap, char *)) = retval; + else + *(va_arg(ap, int *)) = retval; break; - case 'c': - PCHAR(va_arg(ap, int)) - ; - break; - case 'D': - up = va_arg(ap, u_char *); - p = va_arg(ap, char *); - if (!width) - width = 16; - while (width--) { - asm("nop"); - PCHAR(hex2ascii( *up >> 4 )); - asm("nop"); - PCHAR(hex2ascii( *up & 0x0f )); - asm("nop"); - up++; - if (width) - for (q = p; *q; q++) - PCHAR(*q); - } - break; - case 'd': - case 'i': - base = 10; - sign = 1; - goto handle_sign; - case 'h': - if (hflag) { - hflag = 0; - cflag = 1; - } - else - hflag = 1; - goto reswitch; - case 'j': - jflag = 1; - goto reswitch; - case 'l': - if (lflag) { - lflag = 0; + case 'o': + base = 8; + goto handle_nosign; + case 'p': + base = 16; + sharpflag = (width == 0); + sign = 0; + num = (uintptr_t) va_arg(ap, void *); + goto number; + case 'q': qflag = 1; - } - else - lflag = 1; - goto reswitch; - case 'n': - if (jflag) - *(va_arg(ap, intmax_t *)) = retval; - else if (qflag) - *(va_arg(ap, quad_t *)) = retval; - else if (lflag) - *(va_arg(ap, long *)) = retval; - else if (zflag) - *(va_arg(ap, size_t *)) = retval; - else if (hflag) - *(va_arg(ap, short *)) = retval; - else if (cflag) - *(va_arg(ap, char *)) = retval; - else - *(va_arg(ap, int *)) = retval; + goto reswitch; + case 'r': + base = radix; + if (sign) + goto handle_sign; + goto handle_nosign; + case 's': + p = va_arg(ap, char *); + if (p == NULL) + p = "(null)"; + if (!dot) + n = strlen(p); + else + for (n = 0; n < dwidth && p[n]; n++) + continue; + + width -= n; + + if (!ladjust && width > 0) + while (width--) + PCHAR(padc) + ; + while (n--) + PCHAR(*p++) + ; + if (ladjust && width > 0) + while (width--) + PCHAR(padc) + ; break; - case 'o': - base = 8; - goto handle_nosign; - case 'p': - base = 16; - sharpflag = (width == 0); - sign = 0; - num = (uintptr_t) va_arg(ap, void *); - goto number; - case 'q': - qflag = 1; - goto reswitch; - case 'r': - base = radix; - if (sign) + case 't': + tflag = 1; + goto reswitch; + case 'u': + base = 10; + goto handle_nosign; + case 'X': + upper = 1; + case 'x': + base = 16; + goto handle_nosign; + case 'y': + base = 16; + sign = 1; goto handle_sign; - goto handle_nosign; - case 's': - p = va_arg(ap, char *); - if (p == NULL) - p = "(null)"; - if (!dot) - n = strlen(p); - else - for (n = 0; n < dwidth && p[n]; n++) - continue; - - width -= n; - - if (!ladjust && width > 0) - while (width--) - PCHAR(padc) - ; - while (n--) - PCHAR(*p++) - ; - if (ladjust && width > 0) - while (width--) - PCHAR(padc) - ; - break; - case 't': - tflag = 1; - goto reswitch; - case 'u': - base = 10; - goto handle_nosign; - case 'X': - upper = 1; - case 'x': - base = 16; - goto handle_nosign; - case 'y': - base = 16; - sign = 1; - goto handle_sign; - case 'z': - zflag = 1; - goto reswitch; - handle_nosign: sign = 0; - if (jflag) - num = va_arg(ap, uintmax_t); - else if (qflag) - num = va_arg(ap, u_quad_t); - else if (tflag) - num = va_arg(ap, __ptrdiff_t); - else if (lflag) - num = va_arg(ap, u_long); - else if (zflag) - num = va_arg(ap, size_t); - else if (hflag) - num = (u_short) va_arg(ap, int); - else if (cflag) - num = (u_char) va_arg(ap, int); - else - num = va_arg(ap, u_int); - goto number; - handle_sign: if (jflag) - num = va_arg(ap, intmax_t); - else if (qflag) - num = va_arg(ap, quad_t); - else if (tflag) - num = va_arg(ap, __ptrdiff_t); - else if (lflag) - num = va_arg(ap, long); - else if (zflag) - num = va_arg(ap, ssize_t); - else if (hflag) - num = (short) va_arg(ap, int); - else if (cflag) - num = (char) va_arg(ap, int); - else - num = va_arg(ap, int); - number: if (sign && (intmax_t) num < 0) { - neg = 1; - num = -(intmax_t) num; - } - p = ksprintn(nbuf, num, base, &n, upper); - tmp = 0; - if (sharpflag && num != 0) { - if (base == 8) + case 'z': + zflag = 1; + goto reswitch; + handle_nosign: sign = 0; + if (jflag) + num = va_arg(ap, uintmax_t); + else if (qflag) + num = va_arg(ap, u_quad_t); + else if (tflag) + num = va_arg(ap, ptrdiff_t); + else if (lflag) + num = va_arg(ap, u_long); + else if (zflag) + num = va_arg(ap, size_t); + else if (hflag) + num = (u_short) va_arg(ap, int); + else if (cflag) + num = (u_char) va_arg(ap, int); + else + num = va_arg(ap, u_int); + goto number; + handle_sign: if (jflag) + num = va_arg(ap, intmax_t); + else if (qflag) + num = va_arg(ap, quad_t); + else if (tflag) + num = va_arg(ap, ptrdiff_t); + else if (lflag) + num = va_arg(ap, long); + else if (zflag) + num = va_arg(ap, ssize_t); + else if (hflag) + num = (short) va_arg(ap, int); + else if (cflag) + num = (char) va_arg(ap, int); + else + num = va_arg(ap, int); + number: if (sign && (intmax_t) num < 0) { + neg = 1; + num = -(intmax_t) num; + } + p = ksprintn(nbuf, num, base, &n, upper); + tmp = 0; + if (sharpflag && num != 0) { + if (base == 8) + tmp++; + else if (base == 16) + tmp += 2; + } + if (neg) tmp++; - else if (base == 16) - tmp += 2; - } - if (neg) - tmp++; - if (!ladjust && padc == '0') - dwidth = width - tmp; - width -= tmp + imax(dwidth, n); - dwidth -= n; - if (!ladjust) - while (width-- > 0) - PCHAR(' ') - ; - if (neg) - PCHAR('-') - ; - if (sharpflag && num != 0) { - if (base == 8) { - PCHAR('0'); + if (!ladjust && padc == '0') + dwidth = width - tmp; + width -= tmp + imax(dwidth, n); + dwidth -= n; + if (!ladjust) + while (width-- > 0) + PCHAR(' ') + ; + if (neg) + PCHAR('-') + ; + if (sharpflag && num != 0) { + if (base == 8) { + PCHAR('0'); + } + else if (base == 16) { + PCHAR('0'); + PCHAR('x'); + } } - else if (base == 16) { - PCHAR('0'); - PCHAR('x'); - } - } - while (dwidth-- > 0) - PCHAR('0') - ; + while (dwidth-- > 0) + PCHAR('0') + ; - while (*p) - PCHAR(*p--) - ; + while (*p) + PCHAR(*p--) + ; - if (ladjust) - while (width-- > 0) - PCHAR(' ') - ; + if (ladjust) + while (width-- > 0) + PCHAR(' ') + ; break; - default: - while (percent < fmt) - PCHAR(*percent++) - ; - /* - * Since we ignore a formatting argument it is no - * longer safe to obey the remaining formatting - * arguments as the arguments will no longer match - * the format specs. - */ - stop = 1; + default: + while (percent < fmt) + PCHAR(*percent++) + ; + /* + * Since we ignore a formatting argument it is no + * longer safe to obey the remaining formatting + * arguments as the arguments will no longer match + * the format specs. + */ + stop = 1; break; } } #undef PCHAR return (0); - } static char *ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper) { @@ -686,8 +668,7 @@ do { c = hex2ascii(num % base); *++p = upper ? toupper(c) : c; - } - while (num /= base); + } while (num /= base); if (lenp) *lenp = p - nbuf; diff --git a/sys/lib/string.c b/sys/lib/string.c index 4864390..19fcbd1 100644 --- a/sys/lib/string.c +++ b/sys/lib/string.c @@ -26,266 +26,11 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include +#include -const char hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; +u_char const bcd2bin_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 0, 0, 0, 0, 0, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 0, 0, 0, 0, 0, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 0, 0, 0, 0, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 0, 0, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 0, 0, 0, 0, 0, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 }; -const u_char bcd2bin_data[] = { - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 0, - 0, - 0, - 0, - 0, - 0, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 0, - 0, - 0, - 0, - 0, - 0, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 0, - 0, - 0, - 0, - 0, - 0, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 0, - 0, - 0, - 0, - 0, - 0, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 0, - 0, - 0, - 0, - 0, - 0, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 0, - 0, - 0, - 0, - 0, - 0, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 0, - 0, - 0, - 0, - 0, - 0, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 0, - 0, - 0, - 0, - 0, - 0, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 0, - 0, - 0, - 0, - 0, - 0, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99 }; +u_char const bin2bcd_data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99 }; -const u_char bin2bcd_data[] = { - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - 0x06, - 0x07, - 0x08, - 0x09, - 0x10, - 0x11, - 0x12, - 0x13, - 0x14, - 0x15, - 0x16, - 0x17, - 0x18, - 0x19, - 0x20, - 0x21, - 0x22, - 0x23, - 0x24, - 0x25, - 0x26, - 0x27, - 0x28, - 0x29, - 0x30, - 0x31, - 0x32, - 0x33, - 0x34, - 0x35, - 0x36, - 0x37, - 0x38, - 0x39, - 0x40, - 0x41, - 0x42, - 0x43, - 0x44, - 0x45, - 0x46, - 0x47, - 0x48, - 0x49, - 0x50, - 0x51, - 0x52, - 0x53, - 0x54, - 0x55, - 0x56, - 0x57, - 0x58, - 0x59, - 0x60, - 0x61, - 0x62, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x70, - 0x71, - 0x72, - 0x73, - 0x74, - 0x75, - 0x76, - 0x77, - 0x78, - 0x79, - 0x80, - 0x81, - 0x82, - 0x83, - 0x84, - 0x85, - 0x86, - 0x87, - 0x88, - 0x89, - 0x90, - 0x91, - 0x92, - 0x93, - 0x94, - 0x95, - 0x96, - 0x97, - 0x98, - 0x99 }; - +/* This is actually used with radix [2..36] */ +char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; diff --git a/sys/net/api/Makefile b/sys/net/api/Makefile index 8ce3ea4..20ec808 100644 --- a/sys/net/api/Makefile +++ b/sys/net/api/Makefile @@ -13,13 +13,13 @@ # Compile Types .cc.o: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -c -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -c -o $@ $< .cc.s: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -S -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -S -o $@ $< .c.o: - $(CC) ${CFLAGS} -I../../../include -c -o $@ $< + $(CC) ${CFLAGS} -I../../include -c -o $@ $< .c.s: - $(CC) ${CFLAGS}-I../../../include -S -o $@ $< + $(CC) ${CFLAGS}-I../../include -S -o $@ $< .S.o: $(CC) ${CFLAGS}-c -o $@ $< diff --git a/sys/net/core/Makefile b/sys/net/core/Makefile index 08481c0..103838a 100644 --- a/sys/net/core/Makefile +++ b/sys/net/core/Makefile @@ -12,13 +12,13 @@ # Compile Types .cc.o: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -c -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -c -o $@ $< .cc.s: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -S -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -S -o $@ $< .c.o: - $(CC) ${CFLAGS} -I../../../include -c -o $@ $< + $(CC) ${CFLAGS} -I../../include -c -o $@ $< .c.s: - $(CC) ${CFLAGS} -I../../../include -S -o $@ $< + $(CC) ${CFLAGS} -I../../include -S -o $@ $< .S.o: $(CC) ${CFLAGS} -c -o $@ $< diff --git a/sys/net/core/def.c b/sys/net/core/def.c index d1dbb9e..bfa98af 100644 --- a/sys/net/core/def.c +++ b/sys/net/core/def.c @@ -61,8 +61,6 @@ #include "net/opt.h" #include "net/def.h" -#include -#include #include #if BYTE_ORDER == LITTLE_ENDIAN diff --git a/sys/net/core/init.c b/sys/net/core/init.c index a2271c7..20c7be8 100644 --- a/sys/net/core/init.c +++ b/sys/net/core/init.c @@ -31,7 +31,6 @@ #include "net/opt.h" -#include #include #include "net/init.h" diff --git a/sys/net/core/ipv4/Makefile b/sys/net/core/ipv4/Makefile index bcbea86..008e01a 100644 --- a/sys/net/core/ipv4/Makefile +++ b/sys/net/core/ipv4/Makefile @@ -12,13 +12,13 @@ # Compile Types .cc.o: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../../include -c -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -c -o $@ $< .cc.s: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../../include -S -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -S -o $@ $< .c.o: - $(CC) ${CFLAGS} -I../../../../include -c -o $@ $< + $(CC) ${CFLAGS} -I../../../include -c -o $@ $< .c.s: - $(CC) ${CFLAGS} -I../../../../include -S -o $@ $< + $(CC) ${CFLAGS} -I../../../include -S -o $@ $< .S.o: $(CC) ${CFLAGS} -c -o $@ $< diff --git a/sys/net/core/ipv6/Makefile b/sys/net/core/ipv6/Makefile index f0ca889..71d058c 100644 --- a/sys/net/core/ipv6/Makefile +++ b/sys/net/core/ipv6/Makefile @@ -12,13 +12,13 @@ # Compile Types .cc.o: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../../include -c -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -c -o $@ $< .cc.s: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../../include -S -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -S -o $@ $< .c.o: - $(CC) ${CFLAGS} -I../../../../include -c -o $@ $< + $(CC) ${CFLAGS} -I../../../include -c -o $@ $< .c.s: - $(CC) ${CFLAGS} -I../../../../include -S -o $@ $< + $(CC) ${CFLAGS} -I../../../include -S -o $@ $< .S.o: $(CC) ${CFLAGS} -c -o $@ $< diff --git a/sys/net/net/Makefile b/sys/net/net/Makefile index f858454..a3489aa 100644 --- a/sys/net/net/Makefile +++ b/sys/net/net/Makefile @@ -13,13 +13,13 @@ # Compile Types .cc.o: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -c -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -c -o $@ $< .cc.s: - $(CXX) ${CFLAGS} -DNOBOOL-I../../../include -S -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL-I../../include -S -o $@ $< .c.o: - $(CC) ${CFLAGS} -I../../../include -c -o $@ $< + $(CC) ${CFLAGS} -I../../include -c -o $@ $< .c.s: - $(CC) ${CFLAGS} -I../../../include -S -o $@ $< + $(CC) ${CFLAGS} -I../../include -S -o $@ $< .S.o: $(CC) ${CFLAGS} -c -o $@ $< diff --git a/sys/net/netif/Makefile b/sys/net/netif/Makefile old mode 100644 new mode 100755 index e9a5b4e..d90ab2f --- a/sys/net/netif/Makefile +++ b/sys/net/netif/Makefile @@ -13,13 +13,13 @@ # Compile Types .cc.o: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -c -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -c -o $@ $< .cc.s: - $(CXX) ${CFLAGS} -DNOBOOL -I../../../include -S -o $@ $< + $(CXX) ${CFLAGS} -DNOBOOL -I../../include -S -o $@ $< .c.o: - $(CC) ${CFLAGS} -I../../../include -c -o $@ $< + $(CC) ${CFLAGS} -I../../include -c -o $@ $< .c.s: - $(CC) ${CFLAGS} -I../../../include -S -o $@ $< + $(CC) ${CFLAGS} -I../../include -S -o $@ $< .S.o: $(CC) ${CFLAGS} -c -o $@ $< diff --git a/sys/pci/hd.c b/sys/pci/hd.c index a37c2ba..be6db78 100644 --- a/sys/pci/hd.c +++ b/sys/pci/hd.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/sys/sde/ogDisplay_UbixOS.cc b/sys/sde/ogDisplay_UbixOS.cc old mode 100644 new mode 100755 diff --git a/sys/vmm/copyvirtualspace.c b/sys/vmm/copyvirtualspace.c index 78936c1..dba354b 100644 --- a/sys/vmm/copyvirtualspace.c +++ b/sys/vmm/copyvirtualspace.c @@ -31,6 +31,7 @@ #include #include #include +#include static struct spinLock cvsSpinLock = SPIN_LOCK_INITIALIZER; @@ -49,259 +50,227 @@ ************************************************************************/ void *vmm_copyVirtualSpace(pidType pid) { - void *newPageDirectoryAddress = 0x0; + void *newPageDirectoryAddress = 0x0; - uint32_t *parentPageDirectory = 0x0, *newPageDirectory = 0x0; - uint32_t *parentPageTable = 0x0, *newPageTable = 0x0; - uint32_t *parentStackPage = 0x0, *newStackPage = 0x0; - uint16_t x = 0, i = 0, s = 0; + uint32_t *parentPageDirectory = 0x0, *newPageDirectory = 0x0; + uint32_t *parentPageTable = 0x0, *newPageTable = 0x0; + uint32_t *parentStackPage = 0x0, *newStackPage = 0x0; + uint16_t x = 0, i = 0, s = 0; - spinLock(&cvsSpinLock); + spinLock(&cvsSpinLock); - /* Set Address Of Parent Page Directory */ - parentPageDirectory = (uint32_t *) PD_BASE_ADDR; + /* Set Address Of Parent Page Directory */ + parentPageDirectory = (uint32_t *) PD_BASE_ADDR; - /* Allocate A New Page For The New Page Directory */ - if ((newPageDirectory = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) - kpanic("Error: newPageDirectory == NULL, File: %s, Line: %i\n", - __FILE__, __LINE__); + /* Allocate A New Page For The New Page Directory */ + if ((newPageDirectory = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newPageDirectory == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - /* Set newPageDirectoryAddress To The Newly Created Page Directories Page */ - newPageDirectoryAddress = (void *) vmm_getPhysicalAddr( - (uint32_t) newPageDirectory); + /* Set newPageDirectoryAddress To The Newly Created Page Directories Page */ + newPageDirectoryAddress = (void *) vmm_getPhysicalAddr((uint32_t) newPageDirectory); - /* First Set Up A Flushed Page Directory */ - bzero(newPageDirectory, PAGE_SIZE); + /* First Set Up A Flushed Page Directory */ + bzero(newPageDirectory, PAGE_SIZE); - /* Map Kernel Code Region Entries 0 & 1 */ - newPageDirectory[0] = parentPageDirectory[0]; - //XXX: We Dont Need This - newPageDirectory[1] = parentPageDirectory[1]; + /* Map Kernel Code Region Entries 0 & 1 */ + newPageDirectory[0] = parentPageDirectory[0]; + //XXX: We Dont Need This - newPageDirectory[1] = parentPageDirectory[1]; - if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) - kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, - __LINE__); + if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * 1)); + parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * 1)); - for (x = 0; x < PT_ENTRIES; x++) { - if (((parentPageTable[x]) & PAGE_PRESENT) == PAGE_PRESENT) { + for (x = 0; x < PT_ENTRIES; x++) { + if (((parentPageTable[x]) & PAGE_PRESENT) == PAGE_PRESENT) { - /* Set Page To COW In Parent And Child Space */ - newPageTable[x] = (((uint32_t) parentPageTable[x] & 0xFFFFF000) - | (KERNEL_PAGE_DEFAULT | PAGE_COW)); + /* Set Page To COW In Parent And Child Space */ + newPageTable[x] = (((uint32_t) parentPageTable[x] & 0xFFFFF000) | (KERNEL_PAGE_DEFAULT | PAGE_COW)); - /* Increment The COW Counter For This Page */ - if (((uint32_t) parentPageTable[x] & PAGE_COW) == PAGE_COW) { - adjustCowCounter(((uint32_t) parentPageTable[x] & 0xFFFFF000), - 1); - } else { - /* Add Two If This Is The First Time Setting To COW */ - adjustCowCounter(((uint32_t) parentPageTable[x] & 0xFFFFF000), - 2); - parentPageTable[x] |= PAGE_COW; // newPageTable[i]; - } + /* Increment The COW Counter For This Page */ + if (((uint32_t) parentPageTable[x] & PAGE_COW) == PAGE_COW) { + adjustCowCounter(((uint32_t) parentPageTable[x] & 0xFFFFF000), 1); + } + else { + /* Add Two If This Is The First Time Setting To COW */ + adjustCowCounter(((uint32_t) parentPageTable[x] & 0xFFFFF000), 2); + parentPageTable[x] |= PAGE_COW; // newPageTable[i]; + } - } else - newPageTable[x] = parentPageTable[x]; - } + } + else + newPageTable[x] = parentPageTable[x]; + } - newPageDirectory[1] = (vmm_getPhysicalAddr((uint32_t) newPageTable) - | KERNEL_PAGE_DEFAULT); + newPageDirectory[1] = (vmm_getPhysicalAddr((uint32_t) newPageTable) | KERNEL_PAGE_DEFAULT); - vmm_unmapPage((uint32_t) newPageTable, 1); + vmm_unmapPage((uint32_t) newPageTable, 1); - newPageTable = 0x0; + newPageTable = 0x0; - /* Map The Kernel Memory Region Entry 770 Address 0xC0800000 */ - for (x = PD_INDEX(VMM_KERN_START); x <= PD_INDEX(VMM_KERN_END); x++) - newPageDirectory[x] = parentPageDirectory[x]; + /* Map The Kernel Memory Region Entry 770 Address 0xC0800000 */ + for (x = PD_INDEX(VMM_KERN_START); x <= PD_INDEX(VMM_KERN_END); x++) + newPageDirectory[x] = parentPageDirectory[x]; - /* Map The Kernel Stack Region */ - for (x = PD_INDEX(VMM_KERN_STACK_START); x <= PD_INDEX(VMM_KERN_STACK_END); - x++) { - if ((parentPageDirectory[x] & PAGE_PRESENT) == PAGE_PRESENT) { - /* Set Parent To Propper Page Table */ - parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * x)); + /* Map The Kernel Stack Region */ + for (x = PD_INDEX(VMM_KERN_STACK_START); x <= PD_INDEX(VMM_KERN_STACK_END); x++) { + if ((parentPageDirectory[x] & PAGE_PRESENT) == PAGE_PRESENT) { + /* Set Parent To Propper Page Table */ + parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * x)); - /* Allocate A New Page Table */ - if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) - == 0x0) - kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", - __FILE__, __LINE__); + /* Allocate A New Page Table */ + if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - bzero(newPageTable, PAGE_SIZE); + bzero(newPageTable, PAGE_SIZE); - for (i = 0; i < PT_ENTRIES; i++) { - if ((parentPageTable[i] & PAGE_PRESENT) == PAGE_PRESENT) { + for (i = 0; i < PT_ENTRIES; i++) { + if ((parentPageTable[i] & PAGE_PRESENT) == PAGE_PRESENT) { - /* Alloc A New Page For This Stack Page */ - if ((newStackPage = (uint32_t *) vmm_getFreeKernelPage(pid, - 1)) == 0x0) - kpanic( - "Error: newStackPage == NULL, File: %s, Line: %i\n", - __FILE__, __LINE__); + /* Alloc A New Page For This Stack Page */ + if ((newStackPage = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newStackPage == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - /* Set Pointer To Parents Stack Page */ - parentStackPage = (uint32_t *) (((PAGE_SIZE * PD_ENTRIES) - * x) + (PAGE_SIZE * i)); + /* Set Pointer To Parents Stack Page */ + parentStackPage = (uint32_t *) (((PAGE_SIZE * PD_ENTRIES) * x) + (PAGE_SIZE * i)); - /* Copy The Stack Byte For Byte (I Should Find A Faster Way) */ - memcpy(newStackPage, parentStackPage, PAGE_SIZE); + /* Copy The Stack Byte For Byte (I Should Find A Faster Way) */ + memcpy(newStackPage, parentStackPage, PAGE_SIZE); - /* Insert New Stack Into Page Table */ - newPageTable[i] = - (vmm_getPhysicalAddr((uint32_t) newStackPage) - | PAGE_DEFAULT | PAGE_STACK); + /* Insert New Stack Into Page Table */ + newPageTable[i] = (vmm_getPhysicalAddr((uint32_t) newStackPage) | PAGE_DEFAULT | PAGE_STACK); - /* Unmap From Kernel Space */ - vmm_unmapPage((uint32_t) newStackPage, 1); - } - } - /* Put New Page Table Into New Page Directory */ - newPageDirectory[x] = (vmm_getPhysicalAddr((uint32_t) newPageTable) - | PAGE_DEFAULT); - /* Unmap Page From Kernel Space But Keep It Marked As Not Avail */ - vmm_unmapPage((uint32_t) newPageTable, 1); - } - } + /* Unmap From Kernel Space */ + vmm_unmapPage((uint32_t) newStackPage, 1); + } + } + /* Put New Page Table Into New Page Directory */ + newPageDirectory[x] = (vmm_getPhysicalAddr((uint32_t) newPageTable) | PAGE_DEFAULT); + /* Unmap Page From Kernel Space But Keep It Marked As Not Avail */ + vmm_unmapPage((uint32_t) newPageTable, 1); + } + } - /* - * Now For The Fun Stuff For Page Tables 2-767 We Must Map These And Set - * The Permissions On Every Mapped Pages To COW This Will Conserve Memory - * Because The Two VM Spaces Will Be Sharing Pages Unless an EXECVE Happens - * - * We start at the 4MB boundary as the first 4MB is special - */ + /* + * Now For The Fun Stuff For Page Tables 2-767 We Must Map These And Set + * The Permissions On Every Mapped Pages To COW This Will Conserve Memory + * Because The Two VM Spaces Will Be Sharing Pages Unless an EXECVE Happens + * + * We start at the 4MB boundary as the first 4MB is special + */ - for (x = PD_INDEX(VMM_USER_START); x <= PD_INDEX(VMM_USER_END); x++) { + for (x = PD_INDEX(VMM_USER_START); x <= PD_INDEX(VMM_USER_END); x++) { - /* If Page Table Exists Map It */ - if ((parentPageDirectory[x] & PAGE_PRESENT) == PAGE_PRESENT) { + /* If Page Table Exists Map It */ + if ((parentPageDirectory[x] & PAGE_PRESENT) == PAGE_PRESENT) { - /* Set Parent To Propper Page Table */ - parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * x)); + /* Set Parent To Propper Page Table */ + parentPageTable = (uint32_t *) (PT_BASE_ADDR + (PAGE_SIZE * x)); - /* Allocate A New Page Table */ - if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) - == 0x0) - kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", - __FILE__, __LINE__); + /* Allocate A New Page Table */ + if ((newPageTable = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newPageTable == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - bzero(newPageTable, PAGE_SIZE); + bzero(newPageTable, PAGE_SIZE); - /* Set Parent And New Pages To COW */ - for (i = 0; i < PD_ENTRIES; i++) { + /* Set Parent And New Pages To COW */ + for (i = 0; i < PD_ENTRIES; i++) { - /* If Page Is Mapped */ - if ((parentPageTable[i] & PAGE_PRESENT) == PAGE_PRESENT) { + /* If Page Is Mapped */ + if ((parentPageTable[i] & PAGE_PRESENT) == PAGE_PRESENT) { - /* Check To See If Its A Stack Page */ - if (((uint32_t) parentPageTable[i] & PAGE_STACK) - == PAGE_STACK) { + /* Check To See If Its A Stack Page */ + if (((uint32_t) parentPageTable[i] & PAGE_STACK) == PAGE_STACK) { - /* Alloc A New Page For This Stack Page */ - if ((newStackPage = (uint32_t *) vmm_getFreeKernelPage( - pid, 1)) == 0x0) - kpanic( - "Error: newStackPage == NULL, File: %s, Line: %i\n", - __FILE__, __LINE__); + /* Alloc A New Page For This Stack Page */ + if ((newStackPage = (uint32_t *) vmm_getFreeKernelPage(pid, 1)) == 0x0) + kpanic("Error: newStackPage == NULL, File: %s, Line: %i\n", __FILE__, __LINE__); - /* Set Pointer To Parents Stack Page */ - parentStackPage = - (uint32_t *) (((PAGE_SIZE * PD_ENTRIES) * x) - + (PAGE_SIZE * i)); + /* Set Pointer To Parents Stack Page */ + parentStackPage = (uint32_t *) (((PAGE_SIZE * PD_ENTRIES) * x) + (PAGE_SIZE * i)); - /* Copy The Stack Byte For Byte (I Should Find A Faster Way) */ - memcpy(newStackPage, parentStackPage, PAGE_SIZE); + /* Copy The Stack Byte For Byte (I Should Find A Faster Way) */ + memcpy(newStackPage, parentStackPage, PAGE_SIZE); - /* Insert New Stack Into Page Table */ - newPageTable[i] = (vmm_getPhysicalAddr( - (uint32_t) newStackPage) | PAGE_DEFAULT - | PAGE_STACK); + /* Insert New Stack Into Page Table */ + newPageTable[i] = (vmm_getPhysicalAddr((uint32_t) newStackPage) | PAGE_DEFAULT | PAGE_STACK); - /* Unmap From Kernel Space */ - vmm_unmapPage((uint32_t) newStackPage, 1); + /* Unmap From Kernel Space */ + vmm_unmapPage((uint32_t) newStackPage, 1); - } else { + } + else { - /* Set Page To COW In Parent And Child Space */ - newPageTable[i] = (((uint32_t) parentPageTable[i] - & 0xFFFFF000) | (PAGE_DEFAULT | PAGE_COW)); + /* Set Page To COW In Parent And Child Space */ + newPageTable[i] = (((uint32_t) parentPageTable[i] & 0xFFFFF000) | (PAGE_DEFAULT | PAGE_COW)); - /* Increment The COW Counter For This Page */ - if (((uint32_t) parentPageTable[i] & PAGE_COW) - == PAGE_COW) { - adjustCowCounter( - ((uint32_t) parentPageTable[i] & 0xFFFFF000), - 1); - } else { - /* Add Two If This Is The First Time Setting To COW */ - adjustCowCounter( - ((uint32_t) parentPageTable[i] & 0xFFFFF000), - 2); - parentPageTable[i] |= PAGE_COW; // newPageTable[i]; - } - } - } else { - newPageTable[i] = (uint32_t) 0x0; - } - } + /* Increment The COW Counter For This Page */ + if (((uint32_t) parentPageTable[i] & PAGE_COW) == PAGE_COW) { + adjustCowCounter(((uint32_t) parentPageTable[i] & 0xFFFFF000), 1); + } + else { + /* Add Two If This Is The First Time Setting To COW */ + adjustCowCounter(((uint32_t) parentPageTable[i] & 0xFFFFF000), 2); + parentPageTable[i] |= PAGE_COW; // newPageTable[i]; + } + } + } + else { + newPageTable[i] = (uint32_t) 0x0; + } + } - /* Put New Page Table Into New Page Directory */ - newPageDirectory[x] = (vmm_getPhysicalAddr((uint32_t) newPageTable) - | PAGE_DEFAULT); - /* Unmap Page From Kernel Space But Keep It Marked As Not Avail */ - vmm_unmapPage((uint32_t) newPageTable, 1); - } - } + /* Put New Page Table Into New Page Directory */ + newPageDirectory[x] = (vmm_getPhysicalAddr((uint32_t) newPageTable) | PAGE_DEFAULT); + /* Unmap Page From Kernel Space But Keep It Marked As Not Avail */ + vmm_unmapPage((uint32_t) newPageTable, 1); + } + } - /* - * Allocate A New Page For The The First Page Table Where We Will Map The - * Lower Region First 4MB - */ + /* + * Allocate A New Page For The The First Page Table Where We Will Map The + * Lower Region First 4MB + */ - /* - * - * Map Page Directory Into VM Space - * First Page After Page Tables - * This must be mapped into the page directory before we map all 1024 page directories into the memory space - */ - newPageTable = (uint32_t *) vmm_getFreePage(pid); + /* + * + * Map Page Directory Into VM Space + * First Page After Page Tables + * This must be mapped into the page directory before we map all 1024 page directories into the memory space + */ + newPageTable = (uint32_t *) vmm_getFreePage(pid); - newPageDirectory[PD_INDEX(PD_BASE_ADDR)] = (uint32_t) (vmm_getPhysicalAddr( - (uint32_t) newPageTable) | PAGE_DEFAULT); + newPageDirectory[PD_INDEX(PD_BASE_ADDR)] = (uint32_t) (vmm_getPhysicalAddr((uint32_t) newPageTable) | PAGE_DEFAULT); - newPageTable[0] = (uint32_t) ((uint32_t) (newPageDirectoryAddress) - | PAGE_DEFAULT); + newPageTable[0] = (uint32_t) ((uint32_t) (newPageDirectoryAddress) | PAGE_DEFAULT); - vmm_unmapPage((uint32_t) newPageTable, 1); + vmm_unmapPage((uint32_t) newPageTable, 1); - /* - * - * Map Page Tables Into VM Space - * The First Page Table (4MB) Maps To All Page Directories - * - */ + /* + * + * Map Page Tables Into VM Space + * The First Page Table (4MB) Maps To All Page Directories + * + */ - newPageTable = (uint32_t *) vmm_getFreePage(pid); + newPageTable = (uint32_t *) vmm_getFreePage(pid); - newPageDirectory[PD_INDEX(PT_BASE_ADDR)] = (uint32_t) (vmm_getPhysicalAddr( - (uint32_t) newPageTable) | PAGE_DEFAULT); + newPageDirectory[PD_INDEX(PT_BASE_ADDR)] = (uint32_t) (vmm_getPhysicalAddr((uint32_t) newPageTable) | PAGE_DEFAULT); - /* Flush The Page From Garbage In Memory */ - bzero(newPageTable, PAGE_SIZE); + /* Flush The Page From Garbage In Memory */ + bzero(newPageTable, PAGE_SIZE); - for (x = 0; x < PD_ENTRIES; x++) - newPageTable[x] = newPageDirectory[x]; + for (x = 0; x < PD_ENTRIES; x++) + newPageTable[x] = newPageDirectory[x]; - /* Unmap Page From Virtual Space */ - vmm_unmapPage((uint32_t) newPageTable, 1); + /* Unmap Page From Virtual Space */ + vmm_unmapPage((uint32_t) newPageTable, 1); - /* Now We Are Done With The Page Directory So Lets Unmap That Too */ - vmm_unmapPage((uint32_t) newPageDirectory, 1); + /* Now We Are Done With The Page Directory So Lets Unmap That Too */ + vmm_unmapPage((uint32_t) newPageDirectory, 1); - spinUnlock(&cvsSpinLock); + spinUnlock(&cvsSpinLock); - /* Return Physical Address Of Page Directory */ - return (newPageDirectoryAddress); + /* Return Physical Address Of Page Directory */ + return (newPageDirectoryAddress); } diff --git a/sys/vmm/vmm_memory.c b/sys/vmm/vmm_memory.c index ee021b5..56e2ac8 100644 --- a/sys/vmm/vmm_memory.c +++ b/sys/vmm/vmm_memory.c @@ -36,7 +36,7 @@ #include //MrOlsen (2016-01-11) NOTE: Need to Seperate Out CPU Specific Stuff Over Time -#include +#include static uint32_t freePages = 0; static struct spinLock vmmSpinLock = SPIN_LOCK_INITIALIZER; @@ -92,9 +92,6 @@ systemVitals->freePages = freePages; /* Print Out Amount Of Memory */ - kprintf("T\n"); - kprintf("[%i]\n", 1024); - kprintf("E\n"); kprintf("Real Memory: %iKB\n", numPages * 4); kprintf("Available Memory: %iKB\n", freePages * 4); diff --git a/tools/SCRIPT.DPF b/tools/SCRIPT.DPF old mode 100644 new mode 100755 Binary files differ diff --git a/tools/mbr b/tools/mbr old mode 100644 new mode 100755 Binary files differ diff --git a/tools/stat b/tools/stat old mode 100644 new mode 100755 Binary files differ