From 779429d2896d192cfc456b11436243c6dc771f9c Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 29 Aug 2009 14:29:57 +0300 Subject: [PATCH 1/9] Intermediate stage in reincorporating old libc into userspace tasks. --- containers/posix/fs0/include/lib/malloc.h | 6 - containers/posix/fs0/include/linker.lds | 2 +- containers/posix/fs0/include/vfs.h | 2 +- containers/posix/fs0/main.c | 2 +- containers/posix/fs0/src/crt0.S | 12 - containers/posix/fs0/src/file.c | 2 +- containers/posix/fs0/src/lib/bit.c | 2 +- containers/posix/fs0/src/lib/idpool.c | 2 +- containers/posix/fs0/src/lib/malloc.c | 3 +- containers/posix/fs0/src/lib/vaddr.c | 2 +- containers/posix/fs0/src/memfs/memfs.c | 2 +- containers/posix/libc/include/arch | 1 - containers/posix/libc/include/arch-arm/uart.h | 7 - containers/posix/libc/include/printf.h | 9 - containers/posix/libc/include/string.h | 11 - containers/posix/libc/src/arch | 1 - containers/posix/libc/src/arch-arm/uart.c | 191 -------- containers/posix/libc/src/printf.c | 446 ------------------ containers/posix/libc/src/putc.c | 8 - containers/posix/libc/src/string.c | 84 ---- containers/posix/{libc => libc2}/SConscript | 27 +- .../libc2/crt/sys-baremetal/arch-arm/crt0.S | 97 ++++ .../libc2/crt/sys-userspace/arch-arm/crt0.S | 93 ++++ .../libc2/include/arch/arm/arch/inttypes.h | 87 ++++ .../libc2/include/arch/arm/arch/pl011_uart.h | 408 ++++++++++++++++ .../libc2/include/arch/arm/arch/setjmp.h | 83 ++++ .../include/arch/arm/arch}/stdint.h | 0 containers/posix/libc2/include/assert.h | 102 ++++ containers/posix/libc2/include/complex.h | 212 +++++++++ containers/posix/libc2/include/ctype.h | 204 ++++++++ containers/posix/libc2/include/errno.h | 104 ++++ containers/posix/libc2/include/inttypes.h | 202 ++++++++ containers/posix/libc2/include/iso646.h | 101 ++++ containers/posix/libc2/include/limits.h | 116 +++++ containers/posix/libc2/include/locale.h | 117 +++++ containers/posix/libc2/include/setjmp.h | 90 ++++ containers/posix/libc2/include/stdarg.h | 96 ++++ .../posix/{libc => libc2}/include/stdbool.h | 0 containers/posix/libc2/include/stddef.h | 117 +++++ .../posix/{libc => libc2}/include/stdint.h | 0 .../posix/{libc => libc2}/include/stdio.h | 12 +- containers/posix/libc2/include/stdlib.h | 210 +++++++++ containers/posix/libc2/include/string.h | 122 +++++ .../sys-baremetal/arch-arm/arch/inttypes.h | 87 ++++ .../sys-baremetal/arch-arm/arch/pl011_uart.h | 408 ++++++++++++++++ .../sys-baremetal/arch-arm/arch/setjmp.h | 83 ++++ .../sys-baremetal/arch-arm/arch/stdint.h | 92 ++++ .../include/sys-baremetal/arch-arm/inttypes.h | 87 ++++ .../sys-baremetal/arch-arm/pl011_uart.h | 408 ++++++++++++++++ .../include/sys-baremetal/arch-arm/setjmp.h | 83 ++++ .../include/sys-baremetal/arch-arm/stdint.h | 92 ++++ .../sys-userspace/arch-arm/arch/inttypes.h | 87 ++++ .../sys-userspace/arch-arm/arch}/pl011_uart.h | 27 +- .../sys-userspace/arch-arm/arch/setjmp.h | 83 ++++ .../sys-userspace/arch-arm/arch/stdint.h | 92 ++++ .../include/sys-userspace/arch-arm/inttypes.h | 87 ++++ .../sys-userspace/arch-arm/pl011_uart.h | 408 ++++++++++++++++ .../include/sys-userspace/arch-arm/setjmp.h | 83 ++++ .../include/sys-userspace/arch-arm/stdint.h | 92 ++++ containers/posix/libc2/include/time.h | 130 +++++ .../posix/{libc => libc2}/src/arch-arm/eabi.c | 1 - containers/posix/libc2/src/arch-arm/jmp.S | 105 +++++ containers/posix/libc2/src/asctime.c | 107 +++++ containers/posix/libc2/src/assert.c | 96 ++++ containers/posix/libc2/src/calloc.c | 95 ++++ containers/posix/libc2/src/clearerr.c | 88 ++++ containers/posix/libc2/src/clock.c | 86 ++++ containers/posix/libc2/src/ctype.c | 0 containers/posix/libc2/src/difftime.c | 86 ++++ containers/posix/libc2/src/errno.c | 82 ++++ containers/posix/libc2/src/exit.c | 99 ++++ containers/posix/libc2/src/fclose.c | 92 ++++ containers/posix/libc2/src/feof.c | 89 ++++ containers/posix/libc2/src/ferror.c | 89 ++++ containers/posix/libc2/src/fflush.c | 89 ++++ containers/posix/libc2/src/fgetc.c | 105 +++++ containers/posix/libc2/src/fgets.c | 108 +++++ containers/posix/{libc => libc2}/src/format.c | 3 +- containers/posix/{libc => libc2}/src/format.h | 0 containers/posix/libc2/src/fprintf.c | 98 ++++ containers/posix/libc2/src/fputc.c | 19 + containers/posix/libc2/src/fputs.c | 95 ++++ containers/posix/libc2/src/fread.c | 101 ++++ containers/posix/libc2/src/fscanf.c | 87 ++++ containers/posix/libc2/src/fseek.c | 103 ++++ containers/posix/libc2/src/ftell.c | 90 ++++ containers/posix/libc2/src/fwrite.c | 102 ++++ containers/posix/libc2/src/getchar.c | 89 ++++ containers/posix/libc2/src/getenv.c | 88 ++++ containers/posix/libc2/src/gmtime.c | 86 ++++ containers/posix/libc2/src/k_r_malloc.h | 20 + containers/posix/libc2/src/locale.c | 128 +++++ containers/posix/libc2/src/localtime.c | 86 ++++ containers/posix/libc2/src/malloc.c | 206 ++++++++ containers/posix/libc2/src/memchr.c | 103 ++++ containers/posix/libc2/src/memcmp.c | 98 ++++ containers/posix/libc2/src/memcpy.c | 115 +++++ containers/posix/libc2/src/memmove.c | 104 ++++ containers/posix/libc2/src/memset.c | 138 ++++++ containers/posix/libc2/src/mktime.c | 86 ++++ containers/posix/libc2/src/perror.c | 10 + containers/posix/libc2/src/printf.c | 100 ++++ containers/posix/libc2/src/putchar.c | 89 ++++ containers/posix/libc2/src/puts.c | 88 ++++ containers/posix/libc2/src/qsort.c | 40 ++ containers/posix/libc2/src/rand.c | 95 ++++ containers/posix/libc2/src/realloc.c | 33 ++ containers/posix/libc2/src/remove.c | 85 ++++ containers/posix/libc2/src/rename.c | 85 ++++ containers/posix/libc2/src/rewind.c | 87 ++++ containers/posix/libc2/src/snprintf.c | 20 + .../posix/{libc => libc2}/src/sprintf.c | 13 +- containers/posix/libc2/src/srand.c | 90 ++++ containers/posix/libc2/src/strcat.c | 89 ++++ containers/posix/libc2/src/strchr.c | 94 ++++ containers/posix/libc2/src/strcmp.c | 99 ++++ containers/posix/libc2/src/strcoll.c | 87 ++++ containers/posix/libc2/src/strcpy.c | 91 ++++ containers/posix/libc2/src/strcspn.c | 93 ++++ containers/posix/libc2/src/strdup.c | 15 + containers/posix/libc2/src/strerror.c | 86 ++++ containers/posix/libc2/src/strftime.c | 86 ++++ containers/posix/libc2/src/strlen.c | 92 ++++ containers/posix/libc2/src/strncat.c | 94 ++++ containers/posix/libc2/src/strncmp.c | 100 ++++ containers/posix/libc2/src/strncpy.c | 102 ++++ containers/posix/libc2/src/strpbrk.c | 95 ++++ containers/posix/libc2/src/strrchr.c | 104 ++++ containers/posix/libc2/src/strspn.c | 92 ++++ containers/posix/libc2/src/strstr.c | 97 ++++ containers/posix/libc2/src/strtod.c | 88 ++++ containers/posix/libc2/src/strtok.c | 101 ++++ containers/posix/libc2/src/strtol.c | 218 +++++++++ containers/posix/libc2/src/strtoul.c | 218 +++++++++ .../arch-arm/plat-pb926/platform_init.c | 50 ++ .../arch-arm/plat-pb926/sys_fputc.c | 290 ++++++++++++ .../src/sys-baremetal/arch-arm/sys_stdio.c | 68 +++ .../arch-arm/plat-pb926/platform_init.c | 50 ++ .../arch-arm/plat-pb926/sys_fputc.c | 290 ++++++++++++ .../src/sys-userspace/arch-arm/sys_stdio.c | 68 +++ containers/posix/libc2/src/system.c | 87 ++++ containers/posix/libc2/src/time.c | 88 ++++ containers/posix/libc2/src/tmpfile.c | 93 ++++ containers/posix/libc2/src/ungetc.c | 99 ++++ containers/posix/libc2/src/vfprintf.c | 91 ++++ containers/posix/libc2/src/vprintf.c | 92 ++++ containers/posix/libc2/src/vsnprintf.c | 91 ++++ containers/posix/mm0/container.c | 4 - containers/posix/mm0/include/file.h | 4 - containers/posix/mm0/include/linker.lds | 2 +- containers/posix/mm0/main.c | 4 +- containers/posix/mm0/src/arch-arm/crt0.S | 12 - containers/posix/mm0/src/arch-arm/mm.c | 1 - containers/posix/mm0/src/arch/crt0.S | 12 - containers/posix/mm0/src/bootm.c | 2 +- containers/posix/mm0/src/capability.c | 1 - containers/posix/mm0/src/file.c | 4 +- containers/posix/mm0/src/lib/addr.c | 2 +- containers/posix/mm0/src/lib/bit.c | 2 +- containers/posix/mm0/src/lib/elf/elf.c | 2 +- containers/posix/mm0/src/lib/idpool.c | 2 +- containers/posix/mm0/src/lib/malloc.c | 1 - containers/posix/mm0/src/mmap.c | 4 +- containers/posix/mm0/src/pagers.c | 12 +- containers/posix/mm0/src/test.c | 1 - containers/posix/mm0/src/utcb.c | 3 +- containers/posix/mm0/src/vm_object.c | 1 - containers/posix/test0/include/linker.lds | 2 +- containers/posix/test0/include/tests.h | 3 +- containers/posix/test0/src/clonetest.c | 1 - containers/posix/test0/src/crt0.S | 12 - containers/posix/test0/src/dirtest.c | 3 +- containers/posix/test0/src/exectest.c | 1 - containers/posix/test0/src/fileio.c | 1 - containers/posix/test0/src/forktest.c | 1 - containers/posix/test0/src/mmaptest.c | 1 - containers/posix/test0/src/shmtest.c | 6 +- containers/posix/test0/src/test_exec/crt0.S | 12 - .../posix/test0/src/test_exec/test_exec.c | 2 +- 179 files changed, 12922 insertions(+), 918 deletions(-) delete mode 100644 containers/posix/fs0/src/crt0.S delete mode 120000 containers/posix/libc/include/arch delete mode 100644 containers/posix/libc/include/arch-arm/uart.h delete mode 100644 containers/posix/libc/include/printf.h delete mode 100644 containers/posix/libc/include/string.h delete mode 120000 containers/posix/libc/src/arch delete mode 100644 containers/posix/libc/src/arch-arm/uart.c delete mode 100644 containers/posix/libc/src/printf.c delete mode 100644 containers/posix/libc/src/putc.c delete mode 100644 containers/posix/libc/src/string.c rename containers/posix/{libc => libc2}/SConscript (50%) create mode 100644 containers/posix/libc2/crt/sys-baremetal/arch-arm/crt0.S create mode 100644 containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S create mode 100644 containers/posix/libc2/include/arch/arm/arch/inttypes.h create mode 100644 containers/posix/libc2/include/arch/arm/arch/pl011_uart.h create mode 100644 containers/posix/libc2/include/arch/arm/arch/setjmp.h rename containers/posix/{libc/include/arch-arm => libc2/include/arch/arm/arch}/stdint.h (100%) create mode 100644 containers/posix/libc2/include/assert.h create mode 100644 containers/posix/libc2/include/complex.h create mode 100644 containers/posix/libc2/include/ctype.h create mode 100644 containers/posix/libc2/include/errno.h create mode 100644 containers/posix/libc2/include/inttypes.h create mode 100644 containers/posix/libc2/include/iso646.h create mode 100644 containers/posix/libc2/include/limits.h create mode 100644 containers/posix/libc2/include/locale.h create mode 100644 containers/posix/libc2/include/setjmp.h create mode 100644 containers/posix/libc2/include/stdarg.h rename containers/posix/{libc => libc2}/include/stdbool.h (100%) create mode 100644 containers/posix/libc2/include/stddef.h rename containers/posix/{libc => libc2}/include/stdint.h (100%) rename containers/posix/{libc => libc2}/include/stdio.h (97%) create mode 100644 containers/posix/libc2/include/stdlib.h create mode 100644 containers/posix/libc2/include/string.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/arch/inttypes.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/arch/pl011_uart.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/arch/setjmp.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/arch/stdint.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/inttypes.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/pl011_uart.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/setjmp.h create mode 100644 containers/posix/libc2/include/sys-baremetal/arch-arm/stdint.h create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/arch/inttypes.h rename containers/posix/{libc/include/arch-arm => libc2/include/sys-userspace/arch-arm/arch}/pl011_uart.h (98%) create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/arch/setjmp.h create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/arch/stdint.h create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/inttypes.h create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/pl011_uart.h create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/setjmp.h create mode 100644 containers/posix/libc2/include/sys-userspace/arch-arm/stdint.h create mode 100644 containers/posix/libc2/include/time.h rename containers/posix/{libc => libc2}/src/arch-arm/eabi.c (99%) create mode 100644 containers/posix/libc2/src/arch-arm/jmp.S create mode 100644 containers/posix/libc2/src/asctime.c create mode 100644 containers/posix/libc2/src/assert.c create mode 100644 containers/posix/libc2/src/calloc.c create mode 100644 containers/posix/libc2/src/clearerr.c create mode 100644 containers/posix/libc2/src/clock.c create mode 100644 containers/posix/libc2/src/ctype.c create mode 100644 containers/posix/libc2/src/difftime.c create mode 100644 containers/posix/libc2/src/errno.c create mode 100644 containers/posix/libc2/src/exit.c create mode 100644 containers/posix/libc2/src/fclose.c create mode 100644 containers/posix/libc2/src/feof.c create mode 100644 containers/posix/libc2/src/ferror.c create mode 100644 containers/posix/libc2/src/fflush.c create mode 100644 containers/posix/libc2/src/fgetc.c create mode 100644 containers/posix/libc2/src/fgets.c rename containers/posix/{libc => libc2}/src/format.c (99%) rename containers/posix/{libc => libc2}/src/format.h (100%) create mode 100644 containers/posix/libc2/src/fprintf.c create mode 100644 containers/posix/libc2/src/fputc.c create mode 100644 containers/posix/libc2/src/fputs.c create mode 100644 containers/posix/libc2/src/fread.c create mode 100644 containers/posix/libc2/src/fscanf.c create mode 100644 containers/posix/libc2/src/fseek.c create mode 100644 containers/posix/libc2/src/ftell.c create mode 100644 containers/posix/libc2/src/fwrite.c create mode 100644 containers/posix/libc2/src/getchar.c create mode 100644 containers/posix/libc2/src/getenv.c create mode 100644 containers/posix/libc2/src/gmtime.c create mode 100644 containers/posix/libc2/src/k_r_malloc.h create mode 100644 containers/posix/libc2/src/locale.c create mode 100644 containers/posix/libc2/src/localtime.c create mode 100644 containers/posix/libc2/src/malloc.c create mode 100644 containers/posix/libc2/src/memchr.c create mode 100644 containers/posix/libc2/src/memcmp.c create mode 100644 containers/posix/libc2/src/memcpy.c create mode 100644 containers/posix/libc2/src/memmove.c create mode 100644 containers/posix/libc2/src/memset.c create mode 100644 containers/posix/libc2/src/mktime.c create mode 100644 containers/posix/libc2/src/perror.c create mode 100644 containers/posix/libc2/src/printf.c create mode 100644 containers/posix/libc2/src/putchar.c create mode 100644 containers/posix/libc2/src/puts.c create mode 100644 containers/posix/libc2/src/qsort.c create mode 100644 containers/posix/libc2/src/rand.c create mode 100644 containers/posix/libc2/src/realloc.c create mode 100644 containers/posix/libc2/src/remove.c create mode 100644 containers/posix/libc2/src/rename.c create mode 100644 containers/posix/libc2/src/rewind.c create mode 100644 containers/posix/libc2/src/snprintf.c rename containers/posix/{libc => libc2}/src/sprintf.c (99%) create mode 100644 containers/posix/libc2/src/srand.c create mode 100644 containers/posix/libc2/src/strcat.c create mode 100644 containers/posix/libc2/src/strchr.c create mode 100644 containers/posix/libc2/src/strcmp.c create mode 100644 containers/posix/libc2/src/strcoll.c create mode 100644 containers/posix/libc2/src/strcpy.c create mode 100644 containers/posix/libc2/src/strcspn.c create mode 100644 containers/posix/libc2/src/strdup.c create mode 100644 containers/posix/libc2/src/strerror.c create mode 100644 containers/posix/libc2/src/strftime.c create mode 100644 containers/posix/libc2/src/strlen.c create mode 100644 containers/posix/libc2/src/strncat.c create mode 100644 containers/posix/libc2/src/strncmp.c create mode 100644 containers/posix/libc2/src/strncpy.c create mode 100644 containers/posix/libc2/src/strpbrk.c create mode 100644 containers/posix/libc2/src/strrchr.c create mode 100644 containers/posix/libc2/src/strspn.c create mode 100644 containers/posix/libc2/src/strstr.c create mode 100644 containers/posix/libc2/src/strtod.c create mode 100644 containers/posix/libc2/src/strtok.c create mode 100644 containers/posix/libc2/src/strtol.c create mode 100644 containers/posix/libc2/src/strtoul.c create mode 100644 containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c create mode 100644 containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c create mode 100644 containers/posix/libc2/src/sys-baremetal/arch-arm/sys_stdio.c create mode 100644 containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/platform_init.c create mode 100644 containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c create mode 100644 containers/posix/libc2/src/sys-userspace/arch-arm/sys_stdio.c create mode 100644 containers/posix/libc2/src/system.c create mode 100644 containers/posix/libc2/src/time.c create mode 100644 containers/posix/libc2/src/tmpfile.c create mode 100644 containers/posix/libc2/src/ungetc.c create mode 100644 containers/posix/libc2/src/vfprintf.c create mode 100644 containers/posix/libc2/src/vprintf.c create mode 100644 containers/posix/libc2/src/vsnprintf.c delete mode 100644 containers/posix/mm0/src/arch-arm/crt0.S delete mode 100644 containers/posix/mm0/src/arch/crt0.S delete mode 100644 containers/posix/test0/src/crt0.S delete mode 100644 containers/posix/test0/src/test_exec/crt0.S diff --git a/containers/posix/fs0/include/lib/malloc.h b/containers/posix/fs0/include/lib/malloc.h index ac514f2..37479ff 100644 --- a/containers/posix/fs0/include/lib/malloc.h +++ b/containers/posix/fs0/include/lib/malloc.h @@ -3,12 +3,6 @@ #include #include -#ifndef NULL -#define NULL 0 -#endif -#ifndef size_t -#define size_t int -#endif void *kmalloc(size_t size); void kfree(void *blk); diff --git a/containers/posix/fs0/include/linker.lds b/containers/posix/fs0/include/linker.lds index fed94eb..d555415 100644 --- a/containers/posix/fs0/include/linker.lds +++ b/containers/posix/fs0/include/linker.lds @@ -26,7 +26,7 @@ SECTIONS { . = virtual_base; _start_text = .; - .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } + .text : AT (ADDR(.text) - offset) { crt0.o(.text) *(.text) } /* rodata is needed else your strings will link at physical! */ .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } diff --git a/containers/posix/fs0/include/vfs.h b/containers/posix/fs0/include/vfs.h index 4f94898..5d9b5a8 100644 --- a/containers/posix/fs0/include/vfs.h +++ b/containers/posix/fs0/include/vfs.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/containers/posix/fs0/main.c b/containers/posix/fs0/main.c index b5b672b..7fc7475 100644 --- a/containers/posix/fs0/main.c +++ b/containers/posix/fs0/main.c @@ -122,7 +122,7 @@ void handle_fs_requests(void) default: printf("%s: Unrecognised ipc tag (%d) " "received from tid: %d. Ignoring.\n", __TASKNAME__, - mr[MR_TAG], senderid); + mr[MR_TAG], sender); } /* Reply */ diff --git a/containers/posix/fs0/src/crt0.S b/containers/posix/fs0/src/crt0.S deleted file mode 100644 index a390ee9..0000000 --- a/containers/posix/fs0/src/crt0.S +++ /dev/null @@ -1,12 +0,0 @@ - -.section .text.head -.global _start; -.type _start,function; -.align; - -_start: - ldr sp, =__stack - bl __container_init -1: - b 1b - diff --git a/containers/posix/fs0/src/file.c b/containers/posix/fs0/src/file.c index 4b4963e..2bfd6fe 100644 --- a/containers/posix/fs0/src/file.c +++ b/containers/posix/fs0/src/file.c @@ -8,7 +8,7 @@ #include #include #include INC_GLUE(memory.h) -#include +#include /* * This reads contents of a file in pages, calling the fs-specific file read function to read-in diff --git a/containers/posix/fs0/src/lib/bit.c b/containers/posix/fs0/src/lib/bit.c index d4e1226..7b1dee4 100644 --- a/containers/posix/fs0/src/lib/bit.c +++ b/containers/posix/fs0/src/lib/bit.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include INC_GLUE(memory.h) /* Emulation of ARM's CLZ (count leading zeroes) instruction */ diff --git a/containers/posix/fs0/src/lib/idpool.c b/containers/posix/fs0/src/lib/idpool.c index 13ca67b..0cb826e 100644 --- a/containers/posix/fs0/src/lib/idpool.c +++ b/containers/posix/fs0/src/lib/idpool.c @@ -8,7 +8,7 @@ #include // --> This is a local library that statically allocates its heap. #include #include INC_GLUE(memory.h) -#include +#include #include struct id_pool *id_pool_new_init(int totalbits) diff --git a/containers/posix/fs0/src/lib/malloc.c b/containers/posix/fs0/src/lib/malloc.c index 5b6a344..27c3829 100644 --- a/containers/posix/fs0/src/lib/malloc.c +++ b/containers/posix/fs0/src/lib/malloc.c @@ -18,8 +18,7 @@ Messages that indicate a software error will contain three asterisks (***). *****************************************************************************/ #include /* memcpy(), memset() */ #include /* printf() */ -#include -#include + #define _32BIT 1 /* use small (32K) heap for 16-bit compilers, diff --git a/containers/posix/fs0/src/lib/vaddr.c b/containers/posix/fs0/src/lib/vaddr.c index f199cfc..8a847a7 100644 --- a/containers/posix/fs0/src/lib/vaddr.c +++ b/containers/posix/fs0/src/lib/vaddr.c @@ -8,7 +8,7 @@ #include #include INC_GLUE(memory.h) #include -#include +#include void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end) { diff --git a/containers/posix/fs0/src/memfs/memfs.c b/containers/posix/fs0/src/memfs/memfs.c index 72bb764..95d957f 100644 --- a/containers/posix/fs0/src/memfs/memfs.c +++ b/containers/posix/fs0/src/memfs/memfs.c @@ -192,7 +192,7 @@ struct superblock *memfs_get_superblock(void *block) return 0; } if (sb->magic != MEMFS_MAGIC) { - printf("%s: Magic number not match: %u\n", __FUNCTION__, sb->magic); + printf("%s: Magic number not match: %s\n", __FUNCTION__, sb->magic); return 0; } diff --git a/containers/posix/libc/include/arch b/containers/posix/libc/include/arch deleted file mode 120000 index 85405c2..0000000 --- a/containers/posix/libc/include/arch +++ /dev/null @@ -1 +0,0 @@ -arch-arm \ No newline at end of file diff --git a/containers/posix/libc/include/arch-arm/uart.h b/containers/posix/libc/include/arch-arm/uart.h deleted file mode 100644 index 2ea71dc..0000000 --- a/containers/posix/libc/include/arch-arm/uart.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __LIBC_UART_H__ -#define __LIBC_UART_H__ - -void uart_init(void); -void uart_putc(char c); - -#endif /* __LIBC_UART_H__ */ diff --git a/containers/posix/libc/include/printf.h b/containers/posix/libc/include/printf.h deleted file mode 100644 index 446157b..0000000 --- a/containers/posix/libc/include/printf.h +++ /dev/null @@ -1,9 +0,0 @@ - -#ifndef __PRINTF_H__ -#define __PRINTF_H__ - -#include -#include -int printf(char *format, ...) __attribute__((format (printf, 1, 2))); - -#endif /* __PRINTF_H__ */ diff --git a/containers/posix/libc/include/string.h b/containers/posix/libc/include/string.h deleted file mode 100644 index 1ca9ec5..0000000 --- a/containers/posix/libc/include/string.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __LIB_STRING_H__ -#define __LIB_STRING_H__ - -int strlen(const char *s); -char *strcpy(char *to, const char *from); -char *strncpy(char *dest, const char *src, int count); -int strcmp(const char *s1, const char *s2); -void *memset(void *p, int c, int size); -void *memcpy(void *d, void *s, int size); - -#endif /* __LIB_STRING_H__ */ diff --git a/containers/posix/libc/src/arch b/containers/posix/libc/src/arch deleted file mode 120000 index 85405c2..0000000 --- a/containers/posix/libc/src/arch +++ /dev/null @@ -1 +0,0 @@ -arch-arm \ No newline at end of file diff --git a/containers/posix/libc/src/arch-arm/uart.c b/containers/posix/libc/src/arch-arm/uart.c deleted file mode 100644 index bf8adce..0000000 --- a/containers/posix/libc/src/arch-arm/uart.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Ties up platform's uart driver functions with generic API - * - * Copyright (C) 2007 Bahadir Balban - */ - -#include -#include - -/* UART-specific internal error codes */ -#define PL011_ERROR 1 -#define PL011_EAGAIN 2 - -/* Error status bits in receive status register */ -#define PL011_FE (1 << 0) -#define PL011_PE (1 << 1) -#define PL011_BE (1 << 2) -#define PL011_OE (1 << 3) - -/* Status bits in flag register */ -#define PL011_TXFE (1 << 7) -#define PL011_RXFF (1 << 6) -#define PL011_TXFF (1 << 5) -#define PL011_RXFE (1 << 4) -#define PL011_BUSY (1 << 3) -#define PL011_DCD (1 << 2) -#define PL011_DSR (1 << 1) -#define PL011_CTS (1 << 0) - -struct pl011_uart uart; - -int pl011_tx_char(char c) -{ - unsigned int val; - val = 0; - - read(val, PL011_UARTFR); - if(val & PL011_TXFF) { /* TX FIFO Full */ - return -PL011_EAGAIN; - } - write(c, PL011_UARTDR); - return 0; -} - -int pl011_rx_char(char * c) -{ - unsigned int data; - unsigned int val; - val = 0; - - read(val, PL011_UARTFR); - if(val & PL011_RXFE) { /* RX FIFO Empty */ - return -PL011_EAGAIN; - } - - read(data, PL011_UARTDR); - *c = (char) data; - - if((data >> 8) & 0xF) { /* There were errors */ - return -1; /* Signal error in xfer */ - } - return 0; /* No error return */ -} - - -/* - * Sets the baud rate in kbps. It is recommended to use - * standard rates such as: 1200, 2400, 3600, 4800, 7200, - * 9600, 14400, 19200, 28800, 38400, 57600 76800, 115200. - */ -void pl011_set_baudrate(unsigned int baud, unsigned int clkrate) -{ - const unsigned int uartclk = 24000000; /* 24Mhz clock fixed on pb926 */ - unsigned int val; - unsigned int ipart, fpart; - unsigned int remainder; - - remainder = 0; - ipart = 0; - fpart = 0; - val = 0; - - /* Use default pb926 rate if no rate is supplied */ - if(clkrate == 0) { - clkrate = uartclk; - } - if(baud > 115200 || baud < 1200) { - baud = 38400; /* Default rate. */ - } - /* 24000000 / (38400 * 16) */ - ipart = 39; - - write(ipart, PL011_UARTIBRD); - write(fpart, PL011_UARTFBRD); - - /* For the IBAUD and FBAUD to update, we need to - * write to UARTLCR_H because the 3 registers are - * actually part of a single register in hardware - * which only updates by a write to UARTLCR_H */ - read(val, PL011_UARTLCR_H); - write(val, PL011_UARTLCR_H); - return; - -} - - -/* Masks the irqs given in the flags bitvector. */ -void pl011_set_irq_mask(unsigned int flags) -{ - unsigned int val; - val = 0; - - if(flags > 0x3FF) { /* Invalid irqmask bitvector */ - return; - } - - read(val, PL011_UARTIMSC); - val |= flags; - write(val, PL011_UARTIMSC); - return; -} - - -/* Clears the irqs given in flags from masking */ -void pl011_clr_irq_mask(unsigned int flags) -{ - unsigned int val; - val = 0; - - if(flags > 0x3FF) { /* Invalid irqmask bitvector */ - return; - } - - read(val, PL011_UARTIMSC); - val &= ~flags; - write(val, PL011_UARTIMSC); - return; -} - -int pl011_initialise(struct pl011_uart * uart) -{ - - uart->frame_errors = 0; - uart->parity_errors = 0; - uart->break_errors = 0; - uart->overrun_errors = 0; - - /* Initialise data register for 8 bit data read/writes */ - pl011_set_word_width(8); - - /* Fifos are disabled because by default it is assumed the port - * will be used as a user terminal, and in that case the typed - * characters will only show up when fifos are flushed, rather than - * when each character is typed. We avoid this by not using fifos. - */ - pl011_disable_fifos(); - - /* Set default baud rate of 38400 */ - pl011_set_baudrate(38400, 24000000); - - /* Set default settings of 1 stop bit, no parity, no hw flow ctrl */ - pl011_set_stopbits(1); - pl011_parity_disable(); - - /* Disable all irqs */ - pl011_set_irq_mask(0x3FF); - - /* Enable rx, tx, and uart chip */ - pl011_tx_enable(); - pl011_rx_enable(); - pl011_uart_enable(); - - return 0; -} - -void uart_init() -{ - uart.base = PL011_BASE; - pl011_initialise(&uart); -} - -/* Generic uart function that lib/putchar.c expects to see implemented */ -void uart_putc(char c) -{ - int res; - /* Platform specific uart implementation */ - do { - res = pl011_tx_char(c); - } while (res < 0); -} - diff --git a/containers/posix/libc/src/printf.c b/containers/posix/libc/src/printf.c deleted file mode 100644 index f472de8..0000000 --- a/containers/posix/libc/src/printf.c +++ /dev/null @@ -1,446 +0,0 @@ -/********************************************************************* - * - * Copyright (C) 2002-2004 Karlsruhe University - * - * File path: generic/printk.cc - * Description: Implementation of printf - * - * Redistribution and use in source and binary forms, with or without - * modification, 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. - * - ********************************************************************/ -#include /* for va_list, ... comes with gcc */ -#include - -/* FIXME: LICENSE LICENCE */ -typedef unsigned int word_t; - -extern void putc(const char c); -extern int print_tid (word_t val, word_t width, word_t precision, int adjleft); - - -/* convert nibble to lowercase hex char */ -#define hexchars(x) (((x) < 10) ? ('0' + (x)) : ('a' + ((x) - 10))) - -/** - * Print hexadecimal value - * - * @param val value to print - * @param width width in caracters - * @param precision minimum number of digits to apprear - * @param adjleft left adjust the value - * @param nullpad pad with leading zeros (when right padding) - * - * Prints a hexadecimal value with leading zeroes of given width - * using putc(), or if adjleft argument is given, print - * hexadecimal value with space padding to the right. - * - * @returns the number of charaters printed (should be same as width). - */ -int print_hex64(unsigned long long val, int width, int precision, int adjleft, int nullpad) -{ - int i, n = 0; - int nwidth = 0; - unsigned int high, low; - - high = val >> 32; - low = (unsigned int)val; - - // Find width of hexnumber - if (high) { - while ((high >> (4 * nwidth)) && ((unsigned) nwidth < 2 * sizeof (unsigned int))) - nwidth++; - nwidth += 32; - } else { - while ((low >> (4 * nwidth)) && ((unsigned) nwidth < 2 * sizeof (unsigned int))) - nwidth++; - } - - if (nwidth == 0) - nwidth = 1; - - // May need to increase number of printed digits - if (precision > nwidth) - nwidth = precision; - - // May need to increase number of printed characters - if (width == 0 && width < nwidth) - width = nwidth; - - // Print number with padding - if (high) - { - if (!adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (nullpad ? '0' : ' '); - for (i = 4 * (nwidth - 33); i >= 0; i -= 4, n++) - putc (hexchars ((high >> i) & 0xF)); - if (adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (' '); - width -= 32; - nwidth -= 32; - nullpad = 1; - } - if (! adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (nullpad ? '0' : ' '); - for (i = 4 * (nwidth - 1); i >= 0; i -= 4, n++) - putc (hexchars ((low >> i) & 0xF)); - if (adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (' '); - - return n; -} - -int print_hex_3arg(const word_t val, int width, int precision) -{ - long i, n = 0; - long nwidth = 0; - int adjleft = 0; - int nullpad = 0; - - // Find width of hexnumber - while ((val >> (4 * nwidth)) && (word_t) nwidth < 2 * sizeof (word_t)) - nwidth++; - - if (nwidth == 0) - nwidth = 1; - - // May need to increase number of printed digits - if (precision > nwidth) - nwidth = precision; - - // May need to increase number of printed characters - if (width == 0 && width < nwidth) - width = nwidth; - - // Print number with padding - if (! adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (nullpad ? '0' : ' '); - for (i = 4 * (nwidth - 1); i >= 0; i -= 4, n++) - putc (hexchars ((val >> i) & 0xF)); - if (adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (' '); - - return n; -} - -int print_hex_5arg(const word_t val, int width, - int precision, int adjleft, int nullpad) -{ - long i, n = 0; - long nwidth = 0; - - // Find width of hexnumber - while ((val >> (4 * nwidth)) && (word_t) nwidth < 2 * sizeof (word_t)) - nwidth++; - - if (nwidth == 0) - nwidth = 1; - - // May need to increase number of printed digits - if (precision > nwidth) - nwidth = precision; - - // May need to increase number of printed characters - if (width == 0 && width < nwidth) - width = nwidth; - - // Print number with padding - if (! adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (nullpad ? '0' : ' '); - for (i = 4 * (nwidth - 1); i >= 0; i -= 4, n++) - putc (hexchars ((val >> i) & 0xF)); - if (adjleft) - for (i = width - nwidth; i > 0; i--, n++) - putc (' '); - - return n; -} -/** - * Print a string - * - * @param s zero-terminated string to print - * @param width minimum width of printed string - * - * Prints the zero-terminated string using putc(). The printed - * string will be right padded with space to so that it will be - * at least WIDTH characters wide. - * - * @returns the number of charaters printed. - */ -int print_string_3arg(const char * s, const int width, const int precision) -{ - int n = 0; - - for (;;) - { - if (*s == 0) - break; - - putc(*s++); - n++; - if (precision && n >= precision) - break; - } - - while (n < width) { putc(' '); n++; } - - return n; -} - -int print_string_1arg(const char * s) -{ - int n = 0; - int width = 0; - int precision = 0; - - for (;;) { - if (*s == 0) - break; - - putc(*s++); - n++; - if (precision && n >= precision) - break; - } - - while (n < width) { - putc(' '); - n++; - } - - return n; -} - - -/** - * Print hexadecimal value with a separator - * - * @param val value to print - * @param bits number of lower-most bits before which to - * place the separator - * @param sep the separator to print - * - * @returns the number of charaters printed. - */ -int print_hex_sep(const word_t val, const int bits, const char *sep) -{ - int n = 0; - - n = print_hex_3arg(val >> bits, 0, 0); - n += print_string_1arg(sep); - n += print_hex_3arg(val & ((1 << bits) - 1), 0, 0); - - return n; -} - - -/** - * Print decimal value - * - * @param val value to print - * @param width width of field - * @param pad character used for padding value up to width - * - * Prints a value as a decimal in the given WIDTH with leading - * whitespaces. - * - * @returns the number of characters printed (may be more than WIDTH) - */ -int print_dec(const word_t val, int width) -{ - word_t divisor; - int digits; - /* estimate number of spaces and digits */ - for (divisor = 1, digits = 1; val/divisor >= 10; divisor *= 10, digits++); - - /* print spaces */ - for ( ; digits < width; digits++ ) - putc(' '); - - /* print digits */ - do { - putc(((val/divisor) % 10) + '0'); - } while (divisor /= 10); - - /* report number of digits printed */ - return digits; -} - -/** - * Does the real printk work - * - * @param format_p pointer to format string - * @param args list of arguments, variable length - * - * Prints the given arguments as specified by the format string. - * Implements a subset of the well-known printf plus some L4-specifics. - * - * @returns the number of characters printed - */ -int do_printk(char* format_p, va_list args) -{ - const char* format = format_p; - int n = 0; - int i = 0; - int width = 8; - int precision = 0; - int adjleft = 0, nullpad = 0; - -#define arg(x) va_arg(args, x) - - /* sanity check */ - if (format == '\0') - { - return 0; - } - - while (*format) - { - switch (*(format)) - { - case '%': - width = precision = 0; - adjleft = nullpad = 0; - reentry: - switch (*(++format)) - { - /* modifiers */ - case '.': - for (format++; *format >= '0' && *format <= '9'; format++) - precision = precision * 10 + (*format) - '0'; - if (*format == 'w') - { - // Set precision to printsize of a hex word - precision = sizeof (word_t) * 2; - format++; - } - format--; - goto reentry; - case '0': - nullpad = (width == 0); - case '1'...'9': - width = width*10 + (*format)-'0'; - goto reentry; - case 'w': - // Set width to printsize of a hex word - width = sizeof (word_t) * 2; - goto reentry; - case '-': - adjleft = 0; - goto reentry; - case 'l': - goto reentry; - break; - case 'c': - putc(arg(int)); - n++; - break; - case 'm': /* microseconds */ - { - n += print_hex64(arg(unsigned long long), width, precision, - adjleft, nullpad); - break; - } - case 'd': - { - long val = arg(long); - if (val < 0) - { - putc('-'); - val = -val; - } - n += print_dec(val, width); - break; - } - case 'u': - n += print_dec(arg(long), width); - break; - case 'p': - precision = sizeof (word_t) * 2; - case 'x': - n += print_hex_5arg(arg(long), width, precision, adjleft, nullpad); - break; - case 's': - { - char* s = arg(char*); - if (s) - n += print_string_3arg(s, width, precision); - else - n += print_string_3arg("(null)", width, precision); - } - break; - - case 't': - case 'T': - // Do nothing for now. - //n += print_tid (arg (word_t), width, precision, adjleft); - break; - - case '%': - putc('%'); - n++; - format++; - continue; - default: - n += print_string_1arg("?"); - break; - }; - i++; - break; - default: - putc(*format); - n++; - break; - } - format++; - } - - return n; -} - -/** - * Flexible print function - * - * @param format string containing formatting and parameter type - * information - * @param ... variable list of parameters - * - * @returns the number of characters printed - */ -int printf(char *format, ...) -{ - va_list args; - int i; - - va_start(args, format); - i = do_printk(format, args); - va_end(args); - return i; -}; - - diff --git a/containers/posix/libc/src/putc.c b/containers/posix/libc/src/putc.c deleted file mode 100644 index fc8c8c7..0000000 --- a/containers/posix/libc/src/putc.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -void putc(char c) -{ - if (c == '\n') - uart_putc('\r'); - uart_putc(c); -} diff --git a/containers/posix/libc/src/string.c b/containers/posix/libc/src/string.c deleted file mode 100644 index 8de669e..0000000 --- a/containers/posix/libc/src/string.c +++ /dev/null @@ -1,84 +0,0 @@ -#include - -int strlen(const char *s) -{ - const char *p; - - for (p = s; *p != '\0'; p++); - return p - s; -} - -char *strcpy(char *to, const char *from) -{ - char *t = to; - - while ((*to++ = *from++) != '\0') - ; - return t; -} - -void *memset(void *p, int c, int size) -{ - char ch; - char *pp; - - pp = (char *)p; - ch = (char)c; - - for (int i = 0; i < size; i++) { - *pp++ = ch; - } - return p; -} - -void *memcpy(void *d, void *s, int size) -{ - char *dst = (char *)d; - char *src = (char *)s; - - for (int i = 0; i < size; i++) { - *dst = *src; - dst++; - src++; - } - return d; -} - - -int strcmp(const char *s1, const char *s2) -{ - unsigned int i = 0; - int d; - - while(1) { - d = (unsigned char)s1[i] - (unsigned char)s2[i]; - if (d != 0 || s1[i] == '\0') - return d; - i++; - } -} - -/* - * Copies string pointed by @from to string pointed by @to. - * - * If count is greater than the length of string in @from, - * pads rest of the locations with null. - */ -char *strncpy(char *to, const char *from, int count) -{ - char *temp = to; - - while (count) { - *temp = *from; - - /* - * Stop updating from if null - * terminator is reached. - */ - if (*from) - from++; - temp++; - count--; - } - return to; -} diff --git a/containers/posix/libc/SConscript b/containers/posix/libc2/SConscript similarity index 50% rename from containers/posix/libc/SConscript rename to containers/posix/libc2/SConscript index 954ce5c..ff6bb81 100644 --- a/containers/posix/libc/SConscript +++ b/containers/posix/libc2/SConscript @@ -19,14 +19,27 @@ Import('environment') +variant = "userspace" e = environment.Clone() -e.Append(CPPPATH = ['include', 'include/arch']) +e.Append(CPPPATH = ['include', 'include/sys-' + variant + '/arch-' + environment['ARCH']]) +e.Append(CCFLAGS = '-nostdinc') -e['CCFLAGS'] = ['-g', '-nostdlib', '-Wall', '-ffreestanding', '-std=gnu99'] +source = \ + Glob('src/*.c') + \ + Glob('src/sys-' + variant + '/*.c') + \ + Glob('src/sys-' + variant + '/arch-' + e['ARCH'] + '/*.c') + \ + Glob('src/sys-' + variant + '/arch-' + e['ARCH'] + '/plat-' + e['PLATFORM'] + '/*.c') + \ + Glob('src/arch-' + e['ARCH'] + '/*.c') + \ + Glob('src/arch-' + e['ARCH'] + '/*.S') -objects = e.StaticObject(Glob('src/*.c') + Glob('src/arch-' + environment['ARCH'] + '/*.[cS]')) -Depends(objects, e['configFiles']) -library = e.StaticLibrary('c', objects) -Depends(library, e['configFiles']) +objects = e.StaticObject(source) +Depends (objects, e['configFiles']) +library = e.StaticLibrary('c-' + variant, objects) +Depends (library, e['configFiles']) +runTime = e.StaticObject('crt/sys-' + variant + '/arch-' + e['ARCH'] + '/crt0.S') +Depends (runTime, e['configFiles']) -Return('library') +result = (library, runTime) +#result = (library) + +Return('result') diff --git a/containers/posix/libc2/crt/sys-baremetal/arch-arm/crt0.S b/containers/posix/libc2/crt/sys-baremetal/arch-arm/crt0.S new file mode 100644 index 0000000..5b19314 --- /dev/null +++ b/containers/posix/libc2/crt/sys-baremetal/arch-arm/crt0.S @@ -0,0 +1,97 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .code 32 + .global _start; + .align; +_start: + ldr sp, 1f + bl platform_init + bl main +1: .word _stack_top + + .bss + .align +_stack: + .space 1024 +_stack_top: diff --git a/containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S b/containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S new file mode 100644 index 0000000..a1d6ae3 --- /dev/null +++ b/containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S @@ -0,0 +1,93 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/containers/posix/libc2/include/arch/arm/arch/inttypes.h b/containers/posix/libc2/include/arch/arm/arch/inttypes.h new file mode 100644 index 0000000..329ca46 --- /dev/null +++ b/containers/posix/libc2/include/arch/arm/arch/inttypes.h @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#define __LENGTH_8_MOD "hh" +#define __LENGTH_16_MOD "h" +#define __LENGTH_32_MOD +#define __LENGTH_64_MOD "ll" +#define __LENGTH_MAX_MOD "ll" +#define __LENGTH_PTR_MOD diff --git a/containers/posix/libc2/include/arch/arm/arch/pl011_uart.h b/containers/posix/libc2/include/arch/arm/arch/pl011_uart.h new file mode 100644 index 0000000..cd2551f --- /dev/null +++ b/containers/posix/libc2/include/arch/arm/arch/pl011_uart.h @@ -0,0 +1,408 @@ + +#ifndef __PL011__UART__H__ +#define __PL011__UART__H__ + +/* + * PL011 UART Generic driver implementation. + * Copyright Bahadir Balban (C) 2006 + * + * The particular intention of this code is that it has been carefully + * written as decoupled from os-specific code and in a verbose way such + * that it clearly demonstrates how the device operates, reducing the + * amount of time to be spent for understanding the operational model + * and implementing a driver from scratch. This is the very first to be + * such a driver so far, hopefully it will turn out to be useful. + */ + +/* Default base address for this chip */ +#define PL011_DEFAULT_PHYSICAL_BASE 0x101F1000 +#define PL011_BASE PL011_DEFAULT_PHYSICAL_BASE + +/* Architecture specific memory access macros */ +#define read(val, address) val = *((volatile unsigned int *) address) +#define write(val, address) *((volatile unsigned int *) address) = val + +/* Register offsets */ +#define PL011_UARTDR (PL011_BASE + 0x00) +#define PL011_UARTRSR (PL011_BASE + 0x04) +#define PL011_UARTECR (PL011_BASE + 0x04) +#define PL011_UARTFR (PL011_BASE + 0x18) +#define PL011_UARTILPR (PL011_BASE + 0x20) +#define PL011_UARTIBRD (PL011_BASE + 0x24) +#define PL011_UARTFBRD (PL011_BASE + 0x28) +#define PL011_UARTLCR_H (PL011_BASE + 0x2C) +#define PL011_UARTCR (PL011_BASE + 0x30) +#define PL011_UARTIFLS (PL011_BASE + 0x34) +#define PL011_UARTIMSC (PL011_BASE + 0x38) +#define PL011_UARTRIS (PL011_BASE + 0x3C) +#define PL011_UARTMIS (PL011_BASE + 0x40) +#define PL011_UARTICR (PL011_BASE + 0x44) +#define PL011_UARTDMACR (PL011_BASE + 0x48) + +/* IRQ bits for each uart irq event */ +#define PL011_RXIRQ (1 << 4) +#define PL011_TXIRQ (1 << 5) +#define PL011_RXTIMEOUTIRQ (1 << 6) +#define PL011_FEIRQ (1 << 7) +#define PL011_PEIRQ (1 << 8) +#define PL011_BEIRQ (1 << 9) +#define PL011_OEIRQ (1 << 10) + +struct pl011_uart; + +int pl011_initialise(struct pl011_uart *); +int pl011_tx_char(char); +int pl011_rx_char(char *); + +void pl011_set_baudrate(unsigned int, unsigned int); +void pl011_set_irq_mask(unsigned int); +void pl011_clr_irq_mask(unsigned int); + +void pl011_irq_handler(struct pl011_uart *); +void pl011_tx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_rx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_error_irq_handler(struct pl011_uart *, unsigned int); + +static inline void pl011_uart_enable(void); +static inline void pl011_uart_disable(void); +static inline void pl011_tx_enable(void); +static inline void pl011_tx_disable(void); +static inline void pl011_rx_enable(void); +static inline void pl011_rx_disable(void); +static inline void pl011_irq_clear(unsigned int flags); +static inline unsigned int pl011_read_irqstat(void); +static inline unsigned int pl011_read_irqmask(void); +static inline void pl011_rx_dma_disable(void); +static inline void pl011_rx_dma_enable(void); +static inline void pl011_tx_dma_enable(void); +static inline void pl011_tx_dma_disable(void); +static inline void pl011_set_irq_fifolevel(unsigned int xfer, + unsigned int level); +static inline void pl011_set_word_width(int size); +static inline void pl011_disable_fifos(void); +static inline void pl011_set_parity_even(void); +static inline void pl011_parity_enable(void); +static inline void pl011_set_stopbits(int stopbits); + +static inline void pl011_set_parity_odd(void); +static inline void pl011_enable_fifos(void); +static inline void pl011_parity_disable(void); + +struct pl011_uart_ops { + int (*initialise)(struct pl011_uart *); + + int (*tx_char)(char); + int (*rx_char)(char *); + + void (*set_baudrate)(unsigned int, unsigned int); + void (*set_irq_mask)(unsigned int); + void (*clr_irq_mask)(unsigned int); + + void (*irq_handler)(struct pl011_uart *); + void (*tx_irq_handler)(struct pl011_uart *, unsigned int); + void (*rx_irq_handler)(struct pl011_uart *, unsigned int); + void (*error_irq_handler)(struct pl011_uart *, unsigned int); +}; + +struct pl011_uart { + const unsigned int base; + struct pl011_uart_ops ops; + unsigned int frame_errors; + unsigned int parity_errors; + unsigned int break_errors; + unsigned int overrun_errors; + unsigned int rx_timeout_errors; +}; + + + +#define PL011_UARTEN (1 << 0) +static inline void pl011_uart_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +static inline void pl011_uart_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +#define PL011_TXE (1 << 8) +static inline void pl011_tx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_TXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_tx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_TXE; + write(val, PL011_UARTCR); + return; +} + + +#define PL011_RXE (1 << 9) +static inline void pl011_rx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_rx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +#define PL011_TWO_STOPBITS_SELECT (1 << 3) +static inline void pl011_set_stopbits(int stopbits) +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + + if(stopbits == 2) { /* Set to two bits */ + val |= PL011_TWO_STOPBITS_SELECT; + } else { /* Default is 1 */ + val &= ~PL011_TWO_STOPBITS_SELECT; + } + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_ENABLE (1 << 1) +static inline void pl011_parity_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_parity_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_EVEN (1 << 2) +static inline void pl011_set_parity_even() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_set_parity_odd() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_ENABLE_FIFOS (1 << 4) +static inline void pl011_enable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_disable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + + +#define PL011_WORD_WIDTH_SHIFT (5) +/* Sets the transfer word width for the data register. */ +static inline void pl011_set_word_width(int size) +{ + unsigned int val; + val = 0; + + if(size < 5 || size > 8) /* Default is 8 */ + size = 8; + + /* Clear size field */ + read(val, PL011_UARTLCR_H); + val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT); + write(val, PL011_UARTLCR_H); + + /* The formula is to write 5 less of size given: + * 11 = 8 bits + * 10 = 7 bits + * 01 = 6 bits + * 00 = 5 bits + */ + read(val, PL011_UARTLCR_H); + val |= (size - 5) << PL011_WORD_WIDTH_SHIFT; + write(val, PL011_UARTLCR_H); + + return; +} + +/* + * Defines at which level of fifo fullness an irq will be generated. + * @xfer: tx fifo = 0, rx fifo = 1 + * @level: Generate irq if: + * 0 rxfifo >= 1/8 full txfifo <= 1/8 full + * 1 rxfifo >= 1/4 full txfifo <= 1/4 full + * 2 rxfifo >= 1/2 full txfifo <= 1/2 full + * 3 rxfifo >= 3/4 full txfifo <= 3/4 full + * 4 rxfifo >= 7/8 full txfifo <= 7/8 full + * 5-7 reserved reserved + */ +static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level) +{ + if(xfer != 1 && xfer != 0) /* Invalid fifo */ + return; + + if(level > 4) /* Invalid level */ + return; + + write(level << (xfer * 3), PL011_UARTIFLS); + return; +} + +/* returns which irqs are masked */ +static inline unsigned int pl011_read_irqmask(void) +{ + unsigned int flags; + read(flags, PL011_UARTIMSC); + return flags; +} + +/* returns masked irq status */ +static inline unsigned int pl011_read_irqstat(void) +{ + unsigned int irqstatus; + read(irqstatus, PL011_UARTMIS); + return irqstatus; +} +/* Clears the given asserted irqs */ +static inline void pl011_irq_clear(unsigned int flags) +{ + if(flags > 0x3FF) { /* Invalid irq clearing bitvector */ + return; + } + /* Simply write the flags since it's a write-only register */ + write(flags, PL011_UARTICR); + return; +} + +#define PL011_TXDMAEN (1 << 1) +#define PL011_RXDMAEN (1 << 0) + +/* Enables dma transfers for uart. The dma controller + * must be initialised, set-up and enabled separately. + */ +static inline void pl011_tx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +/* Disables dma transfers for uart */ +static inline void pl011_tx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + + +#endif /* __PL011__UART__ */ + diff --git a/containers/posix/libc2/include/arch/arm/arch/setjmp.h b/containers/posix/libc2/include/arch/arm/arch/setjmp.h new file mode 100644 index 0000000..22a17cd --- /dev/null +++ b/containers/posix/libc2/include/arch/arm/arch/setjmp.h @@ -0,0 +1,83 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Alex Webster +*/ + +typedef int jmp_buf[10]; diff --git a/containers/posix/libc/include/arch-arm/stdint.h b/containers/posix/libc2/include/arch/arm/arch/stdint.h similarity index 100% rename from containers/posix/libc/include/arch-arm/stdint.h rename to containers/posix/libc2/include/arch/arm/arch/stdint.h diff --git a/containers/posix/libc2/include/assert.h b/containers/posix/libc2/include/assert.h new file mode 100644 index 0000000..dba0e5f --- /dev/null +++ b/containers/posix/libc2/include/assert.h @@ -0,0 +1,102 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Cristan Szmajda, Ben Leslie + Description: + Program diagnostics as per 7.2 + Status: Complete. +*/ + + +/* + * may safely be included multiple times with or without NDEBUG + */ +#undef assert + +/* Defining NDEBUG removes asserts */ +#ifdef NDEBUG +#define assert(e) ((void)0) +#else +#define assert(e) ((e) ? (void)0 : __assert(#e, __FILE__, __func__, __LINE__)) +#endif + +/* Implemented in src/assert.c */ +void __assert(const char *, const char *, const char *, int); + diff --git a/containers/posix/libc2/include/complex.h b/containers/posix/libc2/include/complex.h new file mode 100644 index 0000000..36734ca --- /dev/null +++ b/containers/posix/libc2/include/complex.h @@ -0,0 +1,212 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Ben Leslie + Description: + Complex arithmetic as per 7.3 + Status: Functions defined, not implemented +*/ + +#error The complex library is incomplete + +#define complex _Complex +#define _Complex_I (const float _Complex) foo + +#define I _Complex_I + +/* 7.3.5 Trigonometric functions */ + +/* 7.3.5.1 cacos */ +double complex cacos(double complex z); +float complex cacosf(float complex z); +long double complex cacosl(long double complex z); + +/* 7.3.5.2 casin */ +double complex casin(double complex z); +float complex casinf(float complex z); +long double complex casinl(long double complex z); + +/* 7.3.5.3 catan */ +double complex catan(double complex z); +float complex catanf(float complex z); +long double complex catanl(long double complex z); + +/* 7.3.5.4 ccos */ +double complex ccos(double complex z); +float complex ccosf(float complex z); +long double complex ccosl(long double complex z); + +/* 7.3.5.5 csin */ +double complex csin(double complex z); +float complex csinf(float complex z); +long double complex csinl(long double complex z); + +/* 7.3.5.6 ctan */ +double complex ctan(double complex z); +float complex ctanf(float complex z); +long double complex ctanl(long double complex z); + +/* 7.3.6 Hyperbolic functions */ + +/* 7.3.6.1 cacosh */ +double complex cacosh(double complex z); +float complex cacoshf(float complex z); +long double complex cacoshf(long double complex z); + +/* 7.3.6.2 casinh */ +double complex casinh(double complex z); +float complex casinhf(float complex z); +long double complex casinhl(long double complex z); + +/* 7.3.6.3 catanh */ +double complex catanh(double complex z); +float complex catanhf(float complex z); +long double complex catanhl(long double complex z); + +/* 7.3.6.4 ccosh */ +double complex ccosh(double complex z); +float complex ccoshf(float complex z); +long double complex ccoshl(long double complex z); + +/* 7.3.6.5 csinh */ +double complex csinh(double complex z); +float complex csinhf(float complex z); +long double complex csinhl(long double complex z); + +/* 7.3.6.6 ctanh */ +double complex ctanh(double complex z); +float complex ctanhl(float complex z); +long double complex ctanhl(long double complex z); + +/* 7.3.7 Exponential and logarithmic functions */ + +/* 7.3.7.1 cexp */ +double complex cexp(double complex z); +float complex cexpf(float complex z); +long double complex cexpl(long double complex z); + +/* 7.3.7.2 clog */ +double complex clog(double complex z); +float complex clogf(float complex z); +long double complex clogl(long double complex z); + +/* 7.3.8 Power and absolute value functions */ + +/* 7.3.8.1 cabs */ +double complex cabs(double complex z); +float complex cabsf(float complex z); +long double complex cabsl(long double complex z); + +/* 7.3.8.2 cpow */ +double complex cpow(double complex z); +float complex cpowf(float complex z); +long double complex cpowl(long double complex z); + +/* 7.3.8.3 csqrt */ +double complex csqrt(double complex z); +float complex csqrtf(float complex z); +long double complex csqrtl(long double complex z); + +/* 7.3.9 Manipulation functions */ + +/* 7.3.9.1 carg */ +double complex carg(double complex z); +float complex cargf(float complex z); +long double complex cargl(long double complex z); + +/* 7.3.9.2 cimag */ +double complex cimag(double complex z); +float complex cimagf(float complex z); +long double complex cimagl(long double complex z); + +/* 7.3.9.3 conj */ +double complex conj(double complex z); +float complex conjf(float complex z); +long double complex conjl(long double complex z); + +/* 7.3.9.4 cproj */ +double complex cproj(double complex z); +float complex cprojf(float complex z); +long double complex cprojl(long double complex z); + +/* 7.3.9.5 creal */ +double complex creal(double complex z); +float complex crealf(float complex z); +long double complex creall(long double complex z); diff --git a/containers/posix/libc2/include/ctype.h b/containers/posix/libc2/include/ctype.h new file mode 100644 index 0000000..817d9d9 --- /dev/null +++ b/containers/posix/libc2/include/ctype.h @@ -0,0 +1,204 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Cristan Szmadja, Ben Leslie + Description: + Implements character handling as per 7.4 + Status: Incomplete + Ignores locale +*/ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +static inline int +iscntrl(int c) +{ + return (0 <= c && c <= '\037') || c == '\177'; +} + +static inline int +isgraph(int c) +{ + return ' ' < c && c < '\177'; +} + +static inline int +isprint(int c) +{ + return ' ' <= c && c < '\177'; +} + +static inline int +isdigit(int c) +{ + return '0' <= c && c <= '9'; +} + +static inline int +islower(int c) +{ + return 'a' <= c && c <= 'z'; +} + +static inline int +isspace(int c) +{ + return c == ' ' || ('\011' <= c && c <= '\015'); +} + +static inline int +isupper(int c) +{ + return 'A' <= c && c <= 'Z'; +} + +static inline int +isalpha(int c) +{ + return isupper(c) || islower(c); +} + +static inline int +isalnum(int c) +{ + return isalpha(c) || isdigit(c); +} + +static inline int +ispunct(int c) +{ + return isgraph(c) && !isalnum(c); +} + +static inline int +isxdigit(int c) +{ + return isdigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f'); +} + +static inline int +tolower(int c) +{ + return isupper(c) ? c + ('a' - 'A') : c; +} + +static inline int +toupper(int c) +{ + return islower(c) ? c - ('a' - 'A') : c; +} + +static inline int +isascii(int c) +{ + return 0 <= c && c <= '\177'; +} + +static inline int +toascii(int c) +{ + return c & 0177; +} + +static inline int +digittoint(int c) +{ + return isdigit(c) ? c - '0' : 'A' <= c + && c <= 'Z' ? c - 'A' : 'a' <= c && c <= 'z' ? c - 'a' : 99; +} + +#endif /* !_CTYPE_H_ */ + +/* XXX: Extra things needed by POSIX... need to find a correct #ifndef */ + +/* + +int isascii(int); +int toascii(int); + +#define _toupper(x) +#define _tolower(x) + + +*/ + + + diff --git a/containers/posix/libc2/include/errno.h b/containers/posix/libc2/include/errno.h new file mode 100644 index 0000000..4b4db9a --- /dev/null +++ b/containers/posix/libc2/include/errno.h @@ -0,0 +1,104 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Ben Leslie + Description: + Errors as per 7.5 + Status: Complete + Restrictions: Single threaded +*/ + +#ifndef _ERRNO_H_ +#define _ERRNO_H_ + +#define EDOM 1 +#define EILSEQ 2 +#define ERANGE 3 + +#include + +#ifndef THREAD_SAFE +extern int errno; +#else +#define errno (*((int *)__L4_TCR_ThreadLocalStorage())) +#endif + +#endif /* _ERRNO_H_ */ + diff --git a/containers/posix/libc2/include/inttypes.h b/containers/posix/libc2/include/inttypes.h new file mode 100644 index 0000000..e7e9a6a --- /dev/null +++ b/containers/posix/libc2/include/inttypes.h @@ -0,0 +1,202 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Ben Leslie +*/ + +#ifndef _INT_TYPES_ +#define _INT_TYPES_ + +#include + +#include + +/* 7.8.1 Macros for format specifies */ + +/* 7.8.1.2 signed integers */ +#define PRId8 __LENGTH_8_MOD "d" +#define PRId16 __LENGTH_16_MOD "d" +#define PRId32 __LENGTH_32_MOD "d" +#define PRId64 __LENGTH_64_MOD "d" + +#define PRIi8 __LENGTH_8_MOD "i" +#define PRIi16 __LENGTH_16_MOD "i" +#define PRIi32 __LENGTH_32_MOD "i" +#define PRIi64 __LENGTH_64_MOD "i" + +#define PRIdLEAST8 __LENGTH_LEAST8_MOD "d" +#define PRIdLEAST16 __LENGTH_LEAST16_MOD "d" +#define PRIdLEAST32 __LENGTH_LEAST32_MOD "d" +#define PRIdLEAST64 __LENGTH_LEAST64_MOD "d" + +#define PRIiLEAST8 __LENGTH_LEAST8_MOD "i" +#define PRIiLEAST16 __LENGTH_LEAST16_MOD "i" +#define PRIiLEAST32 __LENGTH_LEAST32_MOD "i" +#define PRIiLEAST64 __LENGTH_LEAST64_MOD "i" + +#define PRIdFAST8 __LENGTH_FAST8_MOD "d" +#define PRIdFAST16 __LENGTH_FAST16_MOD "d" +#define PRIdFAST32 __LENGTH_FAST32_MOD "d" +#define PRIdFAST64 __LENGTH_FAST64_MOD "d" + +#define PRIiFAST8 __LENGTH_FAST8_MOD "i" +#define PRIiFAST16 __LENGTH_FAST16_MOD "i" +#define PRIiFAST32 __LENGTH_FAST32_MOD "i" +#define PRIiFAST64 __LENGTH_FAST64_MOD "i" + +#define PRIdMAX __LENGTH_MAX_MOD "d" +#define PRIiMAX __LENGTH_MAX_MOD "i" + +#define PRIdPTR __LENGTH_PTR_MOD "d" +#define PRIiPTR __LENGTH_PTR_MOD "i" + +/* 7.8 __LENGTH_8_MOD.1.3 unsigned integers */ + +#define PRIo8 __LENGTH_8_MOD "o" +#define PRIo16 __LENGTH_16_MOD "o" +#define PRIo32 __LENGTH_32_MOD "o" +#define PRIo64 __LENGTH_64_MOD "o" + +#define PRIu8 __LENGTH_8_MOD "u" +#define PRIu16 __LENGTH_16_MOD "u" +#define PRIu32 __LENGTH_32_MOD "u" +#define PRIu64 __LENGTH_64_MOD "u" + +#define PRIx8 __LENGTH_8_MOD "x" +#define PRIx16 __LENGTH_16_MOD "x" +#define PRIx32 __LENGTH_32_MOD "x" +#define PRIx64 __LENGTH_64_MOD "x" + +#define PRIX8 __LENGTH_8_MOD "X" +#define PRIX16 __LENGTH_16_MOD "X" +#define PRIX32 __LENGTH_32_MOD "X" +#define PRIX64 __LENGTH_64_MOD "X" + +#define PRIoLEAST8 __LENGTH_LEAST8_MOD "o" +#define PRIoLEAST16 __LENGTH_LEAST16_MOD "o" +#define PRIoLEAST32 __LENGTH_LEAST32_MOD "o" +#define PRIoLEAST64 __LENGTH_LEAST64_MOD "o" + +#define PRIuLEAST8 __LENGTH_LEAST8_MOD "u" +#define PRIuLEAST16 __LENGTH_LEAST16_MOD "u" +#define PRIuLEAST32 __LENGTH_LEAST32_MOD "u" +#define PRIuLEAST64 __LENGTH_LEAST64_MOD "u" + +#define PRIxLEAST8 __LENGTH_LEAST8_MOD "x" +#define PRIxLEAST16 __LENGTH_LEAST16_MOD "x" +#define PRIxLEAST32 __LENGTH_LEAST32_MOD "x" +#define PRIxLEAST64 __LENGTH_LEAST64_MOD "x" + +#define PRIXLEAST8 __LENGTH_LEAST8_MOD "X" +#define PRIXLEAST16 __LENGTH_LEAST16_MOD "X" +#define PRIXLEAST32 __LENGTH_LEAST32_MOD "X" +#define PRIXLEAST64 __LENGTH_LEAST64_MOD "X" + +#define PRIoFAST8 __LENGTH_FAST8_MOD "o" +#define PRIoFAST16 __LENGTH_FAST16_MOD "o" +#define PRIoFAST32 __LENGTH_FAST32_MOD "o" +#define PRIoFAST64 __LENGTH_FAST64_MOD "o" + +#define PRIuFAST8 __LENGTH_FAST8_MOD "u" +#define PRIuFAST16 __LENGTH_FAST16_MOD "u" +#define PRIuFAST32 __LENGTH_FAST32_MOD "u" +#define PRIuFAST64 __LENGTH_FAST64_MOD "u" + +#define PRIxFAST8 __LENGTH_FAST8_MOD "x" +#define PRIxFAST16 __LENGTH_FAST16_MOD "x" +#define PRIxFAST32 __LENGTH_FAST32_MOD "x" +#define PRIxFAST64 __LENGTH_FAST64_MOD "x" + +#define PRIXFAST8 __LENGTH_FAST8_MOD "X" +#define PRIXFAST16 __LENGTH_FAST16_MOD "X" +#define PRIXFAST32 __LENGTH_FAST32_MOD "X" +#define PRIXFAST64 __LENGTH_FAST64_MOD "X" + +#define PRIoMAX __LENGTH_MAX_MOD "o" +#define PRIuMAX __LENGTH_MAX_MOD "u" +#define PRIxMAX __LENGTH_MAX_MOD "x" +#define PRIXMAX __LENGTH_MAX_MOD "X" + +#define PRIoPTR __LENGTH_PTR_MOD "o" +#define PRIuPTR __LENGTH_PTR_MOD "u" +#define PRIxPTR __LENGTH_PTR_MOD "x" +#define PRIXPTR __LENGTH_PTR_MOD "X" + +#endif diff --git a/containers/posix/libc2/include/iso646.h b/containers/posix/libc2/include/iso646.h new file mode 100644 index 0000000..a1a4d9f --- /dev/null +++ b/containers/posix/libc2/include/iso646.h @@ -0,0 +1,101 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Ben Leslie + Description: + Alternative spellings as per 7.9 +*/ + +#ifndef _ISO646_H_ +#define _ISO646_H_ + +#define and && +#define and_q &= +#define bitand & +#define bitor | +#define compl ~ +#define not ! +#define not_eq != +#define or || +#define or_eq |= +#define xor ^ +#define xor_eq ^= + +#endif /* _ISO646_H_ */ diff --git a/containers/posix/libc2/include/limits.h b/containers/posix/libc2/include/limits.h new file mode 100644 index 0000000..43038ec --- /dev/null +++ b/containers/posix/libc2/include/limits.h @@ -0,0 +1,116 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#define CHAR_BIT 8 +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 +#define UCHAR_MAX 255 + +#ifdef __CHAR_UNSIGNED__ + #define CHAR_MIN 0 + #define CHAR_MAX UCHAR_MAX +#else + #define CHAR_MIN SCHAR_MIN + #define CHAR_MAX SCHAR_MAX +#endif + +#define MB_LEN_MAX 1 + +#define SHRT_MIN (-32768) +#define SHRT_MAX 32767 +#define USHRT_MAX 65535U + +#define INT_MIN (-2147483648) +#define INT_MAX 2147483647 +#define UINT_MAX 4294967295U + +#define LONG_MIN (-2147483648) +#define LONG_MAX 2147483647 +#define ULONG_MAX 4294967295U + +#define LLONG_MIN (-9223372036854775808LL) +#define LLONG_MAX 9223372036854775807LL +#define ULLONG_MAX 18446744073709551615ULL + +#endif /* _LIMITS_H_ */ diff --git a/containers/posix/libc2/include/locale.h b/containers/posix/libc2/include/locale.h new file mode 100644 index 0000000..9ceaeb6 --- /dev/null +++ b/containers/posix/libc2/include/locale.h @@ -0,0 +1,117 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *mon_deciaml_point; + char *mon_thouasands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char *currency_symbol; + char frac_digits; + char p_cs_precedes; + char n_cs_precedes; + char p_sep_by_space; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + char *int_curr_symbol; + char int_frac_digits; + char int_p_cs_precedes; + char int_n_cs_precedes; + char int_p_sep_by_space; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; +}; + +#define LC_ALL 1 +#define LC_COLLATE 2 +#define LC_CTYPE 3 +#define LC_MONETARY 4 +#define LC_NUMERIC 5 +#define LC_TIME 6 + +char *setlocale(int category, const char *locale); +struct lconv *localeconv(void); diff --git a/containers/posix/libc2/include/setjmp.h b/containers/posix/libc2/include/setjmp.h new file mode 100644 index 0000000..ea5790a --- /dev/null +++ b/containers/posix/libc2/include/setjmp.h @@ -0,0 +1,90 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie, Alex Webster +*/ +#ifndef _SETJMP_H_ +#define _SETJMP_H_ + +#include + +int setjmp(jmp_buf); +void longjmp(jmp_buf, int); + +#endif /* _SETJMP_H_ */ diff --git a/containers/posix/libc2/include/stdarg.h b/containers/posix/libc2/include/stdarg.h new file mode 100644 index 0000000..d53f0e2 --- /dev/null +++ b/containers/posix/libc2/include/stdarg.h @@ -0,0 +1,96 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Authors: Ben Leslie +*/ +/* + Implementation based on C99 Section 7.15 Variable arguments +*/ + +#ifndef _STDARG_H_ +#define _STDARG_H_ + +typedef __builtin_va_list va_list; + +#define va_arg(ap, type) __builtin_va_arg((ap), type) +#define va_copy(dest, src) __builtin_va_copy((ap), type) +#define va_end(ap) __builtin_va_end((ap)) +#define va_start(ap, parmN) __builtin_stdarg_start((ap), (parmN)) + +#endif /* _STDARG_H_ */ diff --git a/containers/posix/libc/include/stdbool.h b/containers/posix/libc2/include/stdbool.h similarity index 100% rename from containers/posix/libc/include/stdbool.h rename to containers/posix/libc2/include/stdbool.h diff --git a/containers/posix/libc2/include/stddef.h b/containers/posix/libc2/include/stddef.h new file mode 100644 index 0000000..99a5f12 --- /dev/null +++ b/containers/posix/libc2/include/stddef.h @@ -0,0 +1,117 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Ben Leslie +*/ + +#ifndef _STDDEF_H_ +#define _STDDEF_H_ + +/* See C99 spec 7.17 */ + +/* We rely on the compiler telling us the right types to go in + here -- this makes a lot of sense, the compiler knows how big + these things are +*/ + +#ifndef __SIZE_TYPE__ +#ifdef __mips__ +#define __SIZE_TYPE__ long unsigned int +#endif +#endif + +#ifndef __PTRDIFF_TYPE__ +#ifdef __mips__ +#define __PTRDIFF_TYPE__ long int +#endif +#endif + +typedef __PTRDIFF_TYPE__ ptrdiff_t ; +typedef __SIZE_TYPE__ size_t; +#ifndef __cplusplus /* FIXME: This is the one concession to C++ programmers that I make. + Allowing them to compile and use the standard C library. This is + more because C++ people shouldn't be restricted from using wonderful + things such as varargs and printf */ +typedef __WCHAR_TYPE__ wchar_t; +#endif +#define NULL ((void *)0) +#define offsetof(type, member) ((size_t) &((type *)0)->member) + +#endif /* _STDDEF_H_ */ diff --git a/containers/posix/libc/include/stdint.h b/containers/posix/libc2/include/stdint.h similarity index 100% rename from containers/posix/libc/include/stdint.h rename to containers/posix/libc2/include/stdint.h diff --git a/containers/posix/libc/include/stdio.h b/containers/posix/libc2/include/stdio.h similarity index 97% rename from containers/posix/libc/include/stdio.h rename to containers/posix/libc2/include/stdio.h index dfc2af0..374a87f 100644 --- a/containers/posix/libc/include/stdio.h +++ b/containers/posix/libc2/include/stdio.h @@ -136,9 +136,9 @@ typedef long fpos_t; /* same */ #define FILENAME_MAX 37 #define L_tmpnam 37 -//#define SEEK_CUR 0 -//#define SEEK_END 1 -//#define SEEK_SET 2 +#define SEEK_CUR 0 +#define SEEK_END 1 +#define SEEK_SET 2 #define TMP_MAX 37 @@ -161,7 +161,7 @@ int setvbuf(FILE *, char *, int, size_t); /* 7.19.6 Format i/o functions */ int fprintf(FILE *, const char *, ...); int fscanf(FILE *, const char *, ...); -//int printf(const char *format, ...) __attribute__((format (printf, 1, 2))); +int printf(const char *format, ...) __attribute__((format (printf, 1, 2))); int scanf(const char *, ...); int snprintf(char *, size_t , const char *, ...); int sprintf(char *, const char *, ...); @@ -177,7 +177,7 @@ int vsscanf(const char *s, const char *format, va_list arg); /* 7.19.7 Character i/o functions */ int fgetc(FILE *); char *fgets(char *, int, FILE *); -//int fputc(int, FILE *); +int fputc(int, FILE *); int fputs(const char *, FILE *); /* getc is specified to be the same as fgetc, so it makes @@ -189,7 +189,7 @@ char *gets(char *); /* putc is specified to be the same as fputc, so it makes the most sense to implement as a macro here */ -//#define putc fputc /*int fetc(int, FILE *); */ +#define putc fputc /*int fetc(int, FILE *); */ int putchar(int); int puts(const char *); diff --git a/containers/posix/libc2/include/stdlib.h b/containers/posix/libc2/include/stdlib.h new file mode 100644 index 0000000..50f8455 --- /dev/null +++ b/containers/posix/libc2/include/stdlib.h @@ -0,0 +1,210 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include +#include + +/* ISOC99 7.20 General Utilities */ + +/* 7.20.2 div types */ +typedef struct { + int quot, rem; +} div_t; + +typedef struct { + long quot, rem; +} ldiv_t; + +typedef struct { + long long quot, rem; +} lldiv_t; + + +/* 7.20.3 EXIT_ macros */ +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX INT_MAX +#define MB_CUR_MAX 1 + +/* 7.20.1 Numeric conversion functions */ + +/* 7.20.1-3 The strtod, strtof and strtold functions */ +double strtod(const char *s, char **endp); +float strtof(const char *s, char **endp); +long double strtold(const char *s, char **endp); + +/* 7.20.1-4 The strtol, stroll, stroul, strtoull functions */ +long strtol(const char *s, char **endp, int base); +long long strtoll(const char *s, char **endp, int base); +unsigned long strtoul(const char *s, char **endp, int base); +unsigned long long strtoull(const char *s, char **endp, int base); + +/* 7.20.1-1 atof function */ +static inline double atof(const char *nptr) +{ + return strtod(nptr, (char **)NULL); +} + +/* 7.20.1-2 The atoi, atol and atoll functions */ +static inline int atoi(const char *nptr) +{ + return (int) strtol(nptr, (char **)NULL, 10); +} + +static inline long atol(const char *nptr) +{ + return strtol(nptr, (char **)NULL, 10); +} + +static inline long long atoll(const char *nptr) +{ + return strtoll(nptr, (char **)NULL, 10); +} + +/* 7.20.2 Pseudo-random sequence generation functions */ + +int rand(void); +void srand(unsigned int seed); + +/* 7.20.3 Memory management functions */ + +void *malloc(size_t); +void free(void *); +void *calloc(size_t, size_t); +void *realloc(void *, size_t); + +/* 7.20.4 Communcation with the environment */ + +void abort(void); +int atexit(void (*func)(void)); +void exit(int status); +void _Exit(int status); +char *getenv(const char *name); +int system(const char *string); + +/* 7.20.5 Searching and sortin utilities */ +void *bsearch(const void *key, const void *base, size_t nmemb, size_t, int (*compar)(const void *, const void*)); +void qsort(void *base, size_t nmemb, size_t, int (*compar)(const void *, const void*)); + +/* 7.20.6 Integer arithmetic function */ + +/* FIXME: (benjl) Gcc defines these, but if we aren't using gcc it probably + won't, but how do we know? Or maybe we should compile with -fnobuiltin? */ + +int abs(int); +long labs(long); +long long llabs(long long); + +#if 0 +static inline int +abs(int x) +{ + return x < 0 ? -x : x; +} + +static inline long +labs(long x) +{ + return x < 0 ? -x : x; +} + +static inline long long +llabs(long long x) +{ + return x < 0 ? -x : x; +} +#endif +/* 7.20.7 Multibyte/wide character conversion functions */ +#if 0 /* We don't have wide characters */ +int mblen(const char *s, size_t n); +int mbtowc(wchar_t pwc, const char *s, size_t n); +int wctomb(char *s, wchat_t wc); +#endif + +/* 7.20.8 Multibyte/wide string conversion functions */ +#if 0 /* We don't have wide characters */ +size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n); +size_t wcstombs(char *s, constwchat_t *pwcs, size_t n); +#endif + +#endif /* _STDLIB_H_ */ diff --git a/containers/posix/libc2/include/string.h b/containers/posix/libc2/include/string.h new file mode 100644 index 0000000..949c211 --- /dev/null +++ b/containers/posix/libc2/include/string.h @@ -0,0 +1,122 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifndef _STRING_H_ +#define _STRING_H_ + +#include + +/* 7.21.2 Copying functions */ +void *memcpy(void *s1, const void *s2, size_t n); +void *memmove(void *s1, const void *s2, size_t n); +char *strcpy(char *s1, const char *s2); +char *strncpy(char *s1, const char *s2, size_t n); + +/* 7.21.3 Concatenation functions */ +char *strcat(char *s1, const char *s2); +char *strncat(char *s1, const char *s2, size_t n); + +/* 7.21.4 Comparison functions */ +int memcmp(const void *s1, const void *s2, size_t n); +int strcmp(const char *s1, const char *s2); +int strcoll(const char *s1, const char *s2); +int strncmp(const char *s1, const char *s2, size_t n); +size_t strxfrm(char *s1, const char *s2, size_t n); + +/* 7.21.5 Search functions */ +void *memchr(const void *s, int c, size_t n); +char *strchr(const char *s, int c); +size_t strcspn(const char *s1, const char *s2); +char *strpbrk(const char *s1, const char *s2); +char *strrchr(const char *s, int c); +size_t strspn(const char *s1, const char *s2); +char *strstr(const char *s1, const char *s2); +char *strtok(char *s1, const char *s2); + +/* 7.21.6 Miscellaneous functions */ +void *memset(void *, int, size_t); +char *strerror(int errnum); +size_t strlen(const char *); + +/* Extra POSIX defined thigns that aren't part of the C standard */ +#ifdef _USE_XOPEN +char *strdup(const char *); +#endif + +#endif /* _STRING_H_ */ diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/inttypes.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/inttypes.h new file mode 100644 index 0000000..329ca46 --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/inttypes.h @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#define __LENGTH_8_MOD "hh" +#define __LENGTH_16_MOD "h" +#define __LENGTH_32_MOD +#define __LENGTH_64_MOD "ll" +#define __LENGTH_MAX_MOD "ll" +#define __LENGTH_PTR_MOD diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/pl011_uart.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/pl011_uart.h new file mode 100644 index 0000000..cd2551f --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/pl011_uart.h @@ -0,0 +1,408 @@ + +#ifndef __PL011__UART__H__ +#define __PL011__UART__H__ + +/* + * PL011 UART Generic driver implementation. + * Copyright Bahadir Balban (C) 2006 + * + * The particular intention of this code is that it has been carefully + * written as decoupled from os-specific code and in a verbose way such + * that it clearly demonstrates how the device operates, reducing the + * amount of time to be spent for understanding the operational model + * and implementing a driver from scratch. This is the very first to be + * such a driver so far, hopefully it will turn out to be useful. + */ + +/* Default base address for this chip */ +#define PL011_DEFAULT_PHYSICAL_BASE 0x101F1000 +#define PL011_BASE PL011_DEFAULT_PHYSICAL_BASE + +/* Architecture specific memory access macros */ +#define read(val, address) val = *((volatile unsigned int *) address) +#define write(val, address) *((volatile unsigned int *) address) = val + +/* Register offsets */ +#define PL011_UARTDR (PL011_BASE + 0x00) +#define PL011_UARTRSR (PL011_BASE + 0x04) +#define PL011_UARTECR (PL011_BASE + 0x04) +#define PL011_UARTFR (PL011_BASE + 0x18) +#define PL011_UARTILPR (PL011_BASE + 0x20) +#define PL011_UARTIBRD (PL011_BASE + 0x24) +#define PL011_UARTFBRD (PL011_BASE + 0x28) +#define PL011_UARTLCR_H (PL011_BASE + 0x2C) +#define PL011_UARTCR (PL011_BASE + 0x30) +#define PL011_UARTIFLS (PL011_BASE + 0x34) +#define PL011_UARTIMSC (PL011_BASE + 0x38) +#define PL011_UARTRIS (PL011_BASE + 0x3C) +#define PL011_UARTMIS (PL011_BASE + 0x40) +#define PL011_UARTICR (PL011_BASE + 0x44) +#define PL011_UARTDMACR (PL011_BASE + 0x48) + +/* IRQ bits for each uart irq event */ +#define PL011_RXIRQ (1 << 4) +#define PL011_TXIRQ (1 << 5) +#define PL011_RXTIMEOUTIRQ (1 << 6) +#define PL011_FEIRQ (1 << 7) +#define PL011_PEIRQ (1 << 8) +#define PL011_BEIRQ (1 << 9) +#define PL011_OEIRQ (1 << 10) + +struct pl011_uart; + +int pl011_initialise(struct pl011_uart *); +int pl011_tx_char(char); +int pl011_rx_char(char *); + +void pl011_set_baudrate(unsigned int, unsigned int); +void pl011_set_irq_mask(unsigned int); +void pl011_clr_irq_mask(unsigned int); + +void pl011_irq_handler(struct pl011_uart *); +void pl011_tx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_rx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_error_irq_handler(struct pl011_uart *, unsigned int); + +static inline void pl011_uart_enable(void); +static inline void pl011_uart_disable(void); +static inline void pl011_tx_enable(void); +static inline void pl011_tx_disable(void); +static inline void pl011_rx_enable(void); +static inline void pl011_rx_disable(void); +static inline void pl011_irq_clear(unsigned int flags); +static inline unsigned int pl011_read_irqstat(void); +static inline unsigned int pl011_read_irqmask(void); +static inline void pl011_rx_dma_disable(void); +static inline void pl011_rx_dma_enable(void); +static inline void pl011_tx_dma_enable(void); +static inline void pl011_tx_dma_disable(void); +static inline void pl011_set_irq_fifolevel(unsigned int xfer, + unsigned int level); +static inline void pl011_set_word_width(int size); +static inline void pl011_disable_fifos(void); +static inline void pl011_set_parity_even(void); +static inline void pl011_parity_enable(void); +static inline void pl011_set_stopbits(int stopbits); + +static inline void pl011_set_parity_odd(void); +static inline void pl011_enable_fifos(void); +static inline void pl011_parity_disable(void); + +struct pl011_uart_ops { + int (*initialise)(struct pl011_uart *); + + int (*tx_char)(char); + int (*rx_char)(char *); + + void (*set_baudrate)(unsigned int, unsigned int); + void (*set_irq_mask)(unsigned int); + void (*clr_irq_mask)(unsigned int); + + void (*irq_handler)(struct pl011_uart *); + void (*tx_irq_handler)(struct pl011_uart *, unsigned int); + void (*rx_irq_handler)(struct pl011_uart *, unsigned int); + void (*error_irq_handler)(struct pl011_uart *, unsigned int); +}; + +struct pl011_uart { + const unsigned int base; + struct pl011_uart_ops ops; + unsigned int frame_errors; + unsigned int parity_errors; + unsigned int break_errors; + unsigned int overrun_errors; + unsigned int rx_timeout_errors; +}; + + + +#define PL011_UARTEN (1 << 0) +static inline void pl011_uart_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +static inline void pl011_uart_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +#define PL011_TXE (1 << 8) +static inline void pl011_tx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_TXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_tx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_TXE; + write(val, PL011_UARTCR); + return; +} + + +#define PL011_RXE (1 << 9) +static inline void pl011_rx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_rx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +#define PL011_TWO_STOPBITS_SELECT (1 << 3) +static inline void pl011_set_stopbits(int stopbits) +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + + if(stopbits == 2) { /* Set to two bits */ + val |= PL011_TWO_STOPBITS_SELECT; + } else { /* Default is 1 */ + val &= ~PL011_TWO_STOPBITS_SELECT; + } + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_ENABLE (1 << 1) +static inline void pl011_parity_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_parity_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_EVEN (1 << 2) +static inline void pl011_set_parity_even() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_set_parity_odd() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_ENABLE_FIFOS (1 << 4) +static inline void pl011_enable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_disable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + + +#define PL011_WORD_WIDTH_SHIFT (5) +/* Sets the transfer word width for the data register. */ +static inline void pl011_set_word_width(int size) +{ + unsigned int val; + val = 0; + + if(size < 5 || size > 8) /* Default is 8 */ + size = 8; + + /* Clear size field */ + read(val, PL011_UARTLCR_H); + val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT); + write(val, PL011_UARTLCR_H); + + /* The formula is to write 5 less of size given: + * 11 = 8 bits + * 10 = 7 bits + * 01 = 6 bits + * 00 = 5 bits + */ + read(val, PL011_UARTLCR_H); + val |= (size - 5) << PL011_WORD_WIDTH_SHIFT; + write(val, PL011_UARTLCR_H); + + return; +} + +/* + * Defines at which level of fifo fullness an irq will be generated. + * @xfer: tx fifo = 0, rx fifo = 1 + * @level: Generate irq if: + * 0 rxfifo >= 1/8 full txfifo <= 1/8 full + * 1 rxfifo >= 1/4 full txfifo <= 1/4 full + * 2 rxfifo >= 1/2 full txfifo <= 1/2 full + * 3 rxfifo >= 3/4 full txfifo <= 3/4 full + * 4 rxfifo >= 7/8 full txfifo <= 7/8 full + * 5-7 reserved reserved + */ +static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level) +{ + if(xfer != 1 && xfer != 0) /* Invalid fifo */ + return; + + if(level > 4) /* Invalid level */ + return; + + write(level << (xfer * 3), PL011_UARTIFLS); + return; +} + +/* returns which irqs are masked */ +static inline unsigned int pl011_read_irqmask(void) +{ + unsigned int flags; + read(flags, PL011_UARTIMSC); + return flags; +} + +/* returns masked irq status */ +static inline unsigned int pl011_read_irqstat(void) +{ + unsigned int irqstatus; + read(irqstatus, PL011_UARTMIS); + return irqstatus; +} +/* Clears the given asserted irqs */ +static inline void pl011_irq_clear(unsigned int flags) +{ + if(flags > 0x3FF) { /* Invalid irq clearing bitvector */ + return; + } + /* Simply write the flags since it's a write-only register */ + write(flags, PL011_UARTICR); + return; +} + +#define PL011_TXDMAEN (1 << 1) +#define PL011_RXDMAEN (1 << 0) + +/* Enables dma transfers for uart. The dma controller + * must be initialised, set-up and enabled separately. + */ +static inline void pl011_tx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +/* Disables dma transfers for uart */ +static inline void pl011_tx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + + +#endif /* __PL011__UART__ */ + diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/setjmp.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/setjmp.h new file mode 100644 index 0000000..22a17cd --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/setjmp.h @@ -0,0 +1,83 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Alex Webster +*/ + +typedef int jmp_buf[10]; diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/stdint.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/stdint.h new file mode 100644 index 0000000..6078b0a --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/stdint.h @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define __PTR_SIZE 32 diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/inttypes.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/inttypes.h new file mode 100644 index 0000000..329ca46 --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/inttypes.h @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#define __LENGTH_8_MOD "hh" +#define __LENGTH_16_MOD "h" +#define __LENGTH_32_MOD +#define __LENGTH_64_MOD "ll" +#define __LENGTH_MAX_MOD "ll" +#define __LENGTH_PTR_MOD diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/pl011_uart.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/pl011_uart.h new file mode 100644 index 0000000..cd2551f --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/pl011_uart.h @@ -0,0 +1,408 @@ + +#ifndef __PL011__UART__H__ +#define __PL011__UART__H__ + +/* + * PL011 UART Generic driver implementation. + * Copyright Bahadir Balban (C) 2006 + * + * The particular intention of this code is that it has been carefully + * written as decoupled from os-specific code and in a verbose way such + * that it clearly demonstrates how the device operates, reducing the + * amount of time to be spent for understanding the operational model + * and implementing a driver from scratch. This is the very first to be + * such a driver so far, hopefully it will turn out to be useful. + */ + +/* Default base address for this chip */ +#define PL011_DEFAULT_PHYSICAL_BASE 0x101F1000 +#define PL011_BASE PL011_DEFAULT_PHYSICAL_BASE + +/* Architecture specific memory access macros */ +#define read(val, address) val = *((volatile unsigned int *) address) +#define write(val, address) *((volatile unsigned int *) address) = val + +/* Register offsets */ +#define PL011_UARTDR (PL011_BASE + 0x00) +#define PL011_UARTRSR (PL011_BASE + 0x04) +#define PL011_UARTECR (PL011_BASE + 0x04) +#define PL011_UARTFR (PL011_BASE + 0x18) +#define PL011_UARTILPR (PL011_BASE + 0x20) +#define PL011_UARTIBRD (PL011_BASE + 0x24) +#define PL011_UARTFBRD (PL011_BASE + 0x28) +#define PL011_UARTLCR_H (PL011_BASE + 0x2C) +#define PL011_UARTCR (PL011_BASE + 0x30) +#define PL011_UARTIFLS (PL011_BASE + 0x34) +#define PL011_UARTIMSC (PL011_BASE + 0x38) +#define PL011_UARTRIS (PL011_BASE + 0x3C) +#define PL011_UARTMIS (PL011_BASE + 0x40) +#define PL011_UARTICR (PL011_BASE + 0x44) +#define PL011_UARTDMACR (PL011_BASE + 0x48) + +/* IRQ bits for each uart irq event */ +#define PL011_RXIRQ (1 << 4) +#define PL011_TXIRQ (1 << 5) +#define PL011_RXTIMEOUTIRQ (1 << 6) +#define PL011_FEIRQ (1 << 7) +#define PL011_PEIRQ (1 << 8) +#define PL011_BEIRQ (1 << 9) +#define PL011_OEIRQ (1 << 10) + +struct pl011_uart; + +int pl011_initialise(struct pl011_uart *); +int pl011_tx_char(char); +int pl011_rx_char(char *); + +void pl011_set_baudrate(unsigned int, unsigned int); +void pl011_set_irq_mask(unsigned int); +void pl011_clr_irq_mask(unsigned int); + +void pl011_irq_handler(struct pl011_uart *); +void pl011_tx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_rx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_error_irq_handler(struct pl011_uart *, unsigned int); + +static inline void pl011_uart_enable(void); +static inline void pl011_uart_disable(void); +static inline void pl011_tx_enable(void); +static inline void pl011_tx_disable(void); +static inline void pl011_rx_enable(void); +static inline void pl011_rx_disable(void); +static inline void pl011_irq_clear(unsigned int flags); +static inline unsigned int pl011_read_irqstat(void); +static inline unsigned int pl011_read_irqmask(void); +static inline void pl011_rx_dma_disable(void); +static inline void pl011_rx_dma_enable(void); +static inline void pl011_tx_dma_enable(void); +static inline void pl011_tx_dma_disable(void); +static inline void pl011_set_irq_fifolevel(unsigned int xfer, + unsigned int level); +static inline void pl011_set_word_width(int size); +static inline void pl011_disable_fifos(void); +static inline void pl011_set_parity_even(void); +static inline void pl011_parity_enable(void); +static inline void pl011_set_stopbits(int stopbits); + +static inline void pl011_set_parity_odd(void); +static inline void pl011_enable_fifos(void); +static inline void pl011_parity_disable(void); + +struct pl011_uart_ops { + int (*initialise)(struct pl011_uart *); + + int (*tx_char)(char); + int (*rx_char)(char *); + + void (*set_baudrate)(unsigned int, unsigned int); + void (*set_irq_mask)(unsigned int); + void (*clr_irq_mask)(unsigned int); + + void (*irq_handler)(struct pl011_uart *); + void (*tx_irq_handler)(struct pl011_uart *, unsigned int); + void (*rx_irq_handler)(struct pl011_uart *, unsigned int); + void (*error_irq_handler)(struct pl011_uart *, unsigned int); +}; + +struct pl011_uart { + const unsigned int base; + struct pl011_uart_ops ops; + unsigned int frame_errors; + unsigned int parity_errors; + unsigned int break_errors; + unsigned int overrun_errors; + unsigned int rx_timeout_errors; +}; + + + +#define PL011_UARTEN (1 << 0) +static inline void pl011_uart_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +static inline void pl011_uart_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +#define PL011_TXE (1 << 8) +static inline void pl011_tx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_TXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_tx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_TXE; + write(val, PL011_UARTCR); + return; +} + + +#define PL011_RXE (1 << 9) +static inline void pl011_rx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_rx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +#define PL011_TWO_STOPBITS_SELECT (1 << 3) +static inline void pl011_set_stopbits(int stopbits) +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + + if(stopbits == 2) { /* Set to two bits */ + val |= PL011_TWO_STOPBITS_SELECT; + } else { /* Default is 1 */ + val &= ~PL011_TWO_STOPBITS_SELECT; + } + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_ENABLE (1 << 1) +static inline void pl011_parity_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_parity_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_EVEN (1 << 2) +static inline void pl011_set_parity_even() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_set_parity_odd() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_ENABLE_FIFOS (1 << 4) +static inline void pl011_enable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_disable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + + +#define PL011_WORD_WIDTH_SHIFT (5) +/* Sets the transfer word width for the data register. */ +static inline void pl011_set_word_width(int size) +{ + unsigned int val; + val = 0; + + if(size < 5 || size > 8) /* Default is 8 */ + size = 8; + + /* Clear size field */ + read(val, PL011_UARTLCR_H); + val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT); + write(val, PL011_UARTLCR_H); + + /* The formula is to write 5 less of size given: + * 11 = 8 bits + * 10 = 7 bits + * 01 = 6 bits + * 00 = 5 bits + */ + read(val, PL011_UARTLCR_H); + val |= (size - 5) << PL011_WORD_WIDTH_SHIFT; + write(val, PL011_UARTLCR_H); + + return; +} + +/* + * Defines at which level of fifo fullness an irq will be generated. + * @xfer: tx fifo = 0, rx fifo = 1 + * @level: Generate irq if: + * 0 rxfifo >= 1/8 full txfifo <= 1/8 full + * 1 rxfifo >= 1/4 full txfifo <= 1/4 full + * 2 rxfifo >= 1/2 full txfifo <= 1/2 full + * 3 rxfifo >= 3/4 full txfifo <= 3/4 full + * 4 rxfifo >= 7/8 full txfifo <= 7/8 full + * 5-7 reserved reserved + */ +static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level) +{ + if(xfer != 1 && xfer != 0) /* Invalid fifo */ + return; + + if(level > 4) /* Invalid level */ + return; + + write(level << (xfer * 3), PL011_UARTIFLS); + return; +} + +/* returns which irqs are masked */ +static inline unsigned int pl011_read_irqmask(void) +{ + unsigned int flags; + read(flags, PL011_UARTIMSC); + return flags; +} + +/* returns masked irq status */ +static inline unsigned int pl011_read_irqstat(void) +{ + unsigned int irqstatus; + read(irqstatus, PL011_UARTMIS); + return irqstatus; +} +/* Clears the given asserted irqs */ +static inline void pl011_irq_clear(unsigned int flags) +{ + if(flags > 0x3FF) { /* Invalid irq clearing bitvector */ + return; + } + /* Simply write the flags since it's a write-only register */ + write(flags, PL011_UARTICR); + return; +} + +#define PL011_TXDMAEN (1 << 1) +#define PL011_RXDMAEN (1 << 0) + +/* Enables dma transfers for uart. The dma controller + * must be initialised, set-up and enabled separately. + */ +static inline void pl011_tx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +/* Disables dma transfers for uart */ +static inline void pl011_tx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + + +#endif /* __PL011__UART__ */ + diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/setjmp.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/setjmp.h new file mode 100644 index 0000000..22a17cd --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/setjmp.h @@ -0,0 +1,83 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Alex Webster +*/ + +typedef int jmp_buf[10]; diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/stdint.h b/containers/posix/libc2/include/sys-baremetal/arch-arm/stdint.h new file mode 100644 index 0000000..6078b0a --- /dev/null +++ b/containers/posix/libc2/include/sys-baremetal/arch-arm/stdint.h @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define __PTR_SIZE 32 diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/inttypes.h b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/inttypes.h new file mode 100644 index 0000000..329ca46 --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/inttypes.h @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#define __LENGTH_8_MOD "hh" +#define __LENGTH_16_MOD "h" +#define __LENGTH_32_MOD +#define __LENGTH_64_MOD "ll" +#define __LENGTH_MAX_MOD "ll" +#define __LENGTH_PTR_MOD diff --git a/containers/posix/libc/include/arch-arm/pl011_uart.h b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/pl011_uart.h similarity index 98% rename from containers/posix/libc/include/arch-arm/pl011_uart.h rename to containers/posix/libc2/include/sys-userspace/arch-arm/arch/pl011_uart.h index 7de009d..341aac3 100644 --- a/containers/posix/libc/include/arch-arm/pl011_uart.h +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/pl011_uart.h @@ -105,7 +105,7 @@ struct pl011_uart_ops { }; struct pl011_uart { - unsigned int base; + const unsigned int base; struct pl011_uart_ops ops; unsigned int frame_errors; unsigned int parity_errors; @@ -281,10 +281,10 @@ static inline void pl011_set_word_width(int size) { unsigned int val; val = 0; - + if(size < 5 || size > 8) /* Default is 8 */ size = 8; - + /* Clear size field */ read(val, PL011_UARTLCR_H); val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT); @@ -299,11 +299,11 @@ static inline void pl011_set_word_width(int size) read(val, PL011_UARTLCR_H); val |= (size - 5) << PL011_WORD_WIDTH_SHIFT; write(val, PL011_UARTLCR_H); - + return; } -/* +/* * Defines at which level of fifo fullness an irq will be generated. * @xfer: tx fifo = 0, rx fifo = 1 * @level: Generate irq if: @@ -320,8 +320,8 @@ static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level return; if(level > 4) /* Invalid level */ - return; - + return; + write(level << (xfer * 3), PL011_UARTIFLS); return; } @@ -339,7 +339,7 @@ static inline unsigned int pl011_read_irqstat(void) { unsigned int irqstatus; read(irqstatus, PL011_UARTMIS); - return irqstatus; + return irqstatus; } /* Clears the given asserted irqs */ static inline void pl011_irq_clear(unsigned int flags) @@ -356,13 +356,13 @@ static inline void pl011_irq_clear(unsigned int flags) #define PL011_RXDMAEN (1 << 0) /* Enables dma transfers for uart. The dma controller - * must be initialised, set-up and enabled separately. + * must be initialised, set-up and enabled separately. */ static inline void pl011_tx_dma_enable() { unsigned int val; val = 0; - + read(val, PL011_UARTDMACR); val |= PL011_TXDMAEN; write(val, PL011_UARTDMACR); @@ -374,7 +374,7 @@ static inline void pl011_tx_dma_disable() { unsigned int val; val = 0; - + read(val, PL011_UARTDMACR); val &= ~PL011_TXDMAEN; write(val, PL011_UARTDMACR); @@ -385,7 +385,7 @@ static inline void pl011_rx_dma_enable() { unsigned int val; val = 0; - + read(val, PL011_UARTDMACR); val |= PL011_RXDMAEN; write(val, PL011_UARTDMACR); @@ -396,12 +396,13 @@ static inline void pl011_rx_dma_disable() { unsigned int val; val = 0; - + read(val, PL011_UARTDMACR); val &= ~PL011_RXDMAEN; write(val, PL011_UARTDMACR); return; } + #endif /* __PL011__UART__ */ diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/setjmp.h b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/setjmp.h new file mode 100644 index 0000000..22a17cd --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/setjmp.h @@ -0,0 +1,83 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Alex Webster +*/ + +typedef int jmp_buf[10]; diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/stdint.h b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/stdint.h new file mode 100644 index 0000000..6078b0a --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/arch/stdint.h @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define __PTR_SIZE 32 diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/inttypes.h b/containers/posix/libc2/include/sys-userspace/arch-arm/inttypes.h new file mode 100644 index 0000000..329ca46 --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/inttypes.h @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#define __LENGTH_8_MOD "hh" +#define __LENGTH_16_MOD "h" +#define __LENGTH_32_MOD +#define __LENGTH_64_MOD "ll" +#define __LENGTH_MAX_MOD "ll" +#define __LENGTH_PTR_MOD diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/pl011_uart.h b/containers/posix/libc2/include/sys-userspace/arch-arm/pl011_uart.h new file mode 100644 index 0000000..341aac3 --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/pl011_uart.h @@ -0,0 +1,408 @@ + +#ifndef __PL011__UART__H__ +#define __PL011__UART__H__ + +/* + * PL011 UART Generic driver implementation. + * Copyright Bahadir Balban (C) 2006 + * + * The particular intention of this code is that it has been carefully + * written as decoupled from os-specific code and in a verbose way such + * that it clearly demonstrates how the device operates, reducing the + * amount of time to be spent for understanding the operational model + * and implementing a driver from scratch. This is the very first to be + * such a driver so far, hopefully it will turn out to be useful. + */ + +/* Default base address for this chip */ +#define PL011_USR_BASE 0x500000 +#define PL011_BASE PL011_USR_BASE + +/* Architecture specific memory access macros */ +#define read(val, address) val = *((volatile unsigned int *) address) +#define write(val, address) *((volatile unsigned int *) address) = val + +/* Register offsets */ +#define PL011_UARTDR (PL011_BASE + 0x00) +#define PL011_UARTRSR (PL011_BASE + 0x04) +#define PL011_UARTECR (PL011_BASE + 0x04) +#define PL011_UARTFR (PL011_BASE + 0x18) +#define PL011_UARTILPR (PL011_BASE + 0x20) +#define PL011_UARTIBRD (PL011_BASE + 0x24) +#define PL011_UARTFBRD (PL011_BASE + 0x28) +#define PL011_UARTLCR_H (PL011_BASE + 0x2C) +#define PL011_UARTCR (PL011_BASE + 0x30) +#define PL011_UARTIFLS (PL011_BASE + 0x34) +#define PL011_UARTIMSC (PL011_BASE + 0x38) +#define PL011_UARTRIS (PL011_BASE + 0x3C) +#define PL011_UARTMIS (PL011_BASE + 0x40) +#define PL011_UARTICR (PL011_BASE + 0x44) +#define PL011_UARTDMACR (PL011_BASE + 0x48) + +/* IRQ bits for each uart irq event */ +#define PL011_RXIRQ (1 << 4) +#define PL011_TXIRQ (1 << 5) +#define PL011_RXTIMEOUTIRQ (1 << 6) +#define PL011_FEIRQ (1 << 7) +#define PL011_PEIRQ (1 << 8) +#define PL011_BEIRQ (1 << 9) +#define PL011_OEIRQ (1 << 10) + +struct pl011_uart; + +int pl011_initialise(struct pl011_uart *); +int pl011_tx_char(char); +int pl011_rx_char(char *); + +void pl011_set_baudrate(unsigned int, unsigned int); +void pl011_set_irq_mask(unsigned int); +void pl011_clr_irq_mask(unsigned int); + +void pl011_irq_handler(struct pl011_uart *); +void pl011_tx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_rx_irq_handler(struct pl011_uart *, unsigned int); +void pl011_error_irq_handler(struct pl011_uart *, unsigned int); + +static inline void pl011_uart_enable(void); +static inline void pl011_uart_disable(void); +static inline void pl011_tx_enable(void); +static inline void pl011_tx_disable(void); +static inline void pl011_rx_enable(void); +static inline void pl011_rx_disable(void); +static inline void pl011_irq_clear(unsigned int flags); +static inline unsigned int pl011_read_irqstat(void); +static inline unsigned int pl011_read_irqmask(void); +static inline void pl011_rx_dma_disable(void); +static inline void pl011_rx_dma_enable(void); +static inline void pl011_tx_dma_enable(void); +static inline void pl011_tx_dma_disable(void); +static inline void pl011_set_irq_fifolevel(unsigned int xfer, + unsigned int level); +static inline void pl011_set_word_width(int size); +static inline void pl011_disable_fifos(void); +static inline void pl011_set_parity_even(void); +static inline void pl011_parity_enable(void); +static inline void pl011_set_stopbits(int stopbits); + +static inline void pl011_set_parity_odd(void); +static inline void pl011_enable_fifos(void); +static inline void pl011_parity_disable(void); + +struct pl011_uart_ops { + int (*initialise)(struct pl011_uart *); + + int (*tx_char)(char); + int (*rx_char)(char *); + + void (*set_baudrate)(unsigned int, unsigned int); + void (*set_irq_mask)(unsigned int); + void (*clr_irq_mask)(unsigned int); + + void (*irq_handler)(struct pl011_uart *); + void (*tx_irq_handler)(struct pl011_uart *, unsigned int); + void (*rx_irq_handler)(struct pl011_uart *, unsigned int); + void (*error_irq_handler)(struct pl011_uart *, unsigned int); +}; + +struct pl011_uart { + const unsigned int base; + struct pl011_uart_ops ops; + unsigned int frame_errors; + unsigned int parity_errors; + unsigned int break_errors; + unsigned int overrun_errors; + unsigned int rx_timeout_errors; +}; + + + +#define PL011_UARTEN (1 << 0) +static inline void pl011_uart_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +static inline void pl011_uart_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_UARTEN; + write(val, PL011_UARTCR); + + return; +} + +#define PL011_TXE (1 << 8) +static inline void pl011_tx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_TXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_tx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_TXE; + write(val, PL011_UARTCR); + return; +} + + +#define PL011_RXE (1 << 9) +static inline void pl011_rx_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val |= PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +static inline void pl011_rx_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTCR); + val &= ~PL011_RXE; + write(val, PL011_UARTCR); + return; +} + +#define PL011_TWO_STOPBITS_SELECT (1 << 3) +static inline void pl011_set_stopbits(int stopbits) +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + + if(stopbits == 2) { /* Set to two bits */ + val |= PL011_TWO_STOPBITS_SELECT; + } else { /* Default is 1 */ + val &= ~PL011_TWO_STOPBITS_SELECT; + } + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_ENABLE (1 << 1) +static inline void pl011_parity_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_parity_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_ENABLE; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_PARITY_EVEN (1 << 2) +static inline void pl011_set_parity_even() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_set_parity_odd() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_PARITY_EVEN; + write(val, PL011_UARTLCR_H); + return; +} + +#define PL011_ENABLE_FIFOS (1 << 4) +static inline void pl011_enable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val |= PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + +static inline void pl011_disable_fifos() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTLCR_H); + val &= ~PL011_ENABLE_FIFOS; + write(val, PL011_UARTLCR_H); + return; +} + + +#define PL011_WORD_WIDTH_SHIFT (5) +/* Sets the transfer word width for the data register. */ +static inline void pl011_set_word_width(int size) +{ + unsigned int val; + val = 0; + + if(size < 5 || size > 8) /* Default is 8 */ + size = 8; + + /* Clear size field */ + read(val, PL011_UARTLCR_H); + val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT); + write(val, PL011_UARTLCR_H); + + /* The formula is to write 5 less of size given: + * 11 = 8 bits + * 10 = 7 bits + * 01 = 6 bits + * 00 = 5 bits + */ + read(val, PL011_UARTLCR_H); + val |= (size - 5) << PL011_WORD_WIDTH_SHIFT; + write(val, PL011_UARTLCR_H); + + return; +} + +/* + * Defines at which level of fifo fullness an irq will be generated. + * @xfer: tx fifo = 0, rx fifo = 1 + * @level: Generate irq if: + * 0 rxfifo >= 1/8 full txfifo <= 1/8 full + * 1 rxfifo >= 1/4 full txfifo <= 1/4 full + * 2 rxfifo >= 1/2 full txfifo <= 1/2 full + * 3 rxfifo >= 3/4 full txfifo <= 3/4 full + * 4 rxfifo >= 7/8 full txfifo <= 7/8 full + * 5-7 reserved reserved + */ +static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level) +{ + if(xfer != 1 && xfer != 0) /* Invalid fifo */ + return; + + if(level > 4) /* Invalid level */ + return; + + write(level << (xfer * 3), PL011_UARTIFLS); + return; +} + +/* returns which irqs are masked */ +static inline unsigned int pl011_read_irqmask(void) +{ + unsigned int flags; + read(flags, PL011_UARTIMSC); + return flags; +} + +/* returns masked irq status */ +static inline unsigned int pl011_read_irqstat(void) +{ + unsigned int irqstatus; + read(irqstatus, PL011_UARTMIS); + return irqstatus; +} +/* Clears the given asserted irqs */ +static inline void pl011_irq_clear(unsigned int flags) +{ + if(flags > 0x3FF) { /* Invalid irq clearing bitvector */ + return; + } + /* Simply write the flags since it's a write-only register */ + write(flags, PL011_UARTICR); + return; +} + +#define PL011_TXDMAEN (1 << 1) +#define PL011_RXDMAEN (1 << 0) + +/* Enables dma transfers for uart. The dma controller + * must be initialised, set-up and enabled separately. + */ +static inline void pl011_tx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +/* Disables dma transfers for uart */ +static inline void pl011_tx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_TXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_enable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val |= PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + +static inline void pl011_rx_dma_disable() +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTDMACR); + val &= ~PL011_RXDMAEN; + write(val, PL011_UARTDMACR); + return; +} + + +#endif /* __PL011__UART__ */ + diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/setjmp.h b/containers/posix/libc2/include/sys-userspace/arch-arm/setjmp.h new file mode 100644 index 0000000..22a17cd --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/setjmp.h @@ -0,0 +1,83 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Alex Webster +*/ + +typedef int jmp_buf[10]; diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/stdint.h b/containers/posix/libc2/include/sys-userspace/arch-arm/stdint.h new file mode 100644 index 0000000..6078b0a --- /dev/null +++ b/containers/posix/libc2/include/sys-userspace/arch-arm/stdint.h @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define __PTR_SIZE 32 diff --git a/containers/posix/libc2/include/time.h b/containers/posix/libc2/include/time.h new file mode 100644 index 0000000..2856e23 --- /dev/null +++ b/containers/posix/libc2/include/time.h @@ -0,0 +1,130 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Author: Ben Leslie + Created: Fri Sep 24 2004 + Description: time.h as per ISOC99 +*/ + +#ifndef _TIME_H_ +#define _TIME_H_ + +#include /* For NULL, size_t */ + +#define CLOCKS_PER_SEC 1 /* Arbitrary, 1s resolution */ + +typedef long clock_t; +typedef long time_t; + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + + +/* 7.23.2 Time manipulation functions */ +clock_t clock(void); +double difftime(time_t time1, time_t time2); +time_t mktime(struct tm *timeptr); +time_t time(time_t *timer); + +/* 7.23.3 Time conversion functions */ +char *asctime(const struct tm *timeptr); +struct tm *gmtime(const time_t *timer); +struct tm *localtime(const time_t *timer); + +/* As per spec pg. 341 */ +static inline +char *ctime(const time_t *timer) +{ + return asctime(localtime(timer)); +} + +size_t strftime(char *s, size_t maxsize, const char *format, + const struct tm *timeptr); + +#endif /* _TIME_H_ */ diff --git a/containers/posix/libc/src/arch-arm/eabi.c b/containers/posix/libc2/src/arch-arm/eabi.c similarity index 99% rename from containers/posix/libc/src/arch-arm/eabi.c rename to containers/posix/libc2/src/arch-arm/eabi.c index 9bede4b..b44a913 100644 --- a/containers/posix/libc/src/arch-arm/eabi.c +++ b/containers/posix/libc2/src/arch-arm/eabi.c @@ -3,7 +3,6 @@ /* Dummies to keep Codesourcery 4.1.1 libgcc division exceptions silent. */ void raise(void) { - } void __aeabi_unwind_cpp_pr0(void) diff --git a/containers/posix/libc2/src/arch-arm/jmp.S b/containers/posix/libc2/src/arch-arm/jmp.S new file mode 100644 index 0000000..bb99255 --- /dev/null +++ b/containers/posix/libc2/src/arch-arm/jmp.S @@ -0,0 +1,105 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#define BEGIN_PROC(name) \ + .global name; \ + .align; \ +name: + +#define END_PROC(name) \ + ; + +#ifdef __thumb__ +#define ret bx +#else +#define ret mov pc, +#endif + +BEGIN_PROC(setjmp) + stmia r0, {r4-r11,r13,r14} + mov r0, #0 + ret lr +END_PROC(setjmp) + +BEGIN_PROC(longjmp) + ldmia r0, {r4-r11,r13,r14} + movs r0, r1 + moveq r0, #1 // don't return zero + ret lr +END_PROC(longjmp) diff --git a/containers/posix/libc2/src/asctime.c b/containers/posix/libc2/src/asctime.c new file mode 100644 index 0000000..0f15b2b --- /dev/null +++ b/containers/posix/libc2/src/asctime.c @@ -0,0 +1,107 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Authors: Ben Leslie + Created: Fri Sep 24 2004 + Note: Implementation taken verbatim from ISOC99 spec. page 341 +*/ +#include +#include + +/* Not required to be thread safe by posix */ +char * +asctime(const struct tm *timeptr) +{ + static const char wday_name[7][3] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static const char mon_name[12][3] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", + "Aug", "Sep", "Oct", "Nov", "Dec" + }; + + static char result[26]; /* NOT THREAD SAFE */ + + sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", + wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon], + timeptr->tm_mday, timeptr->tm_hour, + timeptr->tm_min, timeptr->tm_sec, + 1900 + timeptr->tm_year); + return result; +} diff --git a/containers/posix/libc2/src/assert.c b/containers/posix/libc2/src/assert.c new file mode 100644 index 0000000..99468f4 --- /dev/null +++ b/containers/posix/libc2/src/assert.c @@ -0,0 +1,96 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Authors: Ben Leslie +*/ + +#include /* For __assert */ +#include /* For fprintf() */ +#include /* For abort() */ + + +void +__assert(const char *expression, const char *file, + const char *function, int line) +{ + /* Formatting as per suggstion in C99 spec 7.2.1.1 */ + fprintf(stderr, "Assertion failed: %s, function %s, " + "file %s, line %d.\n", expression, function, file, line); + abort(); +} diff --git a/containers/posix/libc2/src/calloc.c b/containers/posix/libc2/src/calloc.c new file mode 100644 index 0000000..9ec252a --- /dev/null +++ b/containers/posix/libc2/src/calloc.c @@ -0,0 +1,95 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Author: Ben Leslie +*/ + +#include +#include + +void * +calloc(size_t nmemb, size_t size) +{ + void *ptr; + ptr = malloc(nmemb * size); + if (ptr) + memset(ptr, '\0', nmemb * size); + return ptr; +} diff --git a/containers/posix/libc2/src/clearerr.c b/containers/posix/libc2/src/clearerr.c new file mode 100644 index 0000000..69b5e03 --- /dev/null +++ b/containers/posix/libc2/src/clearerr.c @@ -0,0 +1,88 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +void +clearerr(FILE *stream) +{ + lock_stream(stream); + stream->error = 0; + stream->eof = 0; + unlock_stream(stream); +} diff --git a/containers/posix/libc2/src/clock.c b/containers/posix/libc2/src/clock.c new file mode 100644 index 0000000..acbb285 --- /dev/null +++ b/containers/posix/libc2/src/clock.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +clock_t +clock(void) +{ + return 0; /* Don't currently do time -- will probably need to be + system dependant */ +} diff --git a/containers/posix/libc2/src/ctype.c b/containers/posix/libc2/src/ctype.c new file mode 100644 index 0000000..e69de29 diff --git a/containers/posix/libc2/src/difftime.c b/containers/posix/libc2/src/difftime.c new file mode 100644 index 0000000..9b145a3 --- /dev/null +++ b/containers/posix/libc2/src/difftime.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +double +difftime(time_t time1, time_t time2) +{ + return (double) (time1 - time2); +} diff --git a/containers/posix/libc2/src/errno.c b/containers/posix/libc2/src/errno.c new file mode 100644 index 0000000..95790e1 --- /dev/null +++ b/containers/posix/libc2/src/errno.c @@ -0,0 +1,82 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifndef THREAD_SAFE +int errno; +#endif diff --git a/containers/posix/libc2/src/exit.c b/containers/posix/libc2/src/exit.c new file mode 100644 index 0000000..fd35710 --- /dev/null +++ b/containers/posix/libc2/src/exit.c @@ -0,0 +1,99 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie + Created: Wed Oct 6 2004 +*/ +#include + +void +exit(int status) +{ + /* Call registered atexit() functions */ + + /* Flush unbuffered data */ + + /* Close all streams */ + + /* Remove anything created by tmpfile() */ + + /* Call _Exit() */ + _Exit(status); +} + diff --git a/containers/posix/libc2/src/fclose.c b/containers/posix/libc2/src/fclose.c new file mode 100644 index 0000000..98264e8 --- /dev/null +++ b/containers/posix/libc2/src/fclose.c @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include + +int +fclose(FILE *stream) +{ + int r; + lock_stream(stream); + r = stream->close_fn(stream->handle); + /* fflush file */ + unlock_stream(stream); + return r; +} diff --git a/containers/posix/libc2/src/feof.c b/containers/posix/libc2/src/feof.c new file mode 100644 index 0000000..caddfb0 --- /dev/null +++ b/containers/posix/libc2/src/feof.c @@ -0,0 +1,89 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +int +feof(FILE *f) +{ + int res; + lock_stream(f); + res = f->eof; + unlock_stream(f); + return res; +} diff --git a/containers/posix/libc2/src/ferror.c b/containers/posix/libc2/src/ferror.c new file mode 100644 index 0000000..c94feec --- /dev/null +++ b/containers/posix/libc2/src/ferror.c @@ -0,0 +1,89 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +int +ferror(FILE *stream) +{ + int res; + lock_stream(stream); + res = stream->error; + unlock_stream(stream); + return res; +} diff --git a/containers/posix/libc2/src/fflush.c b/containers/posix/libc2/src/fflush.c new file mode 100644 index 0000000..9784b9b --- /dev/null +++ b/containers/posix/libc2/src/fflush.c @@ -0,0 +1,89 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +int +fflush(FILE *file) +{ + lock_stream(file); + /* FIXME: printf("WARNING: fflush not implemented\n"); */ + unlock_stream(file); + return 0; +} diff --git a/containers/posix/libc2/src/fgetc.c b/containers/posix/libc2/src/fgetc.c new file mode 100644 index 0000000..d6c2ddf --- /dev/null +++ b/containers/posix/libc2/src/fgetc.c @@ -0,0 +1,105 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +int +fgetc(FILE *stream) +{ + unsigned char ch; + + lock_stream(stream); + if (stream->unget_pos) { + ch = stream->unget_stack[--stream->unget_pos]; + unlock_stream(stream); + return (int) ch; + } + + /* This is where we should do input buffering */ + if (stream->read_fn(&ch, stream->current_pos, 1, stream->handle) == 1) { + /* Success */ + stream->current_pos++; + unlock_stream(stream); + return (int) ch; + } else { + stream->eof = 1; + unlock_stream(stream); + return EOF; + } +} diff --git a/containers/posix/libc2/src/fgets.c b/containers/posix/libc2/src/fgets.c new file mode 100644 index 0000000..7642040 --- /dev/null +++ b/containers/posix/libc2/src/fgets.c @@ -0,0 +1,108 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include + +char * +fgets(char *s, int n, FILE *stream) +{ + int i; + int c = EOF; + + lock_stream(stream); + for (i = 0; i < n-1; i++) { + c = fgetc(stream); + if (c == EOF) { + break; + } + s[i] = (char) c; + if (c == '\n') { + break; + } + } + unlock_stream(stream); + + s[i+1] = '\0'; + if (c == EOF && i == 0) { + return NULL; + } else { + return s; + } +} diff --git a/containers/posix/libc/src/format.c b/containers/posix/libc2/src/format.c similarity index 99% rename from containers/posix/libc/src/format.c rename to containers/posix/libc2/src/format.c index 5018606..a42b7e1 100644 --- a/containers/posix/libc/src/format.c +++ b/containers/posix/libc2/src/format.c @@ -80,11 +80,10 @@ Authors: Cristan Szmadja, Ben Leslie */ #include -#include "stdio.h" +#include #include #include #include "format.h" -#define fputc putc /* * lookup tables for umaxtostr */ diff --git a/containers/posix/libc/src/format.h b/containers/posix/libc2/src/format.h similarity index 100% rename from containers/posix/libc/src/format.h rename to containers/posix/libc2/src/format.h diff --git a/containers/posix/libc2/src/fprintf.c b/containers/posix/libc2/src/fprintf.c new file mode 100644 index 0000000..709c7f1 --- /dev/null +++ b/containers/posix/libc2/src/fprintf.c @@ -0,0 +1,98 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2005 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* +Author: Ben Leslie +*/ + +#include +#include "format.h" + +int +fprintf(FILE *stream, const char *format, ...) +{ + int ret; + va_list ap; + + va_start(ap, format); + ret = vfprintf(stream, format, ap); + va_end(ap); + return ret; +} + diff --git a/containers/posix/libc2/src/fputc.c b/containers/posix/libc2/src/fputc.c new file mode 100644 index 0000000..732a667 --- /dev/null +++ b/containers/posix/libc2/src/fputc.c @@ -0,0 +1,19 @@ +#include + +int +fputc(int c, FILE *stream) +{ + unsigned char ch = (unsigned char) c; + /* This is where we should do output buffering */ + + lock_stream(stream); + if (stream->write_fn(&ch, stream->current_pos, 1, stream->handle) == 1) { + /* Success */ + stream->current_pos++; + unlock_stream(stream); + return c; + } else { + unlock_stream(stream); + return EOF; + } +} diff --git a/containers/posix/libc2/src/fputs.c b/containers/posix/libc2/src/fputs.c new file mode 100644 index 0000000..b6d24cb --- /dev/null +++ b/containers/posix/libc2/src/fputs.c @@ -0,0 +1,95 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include + +int +fputs(const char *s, FILE *stream) +{ + int c, len = strlen(s); + /* This function does not need to lock the stream as fwrite will + * handle the locking. */ + c = fwrite(s, 1, len, stream); + if (c < len) { + return EOF; + } else { + return 1; + } +} diff --git a/containers/posix/libc2/src/fread.c b/containers/posix/libc2/src/fread.c new file mode 100644 index 0000000..f3b13dd --- /dev/null +++ b/containers/posix/libc2/src/fread.c @@ -0,0 +1,101 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +size_t +fread(void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + size_t elems, sz; + unsigned char *p = ptr; + + lock_stream(stream); + for(elems = 0; elems < nmemb; elems++) { + for(sz = 0; sz < size; sz++, p++) { + int ch; + if ((ch = fgetc(stream)) == EOF) { + goto out; + } + *p = (unsigned char) ch; + } + } +out: + unlock_stream(stream); + return elems; +} diff --git a/containers/posix/libc2/src/fscanf.c b/containers/posix/libc2/src/fscanf.c new file mode 100644 index 0000000..3d45a27 --- /dev/null +++ b/containers/posix/libc2/src/fscanf.c @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +int +fscanf(FILE *stream, const char *fmt, ...) +{ + return 0; +} + diff --git a/containers/posix/libc2/src/fseek.c b/containers/posix/libc2/src/fseek.c new file mode 100644 index 0000000..7a7f04d --- /dev/null +++ b/containers/posix/libc2/src/fseek.c @@ -0,0 +1,103 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include + +int +fseek(FILE *stream, long int offset, int whence) +{ + int res = 0; + lock_stream(stream); + switch(whence) { + case SEEK_SET: + stream->current_pos = offset; + break; + case SEEK_CUR: + stream->current_pos += offset; + break; + case SEEK_END: + stream->current_pos = stream->eof_fn(stream->handle) + offset; + break; + default: + res = -1; + } + unlock_stream(stream); + return res; +} diff --git a/containers/posix/libc2/src/ftell.c b/containers/posix/libc2/src/ftell.c new file mode 100644 index 0000000..017fa3b --- /dev/null +++ b/containers/posix/libc2/src/ftell.c @@ -0,0 +1,90 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +long int +ftell(FILE *stream) +{ + int res; + lock_stream(stream); + res = stream->current_pos; + unlock_stream(stream); + return res; +} diff --git a/containers/posix/libc2/src/fwrite.c b/containers/posix/libc2/src/fwrite.c new file mode 100644 index 0000000..0f2b35c --- /dev/null +++ b/containers/posix/libc2/src/fwrite.c @@ -0,0 +1,102 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* +Author: Ben Leslie +*/ + +#include + +size_t +fwrite(const void * ptr, size_t size, size_t nmemb, FILE * stream) +{ + size_t elems, sz; + const unsigned char *p = ptr; + + lock_stream(stream); + for(elems = 0; elems < nmemb; elems++) { + for(sz = 0; sz < size; sz++, p++) { + if (fputc(*p, stream) == EOF) { + goto out; + } + } + } +out: + unlock_stream(stream); + return elems; +} diff --git a/containers/posix/libc2/src/getchar.c b/containers/posix/libc2/src/getchar.c new file mode 100644 index 0000000..1760344 --- /dev/null +++ b/containers/posix/libc2/src/getchar.c @@ -0,0 +1,89 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* +Authors: Ben Leslie +*/ + +#include + +int +getchar(void) +{ + return fgetc(stdin); +} diff --git a/containers/posix/libc2/src/getenv.c b/containers/posix/libc2/src/getenv.c new file mode 100644 index 0000000..7a0c37e --- /dev/null +++ b/containers/posix/libc2/src/getenv.c @@ -0,0 +1,88 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include + +char * +getenv(const char *name) +{ + printf("WARNING: getenv not implemented\n"); + return NULL; +} diff --git a/containers/posix/libc2/src/gmtime.c b/containers/posix/libc2/src/gmtime.c new file mode 100644 index 0000000..43b1e22 --- /dev/null +++ b/containers/posix/libc2/src/gmtime.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +struct tm * +gmtime(const time_t *timer) +{ + return NULL; +} diff --git a/containers/posix/libc2/src/k_r_malloc.h b/containers/posix/libc2/src/k_r_malloc.h new file mode 100644 index 0000000..a291d05 --- /dev/null +++ b/containers/posix/libc2/src/k_r_malloc.h @@ -0,0 +1,20 @@ +#ifndef _LIBC_K_R_MALLOC_H_ +#define _LIBC_K_R_MALLOC_H_ + +#define NALLOC 0x10000 /* minimum #units to request */ + +typedef long long Align; /* for alignment to long long boundary */ + +union header { /* block header */ + struct { + union header *ptr; /* next block if on free list */ + unsigned size; /* size of this block */ + } s; + Align x; /* force alignment of blocks */ +}; + +typedef union header Header; + +Header *morecore(unsigned nu); +void __malloc_init(void*, void*); +#endif /* _LIBC_K_R_MALLOC_H_ */ diff --git a/containers/posix/libc2/src/locale.c b/containers/posix/libc2/src/locale.c new file mode 100644 index 0000000..7d48b64 --- /dev/null +++ b/containers/posix/libc2/src/locale.c @@ -0,0 +1,128 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include + +#define CHAR_MAX 0 +struct lconv current_locale = { + ".", //decimal_point + "", //thousands_sep + "", //grouping + "", //mon_deciaml_point + "", //mon_thouasands_sep + "", //mon_grouping + "", //positive_sign + "", //negative_sign + "", //currency_symbol + CHAR_MAX, //frac_digits + CHAR_MAX, //p_cs_precedes + CHAR_MAX, //n_cs_precedes + CHAR_MAX, //p_sep_by_space + CHAR_MAX, //n_sep_by_space + CHAR_MAX, //p_sign_posn + CHAR_MAX, //n_sign_posn + "", //int_curr_symbol + CHAR_MAX, //int_frac_digits + CHAR_MAX, //int_p_cs_precedes + CHAR_MAX, //int_n_cs_precedes + CHAR_MAX, //int_p_sep_by_space + CHAR_MAX, //int_n_sep_by_space + CHAR_MAX, //int_p_sign_posn + CHAR_MAX //int_n_sign_posn +}; + +char * +setlocale(int category, const char *locale) +{ + if (strcmp(locale, "C") == 0) { + return "C"; + } + if (strcmp(locale, "") == 0) { + return "C"; + } + + return NULL; +} + +struct lconv * +localeconv(void) +{ + return ¤t_locale; +} diff --git a/containers/posix/libc2/src/localtime.c b/containers/posix/libc2/src/localtime.c new file mode 100644 index 0000000..7e7dd78 --- /dev/null +++ b/containers/posix/libc2/src/localtime.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +struct tm * +localtime(const time_t *timer) +{ + return NULL; +} diff --git a/containers/posix/libc2/src/malloc.c b/containers/posix/libc2/src/malloc.c new file mode 100644 index 0000000..be3a654 --- /dev/null +++ b/containers/posix/libc2/src/malloc.c @@ -0,0 +1,206 @@ + +/* + * K&R Malloc + * + * System specifc code should implement `more_core' + */ +#include "k_r_malloc.h" +#include /* For NULL */ +#include +#include /* For memcpy */ + +#ifdef THREAD_SAFE +#include +extern struct mutex malloc_mutex; +struct mutex malloc_mutex; + +#define MALLOC_LOCK mutex_count_lock(&malloc_mutex) +#define MALLOC_UNLOCK mutex_count_unlock(&malloc_mutex) +#else +#define MALLOC_LOCK +#define MALLOC_UNLOCK +#endif + +static Header base; /* empty list to get started */ +Header *_kr_malloc_freep = NULL; /* start of free list */ +#define freep _kr_malloc_freep + +#ifdef CONFIG_MALLOC_INSTRUMENT +size_t __malloc_instrumented_allocated; +#endif + +#ifdef CONFIG_MALLOC_DEBUG_INTERNAL +#include +#include +int __malloc_check(void); +void __malloc_dump(void); +#endif + +/* + * malloc: general-purpose storage allocator + */ +void * +malloc(size_t nbytes) +{ + Header *p, *prevp; + unsigned nunits; + nunits = (nbytes + sizeof(Header) - 1) / sizeof(Header) + 1; + + MALLOC_LOCK; + if ((prevp = freep) == NULL) { /* no free list yet */ + base.s.ptr = freep = prevp = &base; + base.s.size = 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + if (p->s.size >= nunits) { /* big enough */ + if (p->s.size == nunits) /* exactly */ + prevp->s.ptr = p->s.ptr; + else { /* allocate tail end */ + p->s.size -= nunits; + p += p->s.size; + p->s.size = nunits; + } + freep = prevp; +#ifdef CONFIG_MALLOC_DEBUG + { + /* Write bit pattern over data */ + char *x = (char *) (p + 1); + int i; + for (i = 0; i < nbytes; i++) + x[i] = 0xd0; + } +#endif + +#ifdef CONFIG_MALLOC_INSTRUMENT + __malloc_instrumented_allocated += nunits; +#endif +#ifdef CONFIG_MALLOC_DEBUG_INTERNAL + if (__malloc_check() != 0) { + printf("malloc %d %p\n", nbytes, (void *) (p + 1)); + __malloc_dump(); + assert(__malloc_check() == 0); + } +#endif + MALLOC_UNLOCK; + return (void *) (p + 1); + } + if (p == freep) { /* wrapped around free list */ + if ((p = (Header *) morecore(nunits)) == NULL) { + MALLOC_UNLOCK; + return NULL; /* none left */ + } else { + + } + } + } + MALLOC_UNLOCK; +} + +/* + * free: put block ap in free list + */ +void +free(void *ap) +{ + Header *bp, *p; + + if (ap == NULL) + return; + + MALLOC_LOCK; + bp = (Header *) ap - 1; /* point to block header */ + for (p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) + if (p >= p->s.ptr && (bp > p || bp < p->s.ptr)) + break; /* freed block at start or end of arena */ + +#ifdef CONFIG_MALLOC_INSTRUMENT + __malloc_instrumented_allocated -= bp->s.size; +#endif + + if (bp + bp->s.size == p->s.ptr) { /* join to upper nbr */ + bp->s.size += p->s.ptr->s.size; + bp->s.ptr = p->s.ptr->s.ptr; + } else { + bp->s.ptr = p->s.ptr; + } + + if (p + p->s.size == bp) { /* join to lower nbr */ + p->s.size += bp->s.size; + p->s.ptr = bp->s.ptr; + } else { + p->s.ptr = bp; + } + + freep = p; + +#ifdef CONFIG_MALLOC_DEBUG_INTERNAL + if (__malloc_check() != 0) { + printf("free %p\n", ap); + __malloc_dump(); + assert(__malloc_check() == 0); + } +#endif + MALLOC_UNLOCK; +} + +#ifdef CONFIG_MALLOC_DEBUG_INTERNAL + +int +__malloc_check(void) +{ + Header *p, *prevp; + if ((prevp = freep) == NULL) { /* no free list yet */ + return 0; + } + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + if ((void*) p == NULL) { + return 1; + } + /* Free bits should be in order */ + if (p > p->s.ptr && p != &base) { + return 1; + } + if ((uintptr_t) p + (p->s.size * sizeof(Header)) > (uintptr_t) p->s.ptr && p != &base) { + return 1; + } + /* shouldn't have zero sized free bits */ + if (p->s.size == 0 && p != &base) { + return 1; + } + if (p == freep) { /* wrapped around free list */ + break; + } + } + return 0; +} + +void +__malloc_dump(void) +{ + Header *p, *prevp; + if ((prevp = freep) == NULL) { /* no free list yet */ + return; + } + printf("Malloc dump\n"); + for (p = prevp->s.ptr;; prevp = p, p = p->s.ptr) { + if (p > p->s.ptr && p != &base) { + printf("* "); + } + if (p->s.size == 0 && p != &base) { + printf("# "); + } + if ((uintptr_t) p + (p->s.size * sizeof(Header)) > (uintptr_t) p->s.ptr && p != &base) { + printf("$ "); + } + if (p == &base) { + printf(" p: \n"); + } else { + printf(" p: %p (%d) -> %p\n", p, p->s.size, p->s.ptr); + } + assert(p != NULL); + if (p == freep) { /* wrapped around free list */ + return; + } + } +} +#endif diff --git a/containers/posix/libc2/src/memchr.c b/containers/posix/libc2/src/memchr.c new file mode 100644 index 0000000..921114e --- /dev/null +++ b/containers/posix/libc2/src/memchr.c @@ -0,0 +1,103 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Authors: Ben Leslie + Created: Wed Aug 4 13:37:35 EST 2004 +*/ + +#include + +/* + * return pointer to first occurrence of c in s + */ +/* THREAD SAFE */ +void * +memchr(const void *s, int c, size_t n) +{ + const char *p = (const char *) s; + + while (n--) { + if (*p == c) { + return (void *) p; + } + p++; + } + + return NULL; +} diff --git a/containers/posix/libc2/src/memcmp.c b/containers/posix/libc2/src/memcmp.c new file mode 100644 index 0000000..f26db10 --- /dev/null +++ b/containers/posix/libc2/src/memcmp.c @@ -0,0 +1,98 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +/* THREAD SAFE */ +int +memcmp(const void *s1, const void *s2, size_t n) +{ + size_t i; + int diff; + + for (i = 0; i < n; i++) { + diff = + ((unsigned char *) s1)[i] - ((unsigned char *) s2)[i]; + if (diff != 0) + return diff; + } + return 0; +} diff --git a/containers/posix/libc2/src/memcpy.c b/containers/posix/libc2/src/memcpy.c new file mode 100644 index 0000000..b9c7075 --- /dev/null +++ b/containers/posix/libc2/src/memcpy.c @@ -0,0 +1,115 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Carl van Schaik +*/ +#include +#include + +/* + * copy n bytes from s to d; the regions must not overlap + */ +/* THREAD SAFE */ +void * +memcpy(void *d, const void *s, size_t n) +{ + size_t i; + uintptr_t align = sizeof(uintptr_t)-1; + + if (((uintptr_t)d & align) || ((uintptr_t)s & align) || (n & align)) + { + char *bs = (char *)s; + char *bd = (char *)d; + + /* XXX - optimize this */ + for (i = 0; i < n; i++) + *bd++ = *bs++; + } + else + { /* memcpy - word aligned */ + uintptr_t *ws = (uintptr_t*)s; + uintptr_t *wd = (uintptr_t*)d; + + n /= sizeof(uintptr_t); + + for (i = 0; i < n; i++) + *wd++ = *ws++; + } + return d; +} diff --git a/containers/posix/libc2/src/memmove.c b/containers/posix/libc2/src/memmove.c new file mode 100644 index 0000000..ea3002b --- /dev/null +++ b/containers/posix/libc2/src/memmove.c @@ -0,0 +1,104 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +/* + * copy n bytes from s to d, even if the regions overlap + */ +/* THREAD SAFE */ +void * +memmove(void *d, const void *s, size_t n) +{ + size_t i; + + if (s >= d || (void*) ((char *) s + n) <= d) { + return memcpy(d, s, n); /* memcpy is ascending */ + } else { + /* + * XXX copy 1 byte at a time + */ + for (i = n ; i > 0; i--) { + ((char *) d)[i-1] = ((const char *) s)[i-1]; + } + return d; + } +} diff --git a/containers/posix/libc2/src/memset.c b/containers/posix/libc2/src/memset.c new file mode 100644 index 0000000..66bb045 --- /dev/null +++ b/containers/posix/libc2/src/memset.c @@ -0,0 +1,138 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Carl van Schaik +*/ +#include +#include +#include + +/* + * Fill memory at s with (n) * byte value 'c' + */ +void * +memset(void *s, int c, size_t n) +{ + uintptr_t num, align, pattern, *p, x; + unsigned char *mem = s; + + x = (unsigned char)c; + align = sizeof(uintptr_t)-1; + + if ((uintptr_t)s & align) + { + num = n > align ? (sizeof(uintptr_t) - ((uintptr_t)s & align)) : n; + n -= num; + while (num--) + *mem++ = x; + } + + num = (uintptr_t)n / sizeof(uintptr_t); + + p = (uintptr_t*)mem; + +#if UINTPTR_MAX == UINT32_MAX + pattern = x | x << 8 | x << 16 | x << 24; +#elif UINTPTR_MAX == UINT64_MAX + pattern = x | x << 8 | x << 16 | x << 24 | + x << 32 | x << 40 | x << 48 | x << 56; +#else +#error UINTPTR_MAX not valid +#endif + while (num) { + /* simple hand unrolled loop */ + if ((num & 3)==0) { + num -= 4; + *p++ = pattern; + *p++ = pattern; + *p++ = pattern; + *p++ = pattern; + } else { + num--; + *p++ = pattern; + } + } + mem = (unsigned char*)p; + + num = n & align; + while (num--) + *mem++ = x; + + return s; +} diff --git a/containers/posix/libc2/src/mktime.c b/containers/posix/libc2/src/mktime.c new file mode 100644 index 0000000..83fb7dd --- /dev/null +++ b/containers/posix/libc2/src/mktime.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +time_t +mktime(struct tm *timeptr) +{ + /* Not currently implemented */ + return (time_t)(-1); +} diff --git a/containers/posix/libc2/src/perror.c b/containers/posix/libc2/src/perror.c new file mode 100644 index 0000000..16c8ba3 --- /dev/null +++ b/containers/posix/libc2/src/perror.c @@ -0,0 +1,10 @@ +/* + * A temporary mock-up perror implementation just + * for quick testing purposes. When a proper C library is + * ported, its implementation should be used. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include + + diff --git a/containers/posix/libc2/src/printf.c b/containers/posix/libc2/src/printf.c new file mode 100644 index 0000000..4f70cba --- /dev/null +++ b/containers/posix/libc2/src/printf.c @@ -0,0 +1,100 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* +Author: Ben Leslie +*/ + +#include +#include "format.h" + +/* All of these functions do not lock the I/O stream. They all end up calling + * format which handles the locking. */ + +int +printf(const char *format, ...) +{ + int ret; + va_list ap; + + va_start(ap, format); + ret = vfprintf(stdout, format, ap); + va_end(ap); + return ret; +} diff --git a/containers/posix/libc2/src/putchar.c b/containers/posix/libc2/src/putchar.c new file mode 100644 index 0000000..25572e0 --- /dev/null +++ b/containers/posix/libc2/src/putchar.c @@ -0,0 +1,89 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* +Authors: Ben Leslie +*/ + +#include + +int +putchar(int c) +{ + return fputc(c, stdout); +} diff --git a/containers/posix/libc2/src/puts.c b/containers/posix/libc2/src/puts.c new file mode 100644 index 0000000..4c8f317 --- /dev/null +++ b/containers/posix/libc2/src/puts.c @@ -0,0 +1,88 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +int +puts(const char *s) +{ + while(*s != '\0') + fputc(*s++, stdout); + fputc('\n', stdout); + return 0; +} diff --git a/containers/posix/libc2/src/qsort.c b/containers/posix/libc2/src/qsort.c new file mode 100644 index 0000000..47a5a62 --- /dev/null +++ b/containers/posix/libc2/src/qsort.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +static +void swap(void *base, size_t i, size_t j, size_t size) +{ + void *tmp = malloc(size); + + assert(tmp); + + memcpy(tmp, (char*) base + i * size, size); + memmove((char*) base + i * size, (char*) base + j * size, size); + memcpy((char*) base + j * size, tmp, size); + free(tmp); +} + +/* qsort: sort v[left]...v[right] into increasing order */ +void +qsort(void *base, size_t nmemb, size_t size, + int(*compar)(const void *, const void *)) +{ + int i, last; + + if (nmemb <= 1) + return; + + swap(base, 0, nmemb / 2, size); + + last = 0; + for (i = 1; i < nmemb; i++) + if (compar((char*) base + (i * size), base) < 0) + swap(base, i, ++last, size); + + swap(base, 0, last, size); + + qsort(base, last, size, compar); + qsort((char*) base + (last + 1) * size, nmemb - last - 1, size, compar); +} diff --git a/containers/posix/libc2/src/rand.c b/containers/posix/libc2/src/rand.c new file mode 100644 index 0000000..25688b7 --- /dev/null +++ b/containers/posix/libc2/src/rand.c @@ -0,0 +1,95 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie + Description: Implementation of Pseudo-random numbers for libc (7.20.2) + Note: These are *NOT* good ranndom numbers. The algorithm used is + straight from the ISOC99 specification. +*/ +#include + +unsigned long int _rand_next = 1; + +/* not required to be thread safe by posix */ +int +rand(void) +{ + _rand_next = _rand_next * 1103515245 + 12345; + return (unsigned int) (_rand_next/65536) % 32768; +} diff --git a/containers/posix/libc2/src/realloc.c b/containers/posix/libc2/src/realloc.c new file mode 100644 index 0000000..22c07f4 --- /dev/null +++ b/containers/posix/libc2/src/realloc.c @@ -0,0 +1,33 @@ +/* + * K&R Malloc + * + * System specifc code should implement `more_core' + */ + +#include "k_r_malloc.h" +#include +#include + +void * +realloc(void *ptr, size_t size) +{ + Header *bp; + void *new_ptr; + size_t old_size; + + if (ptr == NULL) + return malloc(size); + bp = (Header *) ptr - 1; /* point to block header */ + old_size = sizeof(Header) * bp->s.size; + new_ptr = malloc(size); + if (new_ptr == NULL) { + return NULL; + } + if (old_size <= size) { + memcpy(new_ptr, ptr, old_size); + } else { + memcpy(new_ptr, ptr, size); + } + free(ptr); + return new_ptr; +} diff --git a/containers/posix/libc2/src/remove.c b/containers/posix/libc2/src/remove.c new file mode 100644 index 0000000..c4a7b22 --- /dev/null +++ b/containers/posix/libc2/src/remove.c @@ -0,0 +1,85 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +int +remove(const char *filename) +{ + return 1; /* Always return failure */ +} diff --git a/containers/posix/libc2/src/rename.c b/containers/posix/libc2/src/rename.c new file mode 100644 index 0000000..d1fd0e7 --- /dev/null +++ b/containers/posix/libc2/src/rename.c @@ -0,0 +1,85 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +int +rename(const char *old, const char *new) +{ + return 1; /* Always return failure */ +} diff --git a/containers/posix/libc2/src/rewind.c b/containers/posix/libc2/src/rewind.c new file mode 100644 index 0000000..151159c --- /dev/null +++ b/containers/posix/libc2/src/rewind.c @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +void +rewind(FILE *stream) +{ + /* This function is not locked as fseek will handle the locking. */ + (void) fseek(stream, 0L, SEEK_SET); +} diff --git a/containers/posix/libc2/src/snprintf.c b/containers/posix/libc2/src/snprintf.c new file mode 100644 index 0000000..849fe4d --- /dev/null +++ b/containers/posix/libc2/src/snprintf.c @@ -0,0 +1,20 @@ +/* +Author: Ben Leslie +*/ + +#include +#include "format.h" + +#include + +int +snprintf(char *s, size_t size, const char *format, ...) +{ + int ret; + va_list ap; + + va_start(ap, format); + ret = vsnprintf(s, size, format, ap); + va_end(ap); + return ret; +} diff --git a/containers/posix/libc/src/sprintf.c b/containers/posix/libc2/src/sprintf.c similarity index 99% rename from containers/posix/libc/src/sprintf.c rename to containers/posix/libc2/src/sprintf.c index e26c5d8..210e2fb 100644 --- a/containers/posix/libc/src/sprintf.c +++ b/containers/posix/libc2/src/sprintf.c @@ -79,20 +79,12 @@ /* Author: Ben Leslie */ -#ifndef NULL -#define NULL 0 -#endif #include #include "format.h" #include -int -vsprintf(char *s, const char *format, va_list arg) -{ - return format_string(s, NULL, 0, -1, format, arg); -} int sprintf(char *s, const char *format, ...) { @@ -105,3 +97,8 @@ sprintf(char *s, const char *format, ...) return ret; } +int +vsprintf(char *s, const char *format, va_list arg) +{ + return format_string(s, NULL, 0, -1, format, arg); +} diff --git a/containers/posix/libc2/src/srand.c b/containers/posix/libc2/src/srand.c new file mode 100644 index 0000000..16a9cbb --- /dev/null +++ b/containers/posix/libc2/src/srand.c @@ -0,0 +1,90 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2005 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie +*/ +#include + +extern unsigned long int _rand_next; + +void +srand(unsigned int seed) +{ + _rand_next = seed; +} diff --git a/containers/posix/libc2/src/strcat.c b/containers/posix/libc2/src/strcat.c new file mode 100644 index 0000000..94c43d9 --- /dev/null +++ b/containers/posix/libc2/src/strcat.c @@ -0,0 +1,89 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Authors: Cristan Szmadja +*/ +#include + +char * +strcat(char *s, const char *t) +{ + strcpy(s + strlen(s), t); + return s; +} diff --git a/containers/posix/libc2/src/strchr.c b/containers/posix/libc2/src/strchr.c new file mode 100644 index 0000000..75fbad3 --- /dev/null +++ b/containers/posix/libc2/src/strchr.c @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ + +#include + +char * +strchr(const char *s, int c) +{ + for (; *s != '\0'; s++) + if (*s == c) + return (char *) s; + if (c == '\0') + return (char *) s; + return NULL; +} diff --git a/containers/posix/libc2/src/strcmp.c b/containers/posix/libc2/src/strcmp.c new file mode 100644 index 0000000..72af345 --- /dev/null +++ b/containers/posix/libc2/src/strcmp.c @@ -0,0 +1,99 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +/* + * compare s1 and s2 + */ +int +strcmp(const char *s1, const char *s2) +{ + size_t i; + int diff; + + for (i = 0;; i++) { + diff = + ((unsigned char *) s1)[i] - ((unsigned char *) s2)[i]; + if (diff != 0 || s1[i] == '\0') + return diff; + } +} diff --git a/containers/posix/libc2/src/strcoll.c b/containers/posix/libc2/src/strcoll.c new file mode 100644 index 0000000..c41d615 --- /dev/null +++ b/containers/posix/libc2/src/strcoll.c @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include +#include + +int +strcoll(const char *s1, const char *s2) +{ + assert(!"strcoll"); + return 0; +} diff --git a/containers/posix/libc2/src/strcpy.c b/containers/posix/libc2/src/strcpy.c new file mode 100644 index 0000000..0c1e5f2 --- /dev/null +++ b/containers/posix/libc2/src/strcpy.c @@ -0,0 +1,91 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +char * +strcpy(char *d, const char *s) +{ + size_t i; + + for (i = 0; (d[i] = s[i]) != '\0'; i++); + return d; +} diff --git a/containers/posix/libc2/src/strcspn.c b/containers/posix/libc2/src/strcspn.c new file mode 100644 index 0000000..ce90eb1 --- /dev/null +++ b/containers/posix/libc2/src/strcspn.c @@ -0,0 +1,93 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +size_t +strcspn(const char *s, const char *charset) +{ + size_t i; + size_t len = strlen(s); + + for (i = 0; strchr(charset, s[i]) == NULL && i < len; i++); + + return i; +} diff --git a/containers/posix/libc2/src/strdup.c b/containers/posix/libc2/src/strdup.c new file mode 100644 index 0000000..d2d4fda --- /dev/null +++ b/containers/posix/libc2/src/strdup.c @@ -0,0 +1,15 @@ +#define _USE_XOPEN +#include +#include + +char * +strdup(const char *s) +{ + int len = strlen(s); + char *d; + d = malloc(len); + if (d == NULL) + return NULL; + strcpy(d, s); + return d; +} diff --git a/containers/posix/libc2/src/strerror.c b/containers/posix/libc2/src/strerror.c new file mode 100644 index 0000000..31b450a --- /dev/null +++ b/containers/posix/libc2/src/strerror.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +char * +strerror(int errnum) +{ + return "No Error"; +} diff --git a/containers/posix/libc2/src/strftime.c b/containers/posix/libc2/src/strftime.c new file mode 100644 index 0000000..429f3b5 --- /dev/null +++ b/containers/posix/libc2/src/strftime.c @@ -0,0 +1,86 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +size_t strftime(char *s, size_t maxsize, const char *format, + const struct tm *timeptr) +{ + return 0; +} diff --git a/containers/posix/libc2/src/strlen.c b/containers/posix/libc2/src/strlen.c new file mode 100644 index 0000000..6043b9b --- /dev/null +++ b/containers/posix/libc2/src/strlen.c @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + + +size_t +strlen(const char *s) +{ + const char *p; + + for (p = s; *p != '\0'; p++); + return p - s; +} diff --git a/containers/posix/libc2/src/strncat.c b/containers/posix/libc2/src/strncat.c new file mode 100644 index 0000000..4a6cfa5 --- /dev/null +++ b/containers/posix/libc2/src/strncat.c @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Authors: Cristan Szmadja, Ben Leslie +*/ + +#include + +char * +strncat(char *d, const char *s, size_t n) +{ + if (strlen(s) < n) { + n = strlen(s); + } + strncpy(d + strlen(d), s, n); + *(d + strlen(d) + n + 1) = '\0'; + return d; +} diff --git a/containers/posix/libc2/src/strncmp.c b/containers/posix/libc2/src/strncmp.c new file mode 100644 index 0000000..3adb3c7 --- /dev/null +++ b/containers/posix/libc2/src/strncmp.c @@ -0,0 +1,100 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +/* + * compare s1 and s2 in the first n bytes + */ +int +strncmp(const char *s1, const char *s2, size_t n) +{ + size_t i; + int diff; + + for (i = 0; i < n; i++) { + diff = + ((unsigned char *) s1)[i] - ((unsigned char *) s2)[i]; + if (diff != 0 || s1[i] == '\0') + return diff; + } + return 0; +} diff --git a/containers/posix/libc2/src/strncpy.c b/containers/posix/libc2/src/strncpy.c new file mode 100644 index 0000000..8a14f40 --- /dev/null +++ b/containers/posix/libc2/src/strncpy.c @@ -0,0 +1,102 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +/* + * copy n bytes from s to d; pads with '\0' and may not '\0'-terminate + */ +char * +strncpy(char *d, const char *s, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + if ((d[i] = s[i]) == '\0') { + /* pad with NUL */ + for (i++; i < n; i++) { + d[i] = '\0'; + } + } + } + + return d; +} diff --git a/containers/posix/libc2/src/strpbrk.c b/containers/posix/libc2/src/strpbrk.c new file mode 100644 index 0000000..decef9e --- /dev/null +++ b/containers/posix/libc2/src/strpbrk.c @@ -0,0 +1,95 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Author: Cristan Szmadja +*/ +#include + +/* + * search for first occurrence of any character in charset in s + */ +char * +strpbrk(const char *s, const char *charset) +{ + for (; *s != '\0'; s++) + if (strchr(charset, *s) != NULL) + return (char *) s; + return NULL; +} diff --git a/containers/posix/libc2/src/strrchr.c b/containers/posix/libc2/src/strrchr.c new file mode 100644 index 0000000..b410170 --- /dev/null +++ b/containers/posix/libc2/src/strrchr.c @@ -0,0 +1,104 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Authors: Carl van Schaik, National ICT Australia +*/ + +#include + +/* + * search for last occurrence of c in s + */ +char * +strrchr(const char *s, int c) +{ + char *r = NULL; + + if( c != '\0') { + while (*s != '\0') { + if (*s++ == c) + r = (char *)s - 1; + } + } else { + r = (char *)s + strlen(s); + } + + return r; +} diff --git a/containers/posix/libc2/src/strspn.c b/containers/posix/libc2/src/strspn.c new file mode 100644 index 0000000..4a7f91d --- /dev/null +++ b/containers/posix/libc2/src/strspn.c @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* + Author: Cristan Szmadja, Ben Leslie +*/ +#include + +size_t +strspn(const char *s, const char *charset) +{ + size_t i; + + for (i = 0; strchr(charset, s[i]) != NULL && s[i] != '\0'; i++); + return i; +} diff --git a/containers/posix/libc2/src/strstr.c b/containers/posix/libc2/src/strstr.c new file mode 100644 index 0000000..2919fca --- /dev/null +++ b/containers/posix/libc2/src/strstr.c @@ -0,0 +1,97 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmajda +*/ +#include +#include +/* + * search for first occurrence of substring in s + */ +char * +strstr(const char *s, const char *substring) +{ + int n = strlen(substring); + + for (; *s != '\0'; s++) + if (strncmp(s, substring, n) == 0) + return (char *) s; + + return NULL; +} diff --git a/containers/posix/libc2/src/strtod.c b/containers/posix/libc2/src/strtod.c new file mode 100644 index 0000000..63da782 --- /dev/null +++ b/containers/posix/libc2/src/strtod.c @@ -0,0 +1,88 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include +#include + +double +strtod(const char * nptr, + char ** endptr) +{ + assert(!"strtod called\n"); + return 0.0; +} diff --git a/containers/posix/libc2/src/strtok.c b/containers/posix/libc2/src/strtok.c new file mode 100644 index 0000000..fecdb35 --- /dev/null +++ b/containers/posix/libc2/src/strtok.c @@ -0,0 +1,101 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 University of New South Wales + * + * All rights reserved. + * + * Developed by: Operating Systems and Distributed Systems Group (DiSy) + * University of New South Wales + * http://www.disy.cse.unsw.edu.au + * + * Permission is granted by University of New South Wales, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of University of New South Wales, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on University of New South + * Wales or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of University of New South Wales or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Cristan Szmadja +*/ +#include + +/* + * tokenize a string + */ +char * +strtok(char *s, const char *delim) +{ + static char *tok; + + if (s == NULL) + s = tok; /* recommence just after last token */ + s += strspn(s, delim); /* skip leading delimeters */ + if (*s == '\0') + return NULL; + tok = s + strcspn(s, delim); /* remember end of token string */ + if (*tok != '\0') + *(tok)++ = '\0'; /* terminate token string */ + return s; +} diff --git a/containers/posix/libc2/src/strtol.c b/containers/posix/libc2/src/strtol.c new file mode 100644 index 0000000..bc5630a --- /dev/null +++ b/containers/posix/libc2/src/strtol.c @@ -0,0 +1,218 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie + Created: Fri Oct 8 2004 +*/ + +#include +#include +#include +#include +#include + +/** + * Work out the numeric value of a char, assuming up to base 36 + * + * @param ch The character to decode + * + * \return Numeric value of character, or 37 on failure + */ +static inline unsigned short +char_value(char ch) +{ + if (ch >= '0' && ch <= '9') { + return ch - '0'; + } + if (ch >= 'a' && ch <= 'z') { + return ch - 'a' + 10; + } + if (ch >= 'A' && ch <= 'Z') { + return ch - 'A' + 10; + } + + return 37; +} + + +long int +strtol(const char *nptr, char **endptr, int base) +{ + /* + Decompose input info thread parts: + - inital list of whitespace (as per isspace) + - subject sequence + - final string one or more unrecognized + */ + const char *ptr = nptr; + bool negative = false; + unsigned int value; + long int return_value = 0; + /* Remove spaces */ + while(*ptr != '\0') { + if (! isspace(*ptr)) { + break; + } + ptr++; + } + + if (*ptr == '\0') + goto fail; + + /* check [+|-] */ + if (*ptr == '+') { + ptr++; + } else if (*ptr == '-') { + negative = true; + ptr++; + } + + if (*ptr == '\0') + goto fail; + + if (base == 16) { + /* _May_ have 0x prefix */ + if (*ptr == '0') { + ptr++; + if (*ptr == 'x' || *ptr == 'X') { + ptr++; + } + } + } + + /* [0(x|X)+] */ + if (base == 0) { + /* Could be hex or octal or decimal */ + if (*ptr != '0') { + base = 10; + } else { + ptr++; + if (ptr == '\0') + goto fail; + if (*ptr == 'x' || *ptr == 'X') { + base = 16; + ptr++; + } else { + base = 8; + } + } + } + + if (*ptr == '\0') + goto fail; + + /* Ok, here we have a base, and we might have a valid number */ + value = char_value(*ptr); + if (value >= base) { + goto fail; + } else { + return_value = value; + ptr++; + } + + while (*ptr != '\0' && (value = char_value(*ptr)) < base) { + return_value = return_value * base + value; + ptr++; + } + + if (endptr != NULL) + *endptr = (char*) ptr; + + if (negative) { + return_value *= -1; + } + + return return_value; + + /* + if base is 0, then we work it out based on a couple + of things + */ + /* + [+|-][0(x|X)+][0-9A-Za-z] not LL * + */ + + /* endptr == final string */ + + fail: + if (endptr != NULL) + *endptr = (char*) nptr; + return 0; + +} diff --git a/containers/posix/libc2/src/strtoul.c b/containers/posix/libc2/src/strtoul.c new file mode 100644 index 0000000..6c78fc2 --- /dev/null +++ b/containers/posix/libc2/src/strtoul.c @@ -0,0 +1,218 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +/* + Author: Ben Leslie + Created: Fri Oct 8 2004 +*/ + +#include +#include +#include +#include +#include + +/** + * Work out the numeric value of a char, assuming up to base 36 + * + * @param ch The character to decode + * + * \return Numeric value of character, or 37 on failure + */ +static inline unsigned short +char_value(char ch) +{ + if (ch >= '0' && ch <= '9') { + return ch - '0'; + } + if (ch >= 'a' && ch <= 'z') { + return ch - 'a' + 10; + } + if (ch >= 'A' && ch <= 'Z') { + return ch - 'A' + 10; + } + + return 37; +} + + +unsigned long int +strtoul(const char *nptr, char **endptr, int base) +{ + /* + Decompose input info thread parts: + - inital list of whitespace (as per isspace) + - subject sequence + - final string one or more unrecognized + */ + const char *ptr = nptr; + bool negative = false; + unsigned int value; + long int return_value = 0; + /* Remove spaces */ + while(*ptr != '\0') { + if (! isspace(*ptr)) { + break; + } + ptr++; + } + + if (*ptr == '\0') + goto fail; + + /* check [+|-] */ + if (*ptr == '+') { + ptr++; + } else if (*ptr == '-') { + negative = true; + ptr++; + } + + if (*ptr == '\0') + goto fail; + + if (base == 16) { + /* _May_ have 0x prefix */ + if (*ptr == '0') { + ptr++; + if (*ptr == 'x' || *ptr == 'X') { + ptr++; + } + } + } + + /* [0(x|X)+] */ + if (base == 0) { + /* Could be hex or octal or decimal */ + if (*ptr != '0') { + base = 10; + } else { + ptr++; + if (ptr == '\0') + goto fail; + if (*ptr == 'x' || *ptr == 'X') { + base = 16; + ptr++; + } else { + base = 8; + } + } + } + + if (*ptr == '\0') + goto fail; + + /* Ok, here we have a base, and we might have a valid number */ + value = char_value(*ptr); + if (value >= base) { + goto fail; + } else { + return_value = value; + ptr++; + } + + while (*ptr != '\0' && (value = char_value(*ptr)) < base) { + return_value = return_value * base + value; + ptr++; + } + + if (endptr != NULL) + *endptr = (char*) ptr; + + if (negative) { + return_value *= -1; + } + + return return_value; + + /* + if base is 0, then we work it out based on a couple + of things + */ + /* + [+|-][0(x|X)+][0-9A-Za-z] not LL * + */ + + /* endptr == final string */ + + fail: + if (endptr != NULL) + *endptr = (char*) nptr; + return 0; + +} diff --git a/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c b/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c new file mode 100644 index 0000000..b732a58 --- /dev/null +++ b/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c @@ -0,0 +1,50 @@ +#include + +struct pl011_uart uart; + +void platform_init(void); + +void platform_init(void) +{ + pl011_initialise(&uart); +} + +/* Initialises the uart class data structures, and the device. + * Terminal-like operation is assumed for default settings. + */ +int pl011_initialise(struct pl011_uart * uart) +{ + + uart->frame_errors = 0; + uart->parity_errors = 0; + uart->break_errors = 0; + uart->overrun_errors = 0; + + /* Initialise data register for 8 bit data read/writes */ + pl011_set_word_width(8); + + /* Fifos are disabled because by default it is assumed the port + * will be used as a user terminal, and in that case the typed + * characters will only show up when fifos are flushed, rather than + * when each character is typed. We avoid this by not using fifos. + */ + pl011_disable_fifos(); + + /* Set default baud rate of 38400 */ + pl011_set_baudrate(38400, 24000000); + + /* Set default settings of 1 stop bit, no parity, no hw flow ctrl */ + pl011_set_stopbits(1); + pl011_parity_disable(); + + /* Disable all irqs */ + pl011_set_irq_mask(0x3FF); + + /* Enable rx, tx, and uart chip */ + pl011_tx_enable(); + pl011_rx_enable(); + pl011_uart_enable(); + + return 0; +} + diff --git a/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c b/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c new file mode 100644 index 0000000..20017af --- /dev/null +++ b/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c @@ -0,0 +1,290 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#define MACHINE_PB926 + +#include +#include +#include + +//#define iPAQ /* FIXME: this is ugly */ +//#undef XSCALE +//#define XSCALE +// #undef iPAQ +// #define XSCALE + +extern int __fputc(int c, FILE *stream); +/* Put character for elf-loader */ +int +__fputc(int c, FILE *stream) +{ + +/* ---------------------------------- iPAQ & PLEB1 (SA-1100)--------------------------- */ +#ifdef MACHINE_IPAQ_H3800 //iPAQ // SA-1100 + volatile char *base = (char *)0x80050000; // base serial interface address + /* volatile int *base2 = (int *)0x80030000; // the other serial Arm serial i/f */ + +/* +UTSR1 32 @ 0x20: + tby <0> # Transmitter busy + rne <1> # Refeive FIFO not empty + tnf <2> # Transmitter not full + pre <3> # Parity error + fre <4> # Framing error + ror <5> # Receive FIFO overrun +*/ + +#define UTDR 0x14 // data register +#define UTSR1 0x20 // status register 1 offset +#define UTSR1_TNF (1 << 2) // tx FIFO not full (status bit) + + while ( ! ( * ( (volatile long *) (base + UTSR1)) & UTSR1_TNF )) + ; // busy wait while TX FIFO is full + *(volatile unsigned char *) (base + UTDR) = c; + // *base2 = c; +#endif + +/* ---------------------------------- PLEB2 (XSCALE PXA-255) --------------------------- */ +#ifdef MACHINE_PLEB2 //XSCALE /* PXA 255 on PLEB2 */ + +/* Console port -- taken from kernel/include/platform/pleb2/console.h */ +#define CONSOLE_OFFSET 0x100000 + +/* IO Base -- taken from kernel/include/arch/arm/xscale/cpu.h */ +#define XSCALE_PXA255_IO_BASE 0x40000000 + +#define DATAR 0x00000000 +#define STATUSR 0x00000014 + +/* TX empty bit -- uboot/include/asm/arch/hardware.h */ +#define LSR_TEMT (1 << 6) /* Transmitter Empty */ + +volatile char *base = (char *) (XSCALE_PXA255_IO_BASE + CONSOLE_OFFSET); + + /* wait for room in the tx FIFO on FFUART */ + while ( ! ( * ( (volatile long *) (base + STATUSR)) & LSR_TEMT )) + ; // busy wait while TX FIFO is full + *(volatile unsigned char *) (base + DATAR) = c; + +#endif /* XSCALE */ +#ifdef MACHINE_PB926 + { + int res; + do { + res = pl011_tx_char(c); + } while( res < 0); + } +#endif /* MACHINE_PB926 */ + return(0); +} + +/* --------------------------------- PB926 UART Driver -------------------------------- */ +#ifdef MACHINE_PB926 + +extern struct pl011_uart uart; + +/* UART-specific internal error codes */ +#define PL011_ERROR 1 +#define PL011_EAGAIN 2 + +/* Error status bits in receive status register */ +#define PL011_FE (1 << 0) +#define PL011_PE (1 << 1) +#define PL011_BE (1 << 2) +#define PL011_OE (1 << 3) + +/* Status bits in flag register */ +#define PL011_TXFE (1 << 7) +#define PL011_RXFF (1 << 6) +#define PL011_TXFF (1 << 5) +#define PL011_RXFE (1 << 4) +#define PL011_BUSY (1 << 3) +#define PL011_DCD (1 << 2) +#define PL011_DSR (1 << 1) +#define PL011_CTS (1 << 0) + +int pl011_tx_char(char c) +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTFR); + if(val & PL011_TXFF) { /* TX FIFO Full */ + return -PL011_EAGAIN; + } + write(c, PL011_UARTDR); + return 0; +} + +int pl011_rx_char(char * c) +{ + unsigned int data; + unsigned int val; + val = 0; + + read(val, PL011_UARTFR); + if(val & PL011_RXFE) { /* RX FIFO Empty */ + return -PL011_EAGAIN; + } + + read(data, PL011_UARTDR); + *c = (char) data; + + if((data >> 8) & 0xF) { /* There were errors */ + return -1; /* Signal error in xfer */ + } + return 0; /* No error return */ +} + + +/* + * Sets the baud rate in kbps. It is recommended to use + * standard rates such as: 1200, 2400, 3600, 4800, 7200, + * 9600, 14400, 19200, 28800, 38400, 57600 76800, 115200. + */ +void pl011_set_baudrate(unsigned int baud, unsigned int clkrate) +{ + const unsigned int uartclk = 24000000; /* 24Mhz clock fixed on pb926 */ + unsigned int val; + unsigned int ipart, fpart; + unsigned int remainder; + + remainder = 0; + ipart = 0; + fpart = 0; + val = 0; + + /* Use default pb926 rate if no rate is supplied */ + if(clkrate == 0) { + clkrate = uartclk; + } + if(baud > 115200 || baud < 1200) { + baud = 38400; /* Default rate. */ + } + + ipart = 39; /* clkrate / (16 * baud) */ + + write(ipart, PL011_UARTIBRD); + write(fpart, PL011_UARTFBRD); + + /* For the IBAUD and FBAUD to update, we need to + * write to UARTLCR_H because the 3 registers are + * actually part of a single register in hardware + * which only updates by a write to UARTLCR_H */ + read(val, PL011_UARTLCR_H); + write(val, PL011_UARTLCR_H); + return; + +} + + +/* Masks the irqs given in the flags bitvector. */ +void pl011_set_irq_mask(unsigned int flags) +{ + unsigned int val; + val = 0; + + if(flags > 0x3FF) { /* Invalid irqmask bitvector */ + return; + } + + read(val, PL011_UARTIMSC); + val |= flags; + write(val, PL011_UARTIMSC); + return; +} + + +/* Clears the irqs given in flags from masking */ +void pl011_clr_irq_mask(unsigned int flags) +{ + unsigned int val; + val = 0; + + if(flags > 0x3FF) { /* Invalid irqmask bitvector */ + return; + } + + read(val, PL011_UARTIMSC); + val &= ~flags; + write(val, PL011_UARTIMSC); + return; +} + + +#endif diff --git a/containers/posix/libc2/src/sys-baremetal/arch-arm/sys_stdio.c b/containers/posix/libc2/src/sys-baremetal/arch-arm/sys_stdio.c new file mode 100644 index 0000000..75b7fea --- /dev/null +++ b/containers/posix/libc2/src/sys-baremetal/arch-arm/sys_stdio.c @@ -0,0 +1,68 @@ +#include +#include + +int __fputc(int c, FILE *stream); + +static int +ser_out(int c) +{ + __fputc(c, 0); + if (c == '\n') + ser_out('\r'); + return 0; +} + +static size_t +l4kdb_write(void *data, long int position, size_t count, void *handle /*unused*/) +{ + size_t i; + char *real_data = data; + for (i = 0; i < count; i++) + ser_out(real_data[i]); + return count; +} + +struct __file __stdin = { + .handle = NULL, + .read_fn = NULL, + .write_fn = NULL, + .close_fn = NULL, + .eof_fn = NULL, + .buffering_mode = _IONBF, + .buffer = NULL, + .unget_pos = 0, + .current_pos = 0, + .eof = 0 +}; + + +struct __file __stdout = { + .handle = NULL, + .read_fn = NULL, + .write_fn = l4kdb_write, + .close_fn = NULL, + .eof_fn = NULL, + .buffering_mode = _IONBF, + .buffer = NULL, + .unget_pos = 0, + .current_pos = 0, + .eof = 0 +}; + + +struct __file __stderr = { + .handle = NULL, + .read_fn = NULL, + .write_fn = l4kdb_write, + .close_fn = NULL, + .eof_fn = NULL, + .buffering_mode = _IONBF, + .buffer = NULL, + .unget_pos = 0, + .current_pos = 0, + .eof = 0 +}; + +FILE *stdin = &__stdin; +FILE *stdout = &__stdout; +FILE *stderr = &__stderr; diff --git a/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/platform_init.c b/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/platform_init.c new file mode 100644 index 0000000..b732a58 --- /dev/null +++ b/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/platform_init.c @@ -0,0 +1,50 @@ +#include + +struct pl011_uart uart; + +void platform_init(void); + +void platform_init(void) +{ + pl011_initialise(&uart); +} + +/* Initialises the uart class data structures, and the device. + * Terminal-like operation is assumed for default settings. + */ +int pl011_initialise(struct pl011_uart * uart) +{ + + uart->frame_errors = 0; + uart->parity_errors = 0; + uart->break_errors = 0; + uart->overrun_errors = 0; + + /* Initialise data register for 8 bit data read/writes */ + pl011_set_word_width(8); + + /* Fifos are disabled because by default it is assumed the port + * will be used as a user terminal, and in that case the typed + * characters will only show up when fifos are flushed, rather than + * when each character is typed. We avoid this by not using fifos. + */ + pl011_disable_fifos(); + + /* Set default baud rate of 38400 */ + pl011_set_baudrate(38400, 24000000); + + /* Set default settings of 1 stop bit, no parity, no hw flow ctrl */ + pl011_set_stopbits(1); + pl011_parity_disable(); + + /* Disable all irqs */ + pl011_set_irq_mask(0x3FF); + + /* Enable rx, tx, and uart chip */ + pl011_tx_enable(); + pl011_rx_enable(); + pl011_uart_enable(); + + return 0; +} + diff --git a/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c b/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c new file mode 100644 index 0000000..ab9e008 --- /dev/null +++ b/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c @@ -0,0 +1,290 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#define MACHINE_PB926 + +#include +#include +#include + +//#define iPAQ /* FIXME: this is ugly */ +//#undef XSCALE +//#define XSCALE +// #undef iPAQ +// #define XSCALE + +extern int __fputc(int c, FILE *stream); +/* Put character for elf-loader */ +int +__fputc(int c, FILE *stream) +{ + +/* ---------------------------------- iPAQ & PLEB1 (SA-1100)--------------------------- */ +#ifdef MACHINE_IPAQ_H3800 //iPAQ // SA-1100 + volatile char *base = (char *)0x80050000; // base serial interface address + /* volatile int *base2 = (int *)0x80030000; // the other serial Arm serial i/f */ + +/* +UTSR1 32 @ 0x20: + tby <0> # Transmitter busy + rne <1> # Refeive FIFO not empty + tnf <2> # Transmitter not full + pre <3> # Parity error + fre <4> # Framing error + ror <5> # Receive FIFO overrun +*/ + +#define UTDR 0x14 // data register +#define UTSR1 0x20 // status register 1 offset +#define UTSR1_TNF (1 << 2) // tx FIFO not full (status bit) + + while ( ! ( * ( (volatile long *) (base + UTSR1)) & UTSR1_TNF )) + ; // busy wait while TX FIFO is full + *(volatile unsigned char *) (base + UTDR) = c; + // *base2 = c; +#endif + +/* ---------------------------------- PLEB2 (XSCALE PXA-255) --------------------------- */ +#ifdef MACHINE_PLEB2 //XSCALE /* PXA 255 on PLEB2 */ + +/* Console port -- taken from kernel/include/platform/pleb2/console.h */ +#define CONSOLE_OFFSET 0x100000 + +/* IO Base -- taken from kernel/include/arch/arm/xscale/cpu.h */ +#define XSCALE_PXA255_IO_BASE 0x40000000 + +#define DATAR 0x00000000 +#define STATUSR 0x00000014 + +/* TX empty bit -- uboot/include/asm/arch/hardware.h */ +#define LSR_TEMT (1 << 6) /* Transmitter Empty */ + +volatile char *base = (char *) (XSCALE_PXA255_IO_BASE + CONSOLE_OFFSET); + + /* wait for room in the tx FIFO on FFUART */ + while ( ! ( * ( (volatile long *) (base + STATUSR)) & LSR_TEMT )) + ; // busy wait while TX FIFO is full + *(volatile unsigned char *) (base + DATAR) = c; + +#endif /* XSCALE */ +#ifdef MACHINE_PB926 + { + int res; + do { + res = pl011_tx_char(c); + } while( res < 0); + } +#endif /* MACHINE_PB926 */ + return(0); +} + +/* --------------------------------- PB926 UART Driver -------------------------------- */ +#ifdef MACHINE_PB926 + +extern struct pl011_uart uart; + +/* UART-specific internal error codes */ +#define PL011_ERROR 1 +#define PL011_EAGAIN 2 + +/* Error status bits in receive status register */ +#define PL011_FE (1 << 0) +#define PL011_PE (1 << 1) +#define PL011_BE (1 << 2) +#define PL011_OE (1 << 3) + +/* Status bits in flag register */ +#define PL011_TXFE (1 << 7) +#define PL011_RXFF (1 << 6) +#define PL011_TXFF (1 << 5) +#define PL011_RXFE (1 << 4) +#define PL011_BUSY (1 << 3) +#define PL011_DCD (1 << 2) +#define PL011_DSR (1 << 1) +#define PL011_CTS (1 << 0) + +int pl011_tx_char(char c) +{ + unsigned int val; + val = 0; + + read(val, PL011_UARTFR); + if(val & PL011_TXFF) { /* TX FIFO Full */ + return -PL011_EAGAIN; + } + write(c, PL011_UARTDR); + return 0; +} + +int pl011_rx_char(char * c) +{ + unsigned int data; + unsigned int val; + val = 0; + + read(val, PL011_UARTFR); + if(val & PL011_RXFE) { /* RX FIFO Empty */ + return -PL011_EAGAIN; + } + + read(data, PL011_UARTDR); + *c = (char) data; + + if((data >> 8) & 0xF) { /* There were errors */ + return -1; /* Signal error in xfer */ + } + return 0; /* No error return */ +} + + +/* + * Sets the baud rate in kbps. It is recommended to use + * standard rates such as: 1200, 2400, 3600, 4800, 7200, + * 9600, 14400, 19200, 28800, 38400, 57600 76800, 115200. + */ +void pl011_set_baudrate(unsigned int baud, unsigned int clkrate) +{ + const unsigned int uartclk = 24000000; /* 24Mhz clock fixed on pb926 */ + unsigned int val; + unsigned int ipart, fpart; + unsigned int remainder; + + remainder = 0; + ipart = 0; + fpart = 0; + val = 0; + + /* Use default pb926 rate if no rate is supplied */ + if(clkrate == 0) { + clkrate = uartclk; + } + if(baud > 115200 || baud < 1200) { + baud = 38400; /* Default rate. */ + } + /* 24000000 / (38400 * 16) */ + ipart = 39; + + write(ipart, PL011_UARTIBRD); + write(fpart, PL011_UARTFBRD); + + /* For the IBAUD and FBAUD to update, we need to + * write to UARTLCR_H because the 3 registers are + * actually part of a single register in hardware + * which only updates by a write to UARTLCR_H */ + read(val, PL011_UARTLCR_H); + write(val, PL011_UARTLCR_H); + return; + +} + + +/* Masks the irqs given in the flags bitvector. */ +void pl011_set_irq_mask(unsigned int flags) +{ + unsigned int val; + val = 0; + + if(flags > 0x3FF) { /* Invalid irqmask bitvector */ + return; + } + + read(val, PL011_UARTIMSC); + val |= flags; + write(val, PL011_UARTIMSC); + return; +} + + +/* Clears the irqs given in flags from masking */ +void pl011_clr_irq_mask(unsigned int flags) +{ + unsigned int val; + val = 0; + + if(flags > 0x3FF) { /* Invalid irqmask bitvector */ + return; + } + + read(val, PL011_UARTIMSC); + val &= ~flags; + write(val, PL011_UARTIMSC); + return; +} + + +#endif diff --git a/containers/posix/libc2/src/sys-userspace/arch-arm/sys_stdio.c b/containers/posix/libc2/src/sys-userspace/arch-arm/sys_stdio.c new file mode 100644 index 0000000..75b7fea --- /dev/null +++ b/containers/posix/libc2/src/sys-userspace/arch-arm/sys_stdio.c @@ -0,0 +1,68 @@ +#include +#include + +int __fputc(int c, FILE *stream); + +static int +ser_out(int c) +{ + __fputc(c, 0); + if (c == '\n') + ser_out('\r'); + return 0; +} + +static size_t +l4kdb_write(void *data, long int position, size_t count, void *handle /*unused*/) +{ + size_t i; + char *real_data = data; + for (i = 0; i < count; i++) + ser_out(real_data[i]); + return count; +} + +struct __file __stdin = { + .handle = NULL, + .read_fn = NULL, + .write_fn = NULL, + .close_fn = NULL, + .eof_fn = NULL, + .buffering_mode = _IONBF, + .buffer = NULL, + .unget_pos = 0, + .current_pos = 0, + .eof = 0 +}; + + +struct __file __stdout = { + .handle = NULL, + .read_fn = NULL, + .write_fn = l4kdb_write, + .close_fn = NULL, + .eof_fn = NULL, + .buffering_mode = _IONBF, + .buffer = NULL, + .unget_pos = 0, + .current_pos = 0, + .eof = 0 +}; + + +struct __file __stderr = { + .handle = NULL, + .read_fn = NULL, + .write_fn = l4kdb_write, + .close_fn = NULL, + .eof_fn = NULL, + .buffering_mode = _IONBF, + .buffer = NULL, + .unget_pos = 0, + .current_pos = 0, + .eof = 0 +}; + +FILE *stdin = &__stdin; +FILE *stdout = &__stdout; +FILE *stderr = &__stderr; diff --git a/containers/posix/libc2/src/system.c b/containers/posix/libc2/src/system.c new file mode 100644 index 0000000..a4c443b --- /dev/null +++ b/containers/posix/libc2/src/system.c @@ -0,0 +1,87 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +int +system(const char *string) +{ + /* Don't suppport a command interpreter at the moment */ + return 0; +} diff --git a/containers/posix/libc2/src/time.c b/containers/posix/libc2/src/time.c new file mode 100644 index 0000000..da44dfe --- /dev/null +++ b/containers/posix/libc2/src/time.c @@ -0,0 +1,88 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ +#include + +time_t +time(time_t *timer) +{ + time_t val = 0; + if (timer) + *timer = val; + return val; +} diff --git a/containers/posix/libc2/src/tmpfile.c b/containers/posix/libc2/src/tmpfile.c new file mode 100644 index 0000000..c18cda2 --- /dev/null +++ b/containers/posix/libc2/src/tmpfile.c @@ -0,0 +1,93 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +extern FILE * sys_tmpfile(void); + +FILE * +tmpfile(void) +{ + FILE *tmp = sys_tmpfile(); + if (tmp != NULL) { + /* Here we need to do additional tests + and setup */ + } + return tmp; +} diff --git a/containers/posix/libc2/src/ungetc.c b/containers/posix/libc2/src/ungetc.c new file mode 100644 index 0000000..60d9588 --- /dev/null +++ b/containers/posix/libc2/src/ungetc.c @@ -0,0 +1,99 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include + +int +ungetc(int c, FILE *stream) +{ + /* + XXX: Note this isn't a full implementation of ungetc, and in particular + doesn't have the correct semantics for binary streams + */ + if (c == EOF) { + return c; + } + if (stream->unget_pos < __UNGET_SIZE) { + stream->eof = 0; + stream->unget_stack[stream->unget_pos++] = c; + return c; + } else { + return EOF; + } +} diff --git a/containers/posix/libc2/src/vfprintf.c b/containers/posix/libc2/src/vfprintf.c new file mode 100644 index 0000000..9e8479c --- /dev/null +++ b/containers/posix/libc2/src/vfprintf.c @@ -0,0 +1,91 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2005 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* +Author: Ben Leslie +*/ + +#include +#include "format.h" + +int +vfprintf(FILE *stream, const char *format, va_list arg) +{ + return format_string(NULL, stream, 1, -1, format, arg); +} diff --git a/containers/posix/libc2/src/vprintf.c b/containers/posix/libc2/src/vprintf.c new file mode 100644 index 0000000..93b8cab --- /dev/null +++ b/containers/posix/libc2/src/vprintf.c @@ -0,0 +1,92 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2005 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +/* +Author: Ben Leslie +*/ + +#include +#include "format.h" + +int +vprintf(const char *format, va_list arg) +{ + return vfprintf(stdout, format, arg); +} + diff --git a/containers/posix/libc2/src/vsnprintf.c b/containers/posix/libc2/src/vsnprintf.c new file mode 100644 index 0000000..d7d579b --- /dev/null +++ b/containers/posix/libc2/src/vsnprintf.c @@ -0,0 +1,91 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#include +#include +#include "format.h" + +int +vsnprintf(char *str, size_t size, const char *format, va_list arg) +{ + if (size == 0) { + return 0; + } + return format_string(str, NULL, 0, size - 1, format, arg); +} diff --git a/containers/posix/mm0/container.c b/containers/posix/mm0/container.c index 598d520..2b7d1f2 100644 --- a/containers/posix/mm0/container.c +++ b/containers/posix/mm0/container.c @@ -16,13 +16,9 @@ */ void main(void); -void uart_init(void); void __container_init(void) { - /* Initialize uarts */ - uart_init(); - /* Generic L4 initialisation */ __l4_init(); diff --git a/containers/posix/mm0/include/file.h b/containers/posix/mm0/include/file.h index 19caf83..f14565f 100644 --- a/containers/posix/mm0/include/file.h +++ b/containers/posix/mm0/include/file.h @@ -6,10 +6,6 @@ #include #include -#define SEEK_CUR 0 -#define SEEK_END 1 -#define SEEK_SET 2 - int vfs_read(unsigned long vnum, unsigned long f_offset, unsigned long npages, void *pagebuf); int vfs_write(unsigned long vnum, unsigned long f_offset, unsigned long npages, diff --git a/containers/posix/mm0/include/linker.lds b/containers/posix/mm0/include/linker.lds index ae99198..ffd56a2 100644 --- a/containers/posix/mm0/include/linker.lds +++ b/containers/posix/mm0/include/linker.lds @@ -25,7 +25,7 @@ SECTIONS { . = virtual_base; _start_text = .; - .text : AT (ADDR(.text) - pager_offset) { *(.text.head) *(.text) } + .text : AT (ADDR(.text) - pager_offset) { crt0.o(.text) *(.text) } /* rodata is needed else your strings will link at physical! */ .rodata : AT (ADDR(.rodata) - pager_offset) { *(.rodata) } .rodata1 : AT (ADDR(.rodata1) - pager_offset) { *(.rodata1) } diff --git a/containers/posix/mm0/main.c b/containers/posix/mm0/main.c index 8ada25e..fe32503 100644 --- a/containers/posix/mm0/main.c +++ b/containers/posix/mm0/main.c @@ -168,9 +168,9 @@ void handle_requests(void) } default: printf("%s: Unrecognised ipc tag (%d) " - "received from (%lu). Full mr reading: " + "received from (%d). Full mr reading: " "%u, %u, %u, %u, %u, %u. Ignoring.\n", - __TASKNAME__, tag, (unsigned long)senderid, read_mr(0), + __TASKNAME__, tag, sender, read_mr(0), read_mr(1), read_mr(2), read_mr(3), read_mr(4), read_mr(5)); } diff --git a/containers/posix/mm0/src/arch-arm/crt0.S b/containers/posix/mm0/src/arch-arm/crt0.S deleted file mode 100644 index a390ee9..0000000 --- a/containers/posix/mm0/src/arch-arm/crt0.S +++ /dev/null @@ -1,12 +0,0 @@ - -.section .text.head -.global _start; -.type _start,function; -.align; - -_start: - ldr sp, =__stack - bl __container_init -1: - b 1b - diff --git a/containers/posix/mm0/src/arch-arm/mm.c b/containers/posix/mm0/src/arch-arm/mm.c index 8a30cb3..5781fee 100644 --- a/containers/posix/mm0/src/arch-arm/mm.c +++ b/containers/posix/mm0/src/arch-arm/mm.c @@ -4,7 +4,6 @@ #include #include #include -#include /* Extracts generic protection flags from architecture-specific pte */ unsigned int vm_prot_flags(pte_t pte) diff --git a/containers/posix/mm0/src/arch/crt0.S b/containers/posix/mm0/src/arch/crt0.S deleted file mode 100644 index a390ee9..0000000 --- a/containers/posix/mm0/src/arch/crt0.S +++ /dev/null @@ -1,12 +0,0 @@ - -.section .text.head -.global _start; -.type _start,function; -.align; - -_start: - ldr sp, =__stack - bl __container_init -1: - b 1b - diff --git a/containers/posix/mm0/src/bootm.c b/containers/posix/mm0/src/bootm.c index 74d4b98..cf7a602 100644 --- a/containers/posix/mm0/src/bootm.c +++ b/containers/posix/mm0/src/bootm.c @@ -13,7 +13,7 @@ #include #include INC_GLUE(memory.h) -#include +#include /* All memory allocated here is discarded after boot */ diff --git a/containers/posix/mm0/src/capability.c b/containers/posix/mm0/src/capability.c index b1f218e..b89acb9 100644 --- a/containers/posix/mm0/src/capability.c +++ b/containers/posix/mm0/src/capability.c @@ -11,7 +11,6 @@ #include #include /* TODO: Move this to API */ #include -#include struct cap_list capability_list; diff --git a/containers/posix/mm0/src/file.c b/containers/posix/mm0/src/file.c index f6472ba..0b8f0d5 100644 --- a/containers/posix/mm0/src/file.c +++ b/containers/posix/mm0/src/file.c @@ -348,7 +348,7 @@ int read_file_pages(struct vm_file *vmfile, unsigned long pfn_start, f_offset); if (IS_ERR(page)) { printf("%s: %s:Could not read page %d " - "from file with vnum: 0x%lx\n", __TASKNAME__, + "from file with vnum: 0x%x\n", __TASKNAME__, __FUNCTION__, f_offset, vm_file_to_vnum(vmfile)); return (int)page; } @@ -460,7 +460,7 @@ int write_file_pages(struct vm_file *f, unsigned long pfn_start, err = f->vm_obj.pager->ops.page_out(&f->vm_obj, f_offset); if (err < 0) { printf("%s: %s:Could not write page %d " - "to file with vnum: 0x%lx\n", __TASKNAME__, + "to file with vnum: 0x%x\n", __TASKNAME__, __FUNCTION__, f_offset, vm_file_to_vnum(f)); return err; } diff --git a/containers/posix/mm0/src/lib/addr.c b/containers/posix/mm0/src/lib/addr.c index 8131fa5..d7c7733 100644 --- a/containers/posix/mm0/src/lib/addr.c +++ b/containers/posix/mm0/src/lib/addr.c @@ -9,7 +9,7 @@ #include #include INC_GLUE(memory.h) #include -#include +#include /* * Initializes an address pool, but uses an already diff --git a/containers/posix/mm0/src/lib/bit.c b/containers/posix/mm0/src/lib/bit.c index 9eaaf5c..84750e3 100644 --- a/containers/posix/mm0/src/lib/bit.c +++ b/containers/posix/mm0/src/lib/bit.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include INC_GLUE(memory.h) /* Emulation of ARM's CLZ (count leading zeroes) instruction */ diff --git a/containers/posix/mm0/src/lib/elf/elf.c b/containers/posix/mm0/src/lib/elf/elf.c index 179b6e4..3f6a62f 100644 --- a/containers/posix/mm0/src/lib/elf/elf.c +++ b/containers/posix/mm0/src/lib/elf/elf.c @@ -10,7 +10,7 @@ #include #include #include -#include + int elf_probe(struct elf_header *header) { diff --git a/containers/posix/mm0/src/lib/idpool.c b/containers/posix/mm0/src/lib/idpool.c index 384d15c..9d1f3df 100644 --- a/containers/posix/mm0/src/lib/idpool.c +++ b/containers/posix/mm0/src/lib/idpool.c @@ -7,7 +7,7 @@ #include #include #include INC_GLUE(memory.h) -#include +#include #include struct id_pool *id_pool_new_init(int totalbits) diff --git a/containers/posix/mm0/src/lib/malloc.c b/containers/posix/mm0/src/lib/malloc.c index cfd303a..13b36ef 100644 --- a/containers/posix/mm0/src/lib/malloc.c +++ b/containers/posix/mm0/src/lib/malloc.c @@ -18,7 +18,6 @@ Messages that indicate a software error will contain three asterisks (***). *****************************************************************************/ #include /* memcpy(), memset() */ #include /* printf() */ -#include #include #define _32BIT 1 diff --git a/containers/posix/mm0/src/mmap.c b/containers/posix/mm0/src/mmap.c index 857385c..5acb0e4 100644 --- a/containers/posix/mm0/src/mmap.c +++ b/containers/posix/mm0/src/mmap.c @@ -239,8 +239,8 @@ void *do_mmap(struct vm_file *mapfile, unsigned long file_offset, /* Get total file pages, check if mapping is within file size */ file_npages = __pfn(page_align_up(mapfile->length)); if (npages > file_npages - file_offset) { - printf("%s: Trying to map %d pages from page %lu, " - "but file length is %lu\n", __FUNCTION__, + printf("%s: Trying to map %d pages from page %d, " + "but file length is %d\n", __FUNCTION__, npages, file_offset, file_npages); return PTR_ERR(-EINVAL); } diff --git a/containers/posix/mm0/src/pagers.c b/containers/posix/mm0/src/pagers.c index fd46d59..ed3512f 100644 --- a/containers/posix/mm0/src/pagers.c +++ b/containers/posix/mm0/src/pagers.c @@ -71,8 +71,8 @@ int file_page_out(struct vm_object *vm_obj, unsigned long page_offset) /* Check first if the file has such a page at all */ if (__pfn(page_align_up(f->length) <= page_offset)) { - printf("%s: %s: Trying to look up page %lu, but file length " - "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, + printf("%s: %s: Trying to look up page %d, but file length " + "is %d bytes.\n", __TASKNAME__, __FUNCTION__, page_offset, f->length); BUG(); } @@ -123,8 +123,8 @@ struct page *file_page_in(struct vm_object *vm_obj, unsigned long page_offset) /* Check first if the file has such a page at all */ if (__pfn(page_align_up(f->length) <= page_offset)) { - printf("%s: %s: Trying to look up page %lu, but file length " - "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, + printf("%s: %s: Trying to look up page %d, but file length " + "is %d bytes.\n", __TASKNAME__, __FUNCTION__, page_offset, f->length); BUG(); } @@ -253,8 +253,8 @@ struct page *bootfile_page_in(struct vm_object *vm_obj, /* Check first if the file has such a page at all */ if (__pfn(page_align_up(boot_file->length) <= offset)) { - printf("%s: %s: Trying to look up page %lu, but file length " - "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, + printf("%s: %s: Trying to look up page %d, but file length " + "is %d bytes.\n", __TASKNAME__, __FUNCTION__, offset, boot_file->length); BUG(); } diff --git a/containers/posix/mm0/src/test.c b/containers/posix/mm0/src/test.c index db43b30..e04ab66 100644 --- a/containers/posix/mm0/src/test.c +++ b/containers/posix/mm0/src/test.c @@ -10,7 +10,6 @@ #include #include #include -#include struct vm_statistics { int tasks; /* All tasks counted on the system */ diff --git a/containers/posix/mm0/src/utcb.c b/containers/posix/mm0/src/utcb.c index 2b87386..6add67c 100644 --- a/containers/posix/mm0/src/utcb.c +++ b/containers/posix/mm0/src/utcb.c @@ -10,7 +10,6 @@ #include #include #include -#include /* * UTCB management in Codezero @@ -141,7 +140,7 @@ out: if (IS_ERR(err = do_mmap(0, 0, task, slot, VMA_ANONYMOUS | VMA_PRIVATE | VMA_FIXED | VM_READ | VM_WRITE, 1))) { - printf("UTCB: mmapping failed with %p\n", err); + printf("UTCB: mmapping failed with %d\n", err); return (int)err; } } diff --git a/containers/posix/mm0/src/vm_object.c b/containers/posix/mm0/src/vm_object.c index 515c839..23ee304 100644 --- a/containers/posix/mm0/src/vm_object.c +++ b/containers/posix/mm0/src/vm_object.c @@ -9,7 +9,6 @@ #include #include #include -#include /* Global list of all in-memory files on the system */ struct global_list global_vm_files = { diff --git a/containers/posix/test0/include/linker.lds b/containers/posix/test0/include/linker.lds index 5da024e..f1c0c3e 100644 --- a/containers/posix/test0/include/linker.lds +++ b/containers/posix/test0/include/linker.lds @@ -26,7 +26,7 @@ SECTIONS { . = virtual_base; _start_text = .; - .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } + .text : AT (ADDR(.text) - offset) { crt0.o(.text) *(.text) } /* rodata is needed else your strings will link at physical! */ .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } diff --git a/containers/posix/test0/include/tests.h b/containers/posix/test0/include/tests.h index 474c3cc..e6e313f 100644 --- a/containers/posix/test0/include/tests.h +++ b/containers/posix/test0/include/tests.h @@ -3,14 +3,13 @@ #define __TASKNAME__ "test0" -// #define TEST_VERBOSE_PRINT +//#define TEST_VERBOSE_PRINT #if defined (TEST_VERBOSE_PRINT) #define test_printf(...) printf(__VA_ARGS__) #else #define test_printf(...) #endif -#include #include extern pid_t parent_of_all; diff --git a/containers/posix/test0/src/clonetest.c b/containers/posix/test0/src/clonetest.c index 56c14cb..a0f50d2 100644 --- a/containers/posix/test0/src/clonetest.c +++ b/containers/posix/test0/src/clonetest.c @@ -2,7 +2,6 @@ * Clone test. */ #include -#include #include #include #include diff --git a/containers/posix/test0/src/crt0.S b/containers/posix/test0/src/crt0.S deleted file mode 100644 index a390ee9..0000000 --- a/containers/posix/test0/src/crt0.S +++ /dev/null @@ -1,12 +0,0 @@ - -.section .text.head -.global _start; -.type _start,function; -.align; - -_start: - ldr sp, =__stack - bl __container_init -1: - b 1b - diff --git a/containers/posix/test0/src/dirtest.c b/containers/posix/test0/src/dirtest.c index ea8ca6f..a091248 100644 --- a/containers/posix/test0/src/dirtest.c +++ b/containers/posix/test0/src/dirtest.c @@ -11,13 +11,12 @@ #include #include #include -#include #define DENTS_TOTAL 50 void print_fsize(struct stat *s) { - printf("%lu", s->st_size); + printf("%d", s->st_size); } void print_flink(struct stat *s) diff --git a/containers/posix/test0/src/exectest.c b/containers/posix/test0/src/exectest.c index af26038..9b9d945 100644 --- a/containers/posix/test0/src/exectest.c +++ b/containers/posix/test0/src/exectest.c @@ -10,7 +10,6 @@ #include #include #include -#include extern char _start_test_exec[]; extern char _end_test_exec[]; diff --git a/containers/posix/test0/src/fileio.c b/containers/posix/test0/src/fileio.c index e1bede3..b5aabe3 100644 --- a/containers/posix/test0/src/fileio.c +++ b/containers/posix/test0/src/fileio.c @@ -7,7 +7,6 @@ #include #include #include -#include int fileio(void) { diff --git a/containers/posix/test0/src/forktest.c b/containers/posix/test0/src/forktest.c index 54c30b4..204b83e 100644 --- a/containers/posix/test0/src/forktest.c +++ b/containers/posix/test0/src/forktest.c @@ -7,7 +7,6 @@ #include #include #include -#include int global = 0; diff --git a/containers/posix/test0/src/mmaptest.c b/containers/posix/test0/src/mmaptest.c index 9550481..5ff6230 100644 --- a/containers/posix/test0/src/mmaptest.c +++ b/containers/posix/test0/src/mmaptest.c @@ -14,7 +14,6 @@ #include #include #include -#include #define PAGE_SIZE 0x1000 diff --git a/containers/posix/test0/src/shmtest.c b/containers/posix/test0/src/shmtest.c index 713fef6..edf4d11 100644 --- a/containers/posix/test0/src/shmtest.c +++ b/containers/posix/test0/src/shmtest.c @@ -22,7 +22,7 @@ int shmtest(void) test_printf("Initiating shmget()\n"); for (int i = 0; i < 2; i++) { if ((shmids[i] = shmget(keys[i], 27, IPC_CREAT | 0666)) < 0) { - test_printf("SHMGET: %d", errno); + test_printf("SHMGET", errno); goto out_err; } else test_printf("SHMID returned: %d\n", shmids[i]); @@ -30,7 +30,7 @@ int shmtest(void) test_printf("Now shmat()\n"); for (int i = 0; i < 2; i++) { if ((int)(bases[i] = shmat(shmids[i], NULL, 0)) == -1) { - test_printf("SHMAT: %d", errno); + test_printf("SHMAT", errno); goto out_err; } else test_printf("SHM base address returned: %p\n", bases[i]); @@ -42,7 +42,7 @@ int shmtest(void) test_printf("Now shmdt()\n"); for (int i = 0; i < 2; i++) { if (shmdt(bases[i]) < 0) { - test_printf("SHMDT: %d", errno); + test_printf("SHMDT", errno); goto out_err; } else test_printf("SHM detached OK.\n"); diff --git a/containers/posix/test0/src/test_exec/crt0.S b/containers/posix/test0/src/test_exec/crt0.S deleted file mode 100644 index a390ee9..0000000 --- a/containers/posix/test0/src/test_exec/crt0.S +++ /dev/null @@ -1,12 +0,0 @@ - -.section .text.head -.global _start; -.type _start,function; -.align; - -_start: - ldr sp, =__stack - bl __container_init -1: - b 1b - diff --git a/containers/posix/test0/src/test_exec/test_exec.c b/containers/posix/test0/src/test_exec/test_exec.c index 5e40cb5..b1287b7 100644 --- a/containers/posix/test0/src/test_exec/test_exec.c +++ b/containers/posix/test0/src/test_exec/test_exec.c @@ -26,7 +26,7 @@ void main(void) { wait_pager(0); if (getpid() == 2) { - printf("EXECVE TEST -- PASSED --\n"); + printf("EXECVE TEST -- PASSED --\n", getpid()); printf("\nThread (%d): Continues to sync with the pager...\n\n", getpid()); while (1) wait_pager(0); From 763d4c7012363befa763171d47b3a1a35b67cc1b Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 29 Aug 2009 14:31:03 +0300 Subject: [PATCH 2/9] Removed accidentally added config file. --- containers/.config | 213 --------------------------------------------- 1 file changed, 213 deletions(-) delete mode 100644 containers/.config diff --git a/containers/.config b/containers/.config deleted file mode 100644 index 4824612..0000000 --- a/containers/.config +++ /dev/null @@ -1,213 +0,0 @@ -# -# Automatically generated make config: don't edit -# Fri Jan 11 15:12:13 2008 -# -# TARGET_alpha is not set -TARGET_arm=y -# TARGET_avr32 is not set -# TARGET_bfin is not set -# TARGET_cris is not set -# TARGET_e1 is not set -# TARGET_frv is not set -# TARGET_h8300 is not set -# TARGET_hppa is not set -# TARGET_i386 is not set -# TARGET_i960 is not set -# TARGET_ia64 is not set -# TARGET_m68k is not set -# TARGET_microblaze is not set -# TARGET_mips is not set -# TARGET_nios is not set -# TARGET_nios2 is not set -# TARGET_powerpc is not set -# TARGET_sh is not set -# TARGET_sh64 is not set -# TARGET_sparc is not set -# TARGET_v850 is not set -# TARGET_vax is not set -# TARGET_x86_64 is not set - -# -# Target Architecture Features and Options -# -TARGET_ARCH="arm" -FORCE_OPTIONS_FOR_ARCH=y -# CONFIG_ARM_OABI is not set -CONFIG_ARM_EABI=y -CONFIG_GENERIC_ARM=y -# CONFIG_ARM610 is not set -# CONFIG_ARM710 is not set -# CONFIG_ARM7TDMI is not set -# CONFIG_ARM720T is not set -# CONFIG_ARM920T is not set -# CONFIG_ARM922T is not set -# CONFIG_ARM926T is not set -# CONFIG_ARM10T is not set -# CONFIG_ARM1136JF_S is not set -# CONFIG_ARM1176JZ_S is not set -# CONFIG_ARM1176JZF_S is not set -# CONFIG_ARM_SA110 is not set -# CONFIG_ARM_SA1100 is not set -# CONFIG_ARM_XSCALE is not set -# CONFIG_ARM_IWMMXT is not set -TARGET_SUBARCH="" - -# -# Using ELF file format -# -ARCH_ANY_ENDIAN=y -ARCH_LITTLE_ENDIAN=y -# ARCH_WANTS_BIG_ENDIAN is not set -ARCH_WANTS_LITTLE_ENDIAN=y -ARCH_HAS_MMU=y -ARCH_USE_MMU=y -UCLIBC_HAS_FLOATS=y -UCLIBC_HAS_FPU=y -DO_C99_MATH=y -KERNEL_HEADERS="/opt/l4-project/tasks/libc/linux-headers/include" -HAVE_DOT_CONFIG=y - -# -# General Library Settings -# -# HAVE_NO_PIC is not set -DOPIC=y -# HAVE_NO_SHARED is not set -# ARCH_HAS_NO_LDSO is not set -HAVE_SHARED=y -# FORCE_SHAREABLE_TEXT_SEGMENTS is not set -LDSO_LDD_SUPPORT=y -LDSO_CACHE_SUPPORT=y -# LDSO_PRELOAD_FILE_SUPPORT is not set -LDSO_BASE_FILENAME="ld.so" -# UCLIBC_STATIC_LDCONFIG is not set -# LDSO_RUNPATH is not set -UCLIBC_CTOR_DTOR=y -# HAS_NO_THREADS is not set -UCLIBC_HAS_THREADS=y -# PTHREADS_DEBUG_SUPPORT is not set -LINUXTHREADS_OLD=y -UCLIBC_HAS_LFS=y -# MALLOC is not set -# MALLOC_SIMPLE is not set -MALLOC_STANDARD=y -MALLOC_GLIBC_COMPAT=y -UCLIBC_DYNAMIC_ATEXIT=y -# COMPAT_ATEXIT is not set -# UCLIBC_SUSV3_LEGACY is not set -# UCLIBC_SUSV3_LEGACY_MACROS is not set -UCLIBC_HAS_SHADOW=y -# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set -UCLIBC_HAS___PROGNAME=y -# UNIX98PTY_ONLY is not set -ASSUME_DEVPTS=y -UCLIBC_HAS_TM_EXTENSIONS=y -UCLIBC_HAS_TZ_CACHING=y -UCLIBC_HAS_TZ_FILE=y -UCLIBC_HAS_TZ_FILE_READ_MANY=y -UCLIBC_TZ_FILE_PATH="/etc/TZ" - -# -# Advanced Library Settings -# -UCLIBC_PWD_BUFFER_SIZE=256 -UCLIBC_GRP_BUFFER_SIZE=256 - -# -# Networking Support -# -# UCLIBC_HAS_IPV6 is not set -UCLIBC_HAS_RPC=y -UCLIBC_HAS_FULL_RPC=y -UCLIBC_HAS_REENTRANT_RPC=y -# UCLIBC_USE_NETLINK is not set -# UCLIBC_HAS_BSD_RES_CLOSE is not set - -# -# String and Stdio Support -# -UCLIBC_HAS_STRING_GENERIC_OPT=y -UCLIBC_HAS_STRING_ARCH_OPT=y -UCLIBC_HAS_CTYPE_TABLES=y -UCLIBC_HAS_CTYPE_SIGNED=y -# UCLIBC_HAS_CTYPE_UNSAFE is not set -UCLIBC_HAS_CTYPE_CHECKED=y -# UCLIBC_HAS_CTYPE_ENFORCED is not set -# UCLIBC_HAS_WCHAR is not set -# UCLIBC_HAS_LOCALE is not set -UCLIBC_HAS_HEXADECIMAL_FLOATS=y -UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y -# USE_OLD_VFPRINTF is not set -UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9 -UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y -# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set -# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set -# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set -UCLIBC_HAS_STDIO_BUFSIZ_4096=y -# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set -UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y -# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set -# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set -# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set -UCLIBC_HAS_STDIO_GETC_MACRO=y -UCLIBC_HAS_STDIO_PUTC_MACRO=y -UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y -# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set -UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y -UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y -UCLIBC_HAS_PRINTF_M_SPEC=y -UCLIBC_HAS_ERRNO_MESSAGES=y -# UCLIBC_HAS_SYS_ERRLIST is not set -UCLIBC_HAS_SIGNUM_MESSAGES=y -# UCLIBC_HAS_SYS_SIGLIST is not set -UCLIBC_HAS_GNU_GETOPT=y -UCLIBC_HAS_GNU_GETSUBOPT=y - -# -# Big and Tall -# -UCLIBC_HAS_REGEX=y -UCLIBC_HAS_REGEX_OLD=y -UCLIBC_HAS_FNMATCH=y -UCLIBC_HAS_FNMATCH_OLD=y -# UCLIBC_HAS_WORDEXP is not set -UCLIBC_HAS_FTW=y -UCLIBC_HAS_GLOB=y -UCLIBC_HAS_GNU_GLOB=y - -# -# Library Installation Options -# -SHARED_LIB_LOADER_PREFIX="/lib" -RUNTIME_PREFIX="/" -DEVEL_PREFIX="/usr/" - -# -# Security options -# -# UCLIBC_BUILD_PIE is not set -# UCLIBC_HAS_ARC4RANDOM is not set -# HAVE_NO_SSP is not set -# UCLIBC_HAS_SSP is not set -UCLIBC_BUILD_RELRO=y -UCLIBC_BUILD_NOW=y -# UCLIBC_BUILD_NOEXECSTACK is not set - -# -# uClibc development/debugging options -# -CROSS_COMPILER_PREFIX="/opt/scratch3/buildroot/build_arm/staging_dir/usr/bin/arm-linux-uclibcgnueabi-" -UCLIBC_EXTRA_CFLAGS="" -# DODEBUG is not set -# DODEBUG_PT is not set -DOSTRIP=y -# DOASSERTS is not set -# SUPPORT_LD_DEBUG is not set -# SUPPORT_LD_DEBUG_EARLY is not set -# UCLIBC_MALLOC_DEBUGGING is not set -WARNINGS="-Wall" -# EXTRA_WARNINGS is not set -# DOMULTI is not set -# UCLIBC_MJN3_ONLY is not set From 5892fba52aae96798f182bc174af07c056b66260 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 29 Aug 2009 15:07:12 +0300 Subject: [PATCH 3/9] Fixed linker scripts on broken crt0.S path --- containers/posix/fs0/include/linker.lds | 2 +- containers/posix/libc2/SConscript | 8 +- .../libc2/crt/sys-userspace/arch-arm/crt0.S | 93 ------------------- containers/posix/mm0/include/linker.lds | 2 +- containers/posix/test0/include/linker.lds | 2 +- 5 files changed, 7 insertions(+), 100 deletions(-) delete mode 100644 containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S diff --git a/containers/posix/fs0/include/linker.lds b/containers/posix/fs0/include/linker.lds index d555415..fed94eb 100644 --- a/containers/posix/fs0/include/linker.lds +++ b/containers/posix/fs0/include/linker.lds @@ -26,7 +26,7 @@ SECTIONS { . = virtual_base; _start_text = .; - .text : AT (ADDR(.text) - offset) { crt0.o(.text) *(.text) } + .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } /* rodata is needed else your strings will link at physical! */ .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } diff --git a/containers/posix/libc2/SConscript b/containers/posix/libc2/SConscript index ff6bb81..64f3949 100644 --- a/containers/posix/libc2/SConscript +++ b/containers/posix/libc2/SConscript @@ -36,10 +36,10 @@ objects = e.StaticObject(source) Depends (objects, e['configFiles']) library = e.StaticLibrary('c-' + variant, objects) Depends (library, e['configFiles']) -runTime = e.StaticObject('crt/sys-' + variant + '/arch-' + e['ARCH'] + '/crt0.S') -Depends (runTime, e['configFiles']) +#runTime = e.StaticObject('crt/sys-' + variant + '/arch-' + e['ARCH'] + '/crt0.S') +#Depends (runTime, e['configFiles']) -result = (library, runTime) -#result = (library) +#result = (library, runTime) +result = (library) Return('result') diff --git a/containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S b/containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S deleted file mode 100644 index a1d6ae3..0000000 --- a/containers/posix/libc2/crt/sys-userspace/arch-arm/crt0.S +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Australian Public Licence B (OZPLB) - * - * Version 1-0 - * - * Copyright (c) 2004 National ICT Australia - * - * All rights reserved. - * - * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) - * National ICT Australia - * http://www.ertos.nicta.com.au - * - * Permission is granted by National ICT Australia, free of charge, to - * any person obtaining a copy of this software and any associated - * documentation files (the "Software") to deal with the Software without - * restriction, including (without limitation) the rights to use, copy, - * modify, adapt, merge, publish, distribute, communicate to the public, - * sublicense, and/or sell, lend or rent out copies of the Software, and - * to permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimers. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimers in the documentation and/or other materials provided - * with the distribution. - * - * * Neither the name of National ICT Australia, nor the names of its - * contributors, may be used to endorse or promote products derived - * from this Software without specific prior written permission. - * - * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT - * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND - * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, - * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS - * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, - * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF - * ERRORS, WHETHER OR NOT DISCOVERABLE. - * - * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL - * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL - * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER - * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR - * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS - * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR - * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, - * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN - * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER - * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS - * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, - * DAMAGES OR OTHER LIABILITY. - * - * If applicable legislation implies representations, warranties, or - * conditions, or imposes obligations or liability on National ICT - * Australia or one of its contributors in respect of the Software that - * cannot be wholly or partly excluded, restricted or modified, the - * liability of National ICT Australia or the contributor is limited, to - * the full extent permitted by the applicable legislation, at its - * option, to: - * a. in the case of goods, any one or more of the following: - * i. the replacement of the goods or the supply of equivalent goods; - * ii. the repair of the goods; - * iii. the payment of the cost of replacing the goods or of acquiring - * equivalent goods; - * iv. the payment of the cost of having the goods repaired; or - * b. in the case of services: - * i. the supplying of the services again; or - * ii. the payment of the cost of having the services supplied again. - * - * The construction, validity and performance of this licence is governed - * by the laws in force in New South Wales, Australia. - */ - -#ifdef __thumb__ -#define bl blx -#endif - - .code 32 - .global _start; - .align; -_start: - ldr sp, =__stack - bl platform_init - bl __container_init -1: - b 1b - diff --git a/containers/posix/mm0/include/linker.lds b/containers/posix/mm0/include/linker.lds index ffd56a2..ae99198 100644 --- a/containers/posix/mm0/include/linker.lds +++ b/containers/posix/mm0/include/linker.lds @@ -25,7 +25,7 @@ SECTIONS { . = virtual_base; _start_text = .; - .text : AT (ADDR(.text) - pager_offset) { crt0.o(.text) *(.text) } + .text : AT (ADDR(.text) - pager_offset) { *(.text.head) *(.text) } /* rodata is needed else your strings will link at physical! */ .rodata : AT (ADDR(.rodata) - pager_offset) { *(.rodata) } .rodata1 : AT (ADDR(.rodata1) - pager_offset) { *(.rodata1) } diff --git a/containers/posix/test0/include/linker.lds b/containers/posix/test0/include/linker.lds index f1c0c3e..5da024e 100644 --- a/containers/posix/test0/include/linker.lds +++ b/containers/posix/test0/include/linker.lds @@ -26,7 +26,7 @@ SECTIONS { . = virtual_base; _start_text = .; - .text : AT (ADDR(.text) - offset) { crt0.o(.text) *(.text) } + .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } /* rodata is needed else your strings will link at physical! */ .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } From 2bbb963848c96f344af54f761df837196751aaed Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 29 Aug 2009 15:09:48 +0300 Subject: [PATCH 4/9] Added untracked crt0.S --- containers/posix/fs0/src/crt0.S | 94 +++++++++++++++++++++ containers/posix/mm0/src/arch-arm/crt0.S | 94 +++++++++++++++++++++ containers/posix/test0/src/crt0.S | 94 +++++++++++++++++++++ containers/posix/test0/src/test_exec/crt0.S | 94 +++++++++++++++++++++ 4 files changed, 376 insertions(+) create mode 100644 containers/posix/fs0/src/crt0.S create mode 100644 containers/posix/mm0/src/arch-arm/crt0.S create mode 100644 containers/posix/test0/src/crt0.S create mode 100644 containers/posix/test0/src/test_exec/crt0.S diff --git a/containers/posix/fs0/src/crt0.S b/containers/posix/fs0/src/crt0.S new file mode 100644 index 0000000..9bcb3a8 --- /dev/null +++ b/containers/posix/fs0/src/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/containers/posix/mm0/src/arch-arm/crt0.S b/containers/posix/mm0/src/arch-arm/crt0.S new file mode 100644 index 0000000..9bcb3a8 --- /dev/null +++ b/containers/posix/mm0/src/arch-arm/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/containers/posix/test0/src/crt0.S b/containers/posix/test0/src/crt0.S new file mode 100644 index 0000000..9bcb3a8 --- /dev/null +++ b/containers/posix/test0/src/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/containers/posix/test0/src/test_exec/crt0.S b/containers/posix/test0/src/test_exec/crt0.S new file mode 100644 index 0000000..d28b311 --- /dev/null +++ b/containers/posix/test0/src/test_exec/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + +.section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + From 7b5a3c2845824371cfeaca9443457a0b76fa23f1 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 29 Aug 2009 15:56:28 +0300 Subject: [PATCH 5/9] Moved userspace libc to posix container directory. Issues: - MM0 needs separate subset of libc and not link with libposix - FS0 needs separate subset of libc and not link with libposix - libposix need transforming into a full-blown uclibc for test0 - libc really is a pseudo-libc that needs to be replaced as above. - Done some hacking to avoid conflicts between pseudo-libc and libposix headers. Now system working as original, (e.g. execve etc. working) --- containers/posix/fs0/main.c | 2 +- containers/posix/fs0/src/memfs/memfs.c | 2 +- containers/posix/{libc2 => libc}/SConscript | 0 .../crt/sys-baremetal/arch-arm/crt0.S | 0 .../{libc2 => libc}/include/arch/arm/arch/inttypes.h | 0 .../include/arch/arm/arch/pl011_uart.h | 0 .../{libc2 => libc}/include/arch/arm/arch/setjmp.h | 0 .../{libc2 => libc}/include/arch/arm/arch/stdint.h | 0 containers/posix/{libc2 => libc}/include/assert.h | 0 containers/posix/{libc2 => libc}/include/complex.h | 0 containers/posix/{libc2 => libc}/include/ctype.h | 0 containers/posix/{libc2 => libc}/include/errno.h | 8 +++++++- containers/posix/{libc2 => libc}/include/inttypes.h | 0 containers/posix/{libc2 => libc}/include/iso646.h | 0 containers/posix/{libc2 => libc}/include/limits.h | 0 containers/posix/{libc2 => libc}/include/locale.h | 0 containers/posix/{libc2 => libc}/include/setjmp.h | 0 containers/posix/{libc2 => libc}/include/stdarg.h | 0 containers/posix/{libc2 => libc}/include/stdbool.h | 0 containers/posix/{libc2 => libc}/include/stddef.h | 2 ++ containers/posix/{libc2 => libc}/include/stdint.h | 0 containers/posix/{libc2 => libc}/include/stdio.h | 6 ++++++ containers/posix/{libc2 => libc}/include/stdlib.h | 0 containers/posix/{libc2 => libc}/include/string.h | 0 .../include/sys-baremetal/arch-arm/arch/inttypes.h | 0 .../include/sys-baremetal/arch-arm/arch/pl011_uart.h | 0 .../include/sys-baremetal/arch-arm/arch/setjmp.h | 0 .../include/sys-baremetal/arch-arm/arch/stdint.h | 0 .../include/sys-baremetal/arch-arm/inttypes.h | 0 .../include/sys-baremetal/arch-arm/pl011_uart.h | 0 .../include/sys-baremetal/arch-arm/setjmp.h | 0 .../include/sys-baremetal/arch-arm/stdint.h | 0 .../include/sys-userspace/arch-arm/arch/inttypes.h | 0 .../include/sys-userspace/arch-arm/arch/pl011_uart.h | 0 .../include/sys-userspace/arch-arm/arch/setjmp.h | 0 .../include/sys-userspace/arch-arm/arch/stdint.h | 0 .../include/sys-userspace/arch-arm/inttypes.h | 0 .../include/sys-userspace/arch-arm/pl011_uart.h | 0 .../include/sys-userspace/arch-arm/setjmp.h | 0 .../include/sys-userspace/arch-arm/stdint.h | 0 containers/posix/{libc2 => libc}/include/time.h | 0 containers/posix/{libc2 => libc}/src/arch-arm/eabi.c | 0 containers/posix/{libc2 => libc}/src/arch-arm/jmp.S | 0 containers/posix/{libc2 => libc}/src/asctime.c | 0 containers/posix/{libc2 => libc}/src/assert.c | 0 containers/posix/{libc2 => libc}/src/calloc.c | 0 containers/posix/{libc2 => libc}/src/clearerr.c | 0 containers/posix/{libc2 => libc}/src/clock.c | 0 containers/posix/{libc2 => libc}/src/ctype.c | 0 containers/posix/{libc2 => libc}/src/difftime.c | 0 containers/posix/{libc2 => libc}/src/errno.c | 0 containers/posix/{libc2 => libc}/src/exit.c | 0 containers/posix/{libc2 => libc}/src/fclose.c | 0 containers/posix/{libc2 => libc}/src/feof.c | 0 containers/posix/{libc2 => libc}/src/ferror.c | 0 containers/posix/{libc2 => libc}/src/fflush.c | 0 containers/posix/{libc2 => libc}/src/fgetc.c | 0 containers/posix/{libc2 => libc}/src/fgets.c | 0 containers/posix/{libc2 => libc}/src/format.c | 0 containers/posix/{libc2 => libc}/src/format.h | 0 containers/posix/{libc2 => libc}/src/fprintf.c | 0 containers/posix/{libc2 => libc}/src/fputc.c | 0 containers/posix/{libc2 => libc}/src/fputs.c | 0 containers/posix/{libc2 => libc}/src/fread.c | 0 containers/posix/{libc2 => libc}/src/fscanf.c | 0 containers/posix/{libc2 => libc}/src/fseek.c | 0 containers/posix/{libc2 => libc}/src/ftell.c | 0 containers/posix/{libc2 => libc}/src/fwrite.c | 0 containers/posix/{libc2 => libc}/src/getchar.c | 0 containers/posix/{libc2 => libc}/src/getenv.c | 0 containers/posix/{libc2 => libc}/src/gmtime.c | 0 containers/posix/{libc2 => libc}/src/k_r_malloc.h | 0 containers/posix/{libc2 => libc}/src/locale.c | 0 containers/posix/{libc2 => libc}/src/localtime.c | 0 containers/posix/{libc2 => libc}/src/malloc.c | 0 containers/posix/{libc2 => libc}/src/memchr.c | 0 containers/posix/{libc2 => libc}/src/memcmp.c | 0 containers/posix/{libc2 => libc}/src/memcpy.c | 0 containers/posix/{libc2 => libc}/src/memmove.c | 0 containers/posix/{libc2 => libc}/src/memset.c | 0 containers/posix/{libc2 => libc}/src/mktime.c | 0 containers/posix/{libc2 => libc}/src/perror.c | 0 containers/posix/{libc2 => libc}/src/printf.c | 0 containers/posix/{libc2 => libc}/src/putchar.c | 0 containers/posix/{libc2 => libc}/src/puts.c | 0 containers/posix/{libc2 => libc}/src/qsort.c | 0 containers/posix/{libc2 => libc}/src/rand.c | 0 containers/posix/{libc2 => libc}/src/realloc.c | 0 containers/posix/{libc2 => libc}/src/remove.c | 0 containers/posix/{libc2 => libc}/src/rename.c | 0 containers/posix/{libc2 => libc}/src/rewind.c | 0 containers/posix/{libc2 => libc}/src/snprintf.c | 0 containers/posix/{libc2 => libc}/src/sprintf.c | 0 containers/posix/{libc2 => libc}/src/srand.c | 0 containers/posix/{libc2 => libc}/src/strcat.c | 0 containers/posix/{libc2 => libc}/src/strchr.c | 0 containers/posix/{libc2 => libc}/src/strcmp.c | 0 containers/posix/{libc2 => libc}/src/strcoll.c | 0 containers/posix/{libc2 => libc}/src/strcpy.c | 0 containers/posix/{libc2 => libc}/src/strcspn.c | 0 containers/posix/{libc2 => libc}/src/strdup.c | 0 containers/posix/{libc2 => libc}/src/strerror.c | 0 containers/posix/{libc2 => libc}/src/strftime.c | 0 containers/posix/{libc2 => libc}/src/strlen.c | 0 containers/posix/{libc2 => libc}/src/strncat.c | 0 containers/posix/{libc2 => libc}/src/strncmp.c | 0 containers/posix/{libc2 => libc}/src/strncpy.c | 0 containers/posix/{libc2 => libc}/src/strpbrk.c | 0 containers/posix/{libc2 => libc}/src/strrchr.c | 0 containers/posix/{libc2 => libc}/src/strspn.c | 0 containers/posix/{libc2 => libc}/src/strstr.c | 0 containers/posix/{libc2 => libc}/src/strtod.c | 0 containers/posix/{libc2 => libc}/src/strtok.c | 0 containers/posix/{libc2 => libc}/src/strtol.c | 0 containers/posix/{libc2 => libc}/src/strtoul.c | 0 .../arch-arm/plat-pb926/platform_init.c | 0 .../sys-baremetal/arch-arm/plat-pb926/sys_fputc.c | 0 .../src/sys-baremetal/arch-arm/sys_stdio.c | 0 .../arch-arm/plat-pb926/platform_init.c | 0 .../sys-userspace/arch-arm/plat-pb926/sys_fputc.c | 0 .../src/sys-userspace/arch-arm/sys_stdio.c | 0 containers/posix/{libc2 => libc}/src/system.c | 0 containers/posix/{libc2 => libc}/src/time.c | 0 containers/posix/{libc2 => libc}/src/tmpfile.c | 0 containers/posix/{libc2 => libc}/src/ungetc.c | 0 containers/posix/{libc2 => libc}/src/vfprintf.c | 0 containers/posix/{libc2 => libc}/src/vprintf.c | 0 containers/posix/{libc2 => libc}/src/vsnprintf.c | 0 containers/posix/libposix/include/posix/bits/sched.h | 6 +++--- containers/posix/libposix/include/posix/unistd.h | 6 ++++++ containers/posix/mm0/main.c | 2 +- containers/posix/mm0/src/file.c | 4 ++-- containers/posix/mm0/src/mmap.c | 4 ++-- containers/posix/mm0/src/pagers.c | 12 ++++++------ containers/posix/mm0/src/utcb.c | 2 +- containers/posix/test0/src/clonetest.c | 2 +- containers/posix/test0/src/dirtest.c | 2 +- containers/posix/test0/src/exectest.c | 2 +- containers/posix/test0/src/test_exec/test_exec.c | 2 +- 139 files changed, 42 insertions(+), 22 deletions(-) rename containers/posix/{libc2 => libc}/SConscript (100%) rename containers/posix/{libc2 => libc}/crt/sys-baremetal/arch-arm/crt0.S (100%) rename containers/posix/{libc2 => libc}/include/arch/arm/arch/inttypes.h (100%) rename containers/posix/{libc2 => libc}/include/arch/arm/arch/pl011_uart.h (100%) rename containers/posix/{libc2 => libc}/include/arch/arm/arch/setjmp.h (100%) rename containers/posix/{libc2 => libc}/include/arch/arm/arch/stdint.h (100%) rename containers/posix/{libc2 => libc}/include/assert.h (100%) rename containers/posix/{libc2 => libc}/include/complex.h (100%) rename containers/posix/{libc2 => libc}/include/ctype.h (100%) rename containers/posix/{libc2 => libc}/include/errno.h (97%) rename containers/posix/{libc2 => libc}/include/inttypes.h (100%) rename containers/posix/{libc2 => libc}/include/iso646.h (100%) rename containers/posix/{libc2 => libc}/include/limits.h (100%) rename containers/posix/{libc2 => libc}/include/locale.h (100%) rename containers/posix/{libc2 => libc}/include/setjmp.h (100%) rename containers/posix/{libc2 => libc}/include/stdarg.h (100%) rename containers/posix/{libc2 => libc}/include/stdbool.h (100%) rename containers/posix/{libc2 => libc}/include/stddef.h (99%) rename containers/posix/{libc2 => libc}/include/stdint.h (100%) rename containers/posix/{libc2 => libc}/include/stdio.h (99%) rename containers/posix/{libc2 => libc}/include/stdlib.h (100%) rename containers/posix/{libc2 => libc}/include/string.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/arch/inttypes.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/arch/pl011_uart.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/arch/setjmp.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/arch/stdint.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/inttypes.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/pl011_uart.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/setjmp.h (100%) rename containers/posix/{libc2 => libc}/include/sys-baremetal/arch-arm/stdint.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/arch/inttypes.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/arch/pl011_uart.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/arch/setjmp.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/arch/stdint.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/inttypes.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/pl011_uart.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/setjmp.h (100%) rename containers/posix/{libc2 => libc}/include/sys-userspace/arch-arm/stdint.h (100%) rename containers/posix/{libc2 => libc}/include/time.h (100%) rename containers/posix/{libc2 => libc}/src/arch-arm/eabi.c (100%) rename containers/posix/{libc2 => libc}/src/arch-arm/jmp.S (100%) rename containers/posix/{libc2 => libc}/src/asctime.c (100%) rename containers/posix/{libc2 => libc}/src/assert.c (100%) rename containers/posix/{libc2 => libc}/src/calloc.c (100%) rename containers/posix/{libc2 => libc}/src/clearerr.c (100%) rename containers/posix/{libc2 => libc}/src/clock.c (100%) rename containers/posix/{libc2 => libc}/src/ctype.c (100%) rename containers/posix/{libc2 => libc}/src/difftime.c (100%) rename containers/posix/{libc2 => libc}/src/errno.c (100%) rename containers/posix/{libc2 => libc}/src/exit.c (100%) rename containers/posix/{libc2 => libc}/src/fclose.c (100%) rename containers/posix/{libc2 => libc}/src/feof.c (100%) rename containers/posix/{libc2 => libc}/src/ferror.c (100%) rename containers/posix/{libc2 => libc}/src/fflush.c (100%) rename containers/posix/{libc2 => libc}/src/fgetc.c (100%) rename containers/posix/{libc2 => libc}/src/fgets.c (100%) rename containers/posix/{libc2 => libc}/src/format.c (100%) rename containers/posix/{libc2 => libc}/src/format.h (100%) rename containers/posix/{libc2 => libc}/src/fprintf.c (100%) rename containers/posix/{libc2 => libc}/src/fputc.c (100%) rename containers/posix/{libc2 => libc}/src/fputs.c (100%) rename containers/posix/{libc2 => libc}/src/fread.c (100%) rename containers/posix/{libc2 => libc}/src/fscanf.c (100%) rename containers/posix/{libc2 => libc}/src/fseek.c (100%) rename containers/posix/{libc2 => libc}/src/ftell.c (100%) rename containers/posix/{libc2 => libc}/src/fwrite.c (100%) rename containers/posix/{libc2 => libc}/src/getchar.c (100%) rename containers/posix/{libc2 => libc}/src/getenv.c (100%) rename containers/posix/{libc2 => libc}/src/gmtime.c (100%) rename containers/posix/{libc2 => libc}/src/k_r_malloc.h (100%) rename containers/posix/{libc2 => libc}/src/locale.c (100%) rename containers/posix/{libc2 => libc}/src/localtime.c (100%) rename containers/posix/{libc2 => libc}/src/malloc.c (100%) rename containers/posix/{libc2 => libc}/src/memchr.c (100%) rename containers/posix/{libc2 => libc}/src/memcmp.c (100%) rename containers/posix/{libc2 => libc}/src/memcpy.c (100%) rename containers/posix/{libc2 => libc}/src/memmove.c (100%) rename containers/posix/{libc2 => libc}/src/memset.c (100%) rename containers/posix/{libc2 => libc}/src/mktime.c (100%) rename containers/posix/{libc2 => libc}/src/perror.c (100%) rename containers/posix/{libc2 => libc}/src/printf.c (100%) rename containers/posix/{libc2 => libc}/src/putchar.c (100%) rename containers/posix/{libc2 => libc}/src/puts.c (100%) rename containers/posix/{libc2 => libc}/src/qsort.c (100%) rename containers/posix/{libc2 => libc}/src/rand.c (100%) rename containers/posix/{libc2 => libc}/src/realloc.c (100%) rename containers/posix/{libc2 => libc}/src/remove.c (100%) rename containers/posix/{libc2 => libc}/src/rename.c (100%) rename containers/posix/{libc2 => libc}/src/rewind.c (100%) rename containers/posix/{libc2 => libc}/src/snprintf.c (100%) rename containers/posix/{libc2 => libc}/src/sprintf.c (100%) rename containers/posix/{libc2 => libc}/src/srand.c (100%) rename containers/posix/{libc2 => libc}/src/strcat.c (100%) rename containers/posix/{libc2 => libc}/src/strchr.c (100%) rename containers/posix/{libc2 => libc}/src/strcmp.c (100%) rename containers/posix/{libc2 => libc}/src/strcoll.c (100%) rename containers/posix/{libc2 => libc}/src/strcpy.c (100%) rename containers/posix/{libc2 => libc}/src/strcspn.c (100%) rename containers/posix/{libc2 => libc}/src/strdup.c (100%) rename containers/posix/{libc2 => libc}/src/strerror.c (100%) rename containers/posix/{libc2 => libc}/src/strftime.c (100%) rename containers/posix/{libc2 => libc}/src/strlen.c (100%) rename containers/posix/{libc2 => libc}/src/strncat.c (100%) rename containers/posix/{libc2 => libc}/src/strncmp.c (100%) rename containers/posix/{libc2 => libc}/src/strncpy.c (100%) rename containers/posix/{libc2 => libc}/src/strpbrk.c (100%) rename containers/posix/{libc2 => libc}/src/strrchr.c (100%) rename containers/posix/{libc2 => libc}/src/strspn.c (100%) rename containers/posix/{libc2 => libc}/src/strstr.c (100%) rename containers/posix/{libc2 => libc}/src/strtod.c (100%) rename containers/posix/{libc2 => libc}/src/strtok.c (100%) rename containers/posix/{libc2 => libc}/src/strtol.c (100%) rename containers/posix/{libc2 => libc}/src/strtoul.c (100%) rename containers/posix/{libc2 => libc}/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c (100%) rename containers/posix/{libc2 => libc}/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c (100%) rename containers/posix/{libc2 => libc}/src/sys-baremetal/arch-arm/sys_stdio.c (100%) rename containers/posix/{libc2 => libc}/src/sys-userspace/arch-arm/plat-pb926/platform_init.c (100%) rename containers/posix/{libc2 => libc}/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c (100%) rename containers/posix/{libc2 => libc}/src/sys-userspace/arch-arm/sys_stdio.c (100%) rename containers/posix/{libc2 => libc}/src/system.c (100%) rename containers/posix/{libc2 => libc}/src/time.c (100%) rename containers/posix/{libc2 => libc}/src/tmpfile.c (100%) rename containers/posix/{libc2 => libc}/src/ungetc.c (100%) rename containers/posix/{libc2 => libc}/src/vfprintf.c (100%) rename containers/posix/{libc2 => libc}/src/vprintf.c (100%) rename containers/posix/{libc2 => libc}/src/vsnprintf.c (100%) diff --git a/containers/posix/fs0/main.c b/containers/posix/fs0/main.c index 7fc7475..b5b672b 100644 --- a/containers/posix/fs0/main.c +++ b/containers/posix/fs0/main.c @@ -122,7 +122,7 @@ void handle_fs_requests(void) default: printf("%s: Unrecognised ipc tag (%d) " "received from tid: %d. Ignoring.\n", __TASKNAME__, - mr[MR_TAG], sender); + mr[MR_TAG], senderid); } /* Reply */ diff --git a/containers/posix/fs0/src/memfs/memfs.c b/containers/posix/fs0/src/memfs/memfs.c index 95d957f..72bb764 100644 --- a/containers/posix/fs0/src/memfs/memfs.c +++ b/containers/posix/fs0/src/memfs/memfs.c @@ -192,7 +192,7 @@ struct superblock *memfs_get_superblock(void *block) return 0; } if (sb->magic != MEMFS_MAGIC) { - printf("%s: Magic number not match: %s\n", __FUNCTION__, sb->magic); + printf("%s: Magic number not match: %u\n", __FUNCTION__, sb->magic); return 0; } diff --git a/containers/posix/libc2/SConscript b/containers/posix/libc/SConscript similarity index 100% rename from containers/posix/libc2/SConscript rename to containers/posix/libc/SConscript diff --git a/containers/posix/libc2/crt/sys-baremetal/arch-arm/crt0.S b/containers/posix/libc/crt/sys-baremetal/arch-arm/crt0.S similarity index 100% rename from containers/posix/libc2/crt/sys-baremetal/arch-arm/crt0.S rename to containers/posix/libc/crt/sys-baremetal/arch-arm/crt0.S diff --git a/containers/posix/libc2/include/arch/arm/arch/inttypes.h b/containers/posix/libc/include/arch/arm/arch/inttypes.h similarity index 100% rename from containers/posix/libc2/include/arch/arm/arch/inttypes.h rename to containers/posix/libc/include/arch/arm/arch/inttypes.h diff --git a/containers/posix/libc2/include/arch/arm/arch/pl011_uart.h b/containers/posix/libc/include/arch/arm/arch/pl011_uart.h similarity index 100% rename from containers/posix/libc2/include/arch/arm/arch/pl011_uart.h rename to containers/posix/libc/include/arch/arm/arch/pl011_uart.h diff --git a/containers/posix/libc2/include/arch/arm/arch/setjmp.h b/containers/posix/libc/include/arch/arm/arch/setjmp.h similarity index 100% rename from containers/posix/libc2/include/arch/arm/arch/setjmp.h rename to containers/posix/libc/include/arch/arm/arch/setjmp.h diff --git a/containers/posix/libc2/include/arch/arm/arch/stdint.h b/containers/posix/libc/include/arch/arm/arch/stdint.h similarity index 100% rename from containers/posix/libc2/include/arch/arm/arch/stdint.h rename to containers/posix/libc/include/arch/arm/arch/stdint.h diff --git a/containers/posix/libc2/include/assert.h b/containers/posix/libc/include/assert.h similarity index 100% rename from containers/posix/libc2/include/assert.h rename to containers/posix/libc/include/assert.h diff --git a/containers/posix/libc2/include/complex.h b/containers/posix/libc/include/complex.h similarity index 100% rename from containers/posix/libc2/include/complex.h rename to containers/posix/libc/include/complex.h diff --git a/containers/posix/libc2/include/ctype.h b/containers/posix/libc/include/ctype.h similarity index 100% rename from containers/posix/libc2/include/ctype.h rename to containers/posix/libc/include/ctype.h diff --git a/containers/posix/libc2/include/errno.h b/containers/posix/libc/include/errno.h similarity index 97% rename from containers/posix/libc2/include/errno.h rename to containers/posix/libc/include/errno.h index 4b4db9a..12698e7 100644 --- a/containers/posix/libc2/include/errno.h +++ b/containers/posix/libc/include/errno.h @@ -88,11 +88,17 @@ #ifndef _ERRNO_H_ #define _ERRNO_H_ +#ifndef EDOM #define EDOM 1 +#endif +#ifndef EILSEQ #define EILSEQ 2 +#endif +#ifndef ERANGE #define ERANGE 3 +#endif -#include +//#include #ifndef THREAD_SAFE extern int errno; diff --git a/containers/posix/libc2/include/inttypes.h b/containers/posix/libc/include/inttypes.h similarity index 100% rename from containers/posix/libc2/include/inttypes.h rename to containers/posix/libc/include/inttypes.h diff --git a/containers/posix/libc2/include/iso646.h b/containers/posix/libc/include/iso646.h similarity index 100% rename from containers/posix/libc2/include/iso646.h rename to containers/posix/libc/include/iso646.h diff --git a/containers/posix/libc2/include/limits.h b/containers/posix/libc/include/limits.h similarity index 100% rename from containers/posix/libc2/include/limits.h rename to containers/posix/libc/include/limits.h diff --git a/containers/posix/libc2/include/locale.h b/containers/posix/libc/include/locale.h similarity index 100% rename from containers/posix/libc2/include/locale.h rename to containers/posix/libc/include/locale.h diff --git a/containers/posix/libc2/include/setjmp.h b/containers/posix/libc/include/setjmp.h similarity index 100% rename from containers/posix/libc2/include/setjmp.h rename to containers/posix/libc/include/setjmp.h diff --git a/containers/posix/libc2/include/stdarg.h b/containers/posix/libc/include/stdarg.h similarity index 100% rename from containers/posix/libc2/include/stdarg.h rename to containers/posix/libc/include/stdarg.h diff --git a/containers/posix/libc2/include/stdbool.h b/containers/posix/libc/include/stdbool.h similarity index 100% rename from containers/posix/libc2/include/stdbool.h rename to containers/posix/libc/include/stdbool.h diff --git a/containers/posix/libc2/include/stddef.h b/containers/posix/libc/include/stddef.h similarity index 99% rename from containers/posix/libc2/include/stddef.h rename to containers/posix/libc/include/stddef.h index 99a5f12..1eaa096 100644 --- a/containers/posix/libc2/include/stddef.h +++ b/containers/posix/libc/include/stddef.h @@ -111,7 +111,9 @@ typedef __SIZE_TYPE__ size_t; things such as varargs and printf */ typedef __WCHAR_TYPE__ wchar_t; #endif +#ifndef NULL #define NULL ((void *)0) +#endif #define offsetof(type, member) ((size_t) &((type *)0)->member) #endif /* _STDDEF_H_ */ diff --git a/containers/posix/libc2/include/stdint.h b/containers/posix/libc/include/stdint.h similarity index 100% rename from containers/posix/libc2/include/stdint.h rename to containers/posix/libc/include/stdint.h diff --git a/containers/posix/libc2/include/stdio.h b/containers/posix/libc/include/stdio.h similarity index 99% rename from containers/posix/libc2/include/stdio.h rename to containers/posix/libc/include/stdio.h index 374a87f..bbca2a9 100644 --- a/containers/posix/libc2/include/stdio.h +++ b/containers/posix/libc/include/stdio.h @@ -136,9 +136,15 @@ typedef long fpos_t; /* same */ #define FILENAME_MAX 37 #define L_tmpnam 37 +#ifndef SEEK_CUR #define SEEK_CUR 0 +#endif +#ifndef SEEK_END #define SEEK_END 1 +#endif +#ifndef SEEK_SET #define SEEK_SET 2 +#endif #define TMP_MAX 37 diff --git a/containers/posix/libc2/include/stdlib.h b/containers/posix/libc/include/stdlib.h similarity index 100% rename from containers/posix/libc2/include/stdlib.h rename to containers/posix/libc/include/stdlib.h diff --git a/containers/posix/libc2/include/string.h b/containers/posix/libc/include/string.h similarity index 100% rename from containers/posix/libc2/include/string.h rename to containers/posix/libc/include/string.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/inttypes.h b/containers/posix/libc/include/sys-baremetal/arch-arm/arch/inttypes.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/arch/inttypes.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/arch/inttypes.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/pl011_uart.h b/containers/posix/libc/include/sys-baremetal/arch-arm/arch/pl011_uart.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/arch/pl011_uart.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/arch/pl011_uart.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/setjmp.h b/containers/posix/libc/include/sys-baremetal/arch-arm/arch/setjmp.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/arch/setjmp.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/arch/setjmp.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/arch/stdint.h b/containers/posix/libc/include/sys-baremetal/arch-arm/arch/stdint.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/arch/stdint.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/arch/stdint.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/inttypes.h b/containers/posix/libc/include/sys-baremetal/arch-arm/inttypes.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/inttypes.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/inttypes.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/pl011_uart.h b/containers/posix/libc/include/sys-baremetal/arch-arm/pl011_uart.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/pl011_uart.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/pl011_uart.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/setjmp.h b/containers/posix/libc/include/sys-baremetal/arch-arm/setjmp.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/setjmp.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/setjmp.h diff --git a/containers/posix/libc2/include/sys-baremetal/arch-arm/stdint.h b/containers/posix/libc/include/sys-baremetal/arch-arm/stdint.h similarity index 100% rename from containers/posix/libc2/include/sys-baremetal/arch-arm/stdint.h rename to containers/posix/libc/include/sys-baremetal/arch-arm/stdint.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/inttypes.h b/containers/posix/libc/include/sys-userspace/arch-arm/arch/inttypes.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/arch/inttypes.h rename to containers/posix/libc/include/sys-userspace/arch-arm/arch/inttypes.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/pl011_uart.h b/containers/posix/libc/include/sys-userspace/arch-arm/arch/pl011_uart.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/arch/pl011_uart.h rename to containers/posix/libc/include/sys-userspace/arch-arm/arch/pl011_uart.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/setjmp.h b/containers/posix/libc/include/sys-userspace/arch-arm/arch/setjmp.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/arch/setjmp.h rename to containers/posix/libc/include/sys-userspace/arch-arm/arch/setjmp.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/arch/stdint.h b/containers/posix/libc/include/sys-userspace/arch-arm/arch/stdint.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/arch/stdint.h rename to containers/posix/libc/include/sys-userspace/arch-arm/arch/stdint.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/inttypes.h b/containers/posix/libc/include/sys-userspace/arch-arm/inttypes.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/inttypes.h rename to containers/posix/libc/include/sys-userspace/arch-arm/inttypes.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/pl011_uart.h b/containers/posix/libc/include/sys-userspace/arch-arm/pl011_uart.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/pl011_uart.h rename to containers/posix/libc/include/sys-userspace/arch-arm/pl011_uart.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/setjmp.h b/containers/posix/libc/include/sys-userspace/arch-arm/setjmp.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/setjmp.h rename to containers/posix/libc/include/sys-userspace/arch-arm/setjmp.h diff --git a/containers/posix/libc2/include/sys-userspace/arch-arm/stdint.h b/containers/posix/libc/include/sys-userspace/arch-arm/stdint.h similarity index 100% rename from containers/posix/libc2/include/sys-userspace/arch-arm/stdint.h rename to containers/posix/libc/include/sys-userspace/arch-arm/stdint.h diff --git a/containers/posix/libc2/include/time.h b/containers/posix/libc/include/time.h similarity index 100% rename from containers/posix/libc2/include/time.h rename to containers/posix/libc/include/time.h diff --git a/containers/posix/libc2/src/arch-arm/eabi.c b/containers/posix/libc/src/arch-arm/eabi.c similarity index 100% rename from containers/posix/libc2/src/arch-arm/eabi.c rename to containers/posix/libc/src/arch-arm/eabi.c diff --git a/containers/posix/libc2/src/arch-arm/jmp.S b/containers/posix/libc/src/arch-arm/jmp.S similarity index 100% rename from containers/posix/libc2/src/arch-arm/jmp.S rename to containers/posix/libc/src/arch-arm/jmp.S diff --git a/containers/posix/libc2/src/asctime.c b/containers/posix/libc/src/asctime.c similarity index 100% rename from containers/posix/libc2/src/asctime.c rename to containers/posix/libc/src/asctime.c diff --git a/containers/posix/libc2/src/assert.c b/containers/posix/libc/src/assert.c similarity index 100% rename from containers/posix/libc2/src/assert.c rename to containers/posix/libc/src/assert.c diff --git a/containers/posix/libc2/src/calloc.c b/containers/posix/libc/src/calloc.c similarity index 100% rename from containers/posix/libc2/src/calloc.c rename to containers/posix/libc/src/calloc.c diff --git a/containers/posix/libc2/src/clearerr.c b/containers/posix/libc/src/clearerr.c similarity index 100% rename from containers/posix/libc2/src/clearerr.c rename to containers/posix/libc/src/clearerr.c diff --git a/containers/posix/libc2/src/clock.c b/containers/posix/libc/src/clock.c similarity index 100% rename from containers/posix/libc2/src/clock.c rename to containers/posix/libc/src/clock.c diff --git a/containers/posix/libc2/src/ctype.c b/containers/posix/libc/src/ctype.c similarity index 100% rename from containers/posix/libc2/src/ctype.c rename to containers/posix/libc/src/ctype.c diff --git a/containers/posix/libc2/src/difftime.c b/containers/posix/libc/src/difftime.c similarity index 100% rename from containers/posix/libc2/src/difftime.c rename to containers/posix/libc/src/difftime.c diff --git a/containers/posix/libc2/src/errno.c b/containers/posix/libc/src/errno.c similarity index 100% rename from containers/posix/libc2/src/errno.c rename to containers/posix/libc/src/errno.c diff --git a/containers/posix/libc2/src/exit.c b/containers/posix/libc/src/exit.c similarity index 100% rename from containers/posix/libc2/src/exit.c rename to containers/posix/libc/src/exit.c diff --git a/containers/posix/libc2/src/fclose.c b/containers/posix/libc/src/fclose.c similarity index 100% rename from containers/posix/libc2/src/fclose.c rename to containers/posix/libc/src/fclose.c diff --git a/containers/posix/libc2/src/feof.c b/containers/posix/libc/src/feof.c similarity index 100% rename from containers/posix/libc2/src/feof.c rename to containers/posix/libc/src/feof.c diff --git a/containers/posix/libc2/src/ferror.c b/containers/posix/libc/src/ferror.c similarity index 100% rename from containers/posix/libc2/src/ferror.c rename to containers/posix/libc/src/ferror.c diff --git a/containers/posix/libc2/src/fflush.c b/containers/posix/libc/src/fflush.c similarity index 100% rename from containers/posix/libc2/src/fflush.c rename to containers/posix/libc/src/fflush.c diff --git a/containers/posix/libc2/src/fgetc.c b/containers/posix/libc/src/fgetc.c similarity index 100% rename from containers/posix/libc2/src/fgetc.c rename to containers/posix/libc/src/fgetc.c diff --git a/containers/posix/libc2/src/fgets.c b/containers/posix/libc/src/fgets.c similarity index 100% rename from containers/posix/libc2/src/fgets.c rename to containers/posix/libc/src/fgets.c diff --git a/containers/posix/libc2/src/format.c b/containers/posix/libc/src/format.c similarity index 100% rename from containers/posix/libc2/src/format.c rename to containers/posix/libc/src/format.c diff --git a/containers/posix/libc2/src/format.h b/containers/posix/libc/src/format.h similarity index 100% rename from containers/posix/libc2/src/format.h rename to containers/posix/libc/src/format.h diff --git a/containers/posix/libc2/src/fprintf.c b/containers/posix/libc/src/fprintf.c similarity index 100% rename from containers/posix/libc2/src/fprintf.c rename to containers/posix/libc/src/fprintf.c diff --git a/containers/posix/libc2/src/fputc.c b/containers/posix/libc/src/fputc.c similarity index 100% rename from containers/posix/libc2/src/fputc.c rename to containers/posix/libc/src/fputc.c diff --git a/containers/posix/libc2/src/fputs.c b/containers/posix/libc/src/fputs.c similarity index 100% rename from containers/posix/libc2/src/fputs.c rename to containers/posix/libc/src/fputs.c diff --git a/containers/posix/libc2/src/fread.c b/containers/posix/libc/src/fread.c similarity index 100% rename from containers/posix/libc2/src/fread.c rename to containers/posix/libc/src/fread.c diff --git a/containers/posix/libc2/src/fscanf.c b/containers/posix/libc/src/fscanf.c similarity index 100% rename from containers/posix/libc2/src/fscanf.c rename to containers/posix/libc/src/fscanf.c diff --git a/containers/posix/libc2/src/fseek.c b/containers/posix/libc/src/fseek.c similarity index 100% rename from containers/posix/libc2/src/fseek.c rename to containers/posix/libc/src/fseek.c diff --git a/containers/posix/libc2/src/ftell.c b/containers/posix/libc/src/ftell.c similarity index 100% rename from containers/posix/libc2/src/ftell.c rename to containers/posix/libc/src/ftell.c diff --git a/containers/posix/libc2/src/fwrite.c b/containers/posix/libc/src/fwrite.c similarity index 100% rename from containers/posix/libc2/src/fwrite.c rename to containers/posix/libc/src/fwrite.c diff --git a/containers/posix/libc2/src/getchar.c b/containers/posix/libc/src/getchar.c similarity index 100% rename from containers/posix/libc2/src/getchar.c rename to containers/posix/libc/src/getchar.c diff --git a/containers/posix/libc2/src/getenv.c b/containers/posix/libc/src/getenv.c similarity index 100% rename from containers/posix/libc2/src/getenv.c rename to containers/posix/libc/src/getenv.c diff --git a/containers/posix/libc2/src/gmtime.c b/containers/posix/libc/src/gmtime.c similarity index 100% rename from containers/posix/libc2/src/gmtime.c rename to containers/posix/libc/src/gmtime.c diff --git a/containers/posix/libc2/src/k_r_malloc.h b/containers/posix/libc/src/k_r_malloc.h similarity index 100% rename from containers/posix/libc2/src/k_r_malloc.h rename to containers/posix/libc/src/k_r_malloc.h diff --git a/containers/posix/libc2/src/locale.c b/containers/posix/libc/src/locale.c similarity index 100% rename from containers/posix/libc2/src/locale.c rename to containers/posix/libc/src/locale.c diff --git a/containers/posix/libc2/src/localtime.c b/containers/posix/libc/src/localtime.c similarity index 100% rename from containers/posix/libc2/src/localtime.c rename to containers/posix/libc/src/localtime.c diff --git a/containers/posix/libc2/src/malloc.c b/containers/posix/libc/src/malloc.c similarity index 100% rename from containers/posix/libc2/src/malloc.c rename to containers/posix/libc/src/malloc.c diff --git a/containers/posix/libc2/src/memchr.c b/containers/posix/libc/src/memchr.c similarity index 100% rename from containers/posix/libc2/src/memchr.c rename to containers/posix/libc/src/memchr.c diff --git a/containers/posix/libc2/src/memcmp.c b/containers/posix/libc/src/memcmp.c similarity index 100% rename from containers/posix/libc2/src/memcmp.c rename to containers/posix/libc/src/memcmp.c diff --git a/containers/posix/libc2/src/memcpy.c b/containers/posix/libc/src/memcpy.c similarity index 100% rename from containers/posix/libc2/src/memcpy.c rename to containers/posix/libc/src/memcpy.c diff --git a/containers/posix/libc2/src/memmove.c b/containers/posix/libc/src/memmove.c similarity index 100% rename from containers/posix/libc2/src/memmove.c rename to containers/posix/libc/src/memmove.c diff --git a/containers/posix/libc2/src/memset.c b/containers/posix/libc/src/memset.c similarity index 100% rename from containers/posix/libc2/src/memset.c rename to containers/posix/libc/src/memset.c diff --git a/containers/posix/libc2/src/mktime.c b/containers/posix/libc/src/mktime.c similarity index 100% rename from containers/posix/libc2/src/mktime.c rename to containers/posix/libc/src/mktime.c diff --git a/containers/posix/libc2/src/perror.c b/containers/posix/libc/src/perror.c similarity index 100% rename from containers/posix/libc2/src/perror.c rename to containers/posix/libc/src/perror.c diff --git a/containers/posix/libc2/src/printf.c b/containers/posix/libc/src/printf.c similarity index 100% rename from containers/posix/libc2/src/printf.c rename to containers/posix/libc/src/printf.c diff --git a/containers/posix/libc2/src/putchar.c b/containers/posix/libc/src/putchar.c similarity index 100% rename from containers/posix/libc2/src/putchar.c rename to containers/posix/libc/src/putchar.c diff --git a/containers/posix/libc2/src/puts.c b/containers/posix/libc/src/puts.c similarity index 100% rename from containers/posix/libc2/src/puts.c rename to containers/posix/libc/src/puts.c diff --git a/containers/posix/libc2/src/qsort.c b/containers/posix/libc/src/qsort.c similarity index 100% rename from containers/posix/libc2/src/qsort.c rename to containers/posix/libc/src/qsort.c diff --git a/containers/posix/libc2/src/rand.c b/containers/posix/libc/src/rand.c similarity index 100% rename from containers/posix/libc2/src/rand.c rename to containers/posix/libc/src/rand.c diff --git a/containers/posix/libc2/src/realloc.c b/containers/posix/libc/src/realloc.c similarity index 100% rename from containers/posix/libc2/src/realloc.c rename to containers/posix/libc/src/realloc.c diff --git a/containers/posix/libc2/src/remove.c b/containers/posix/libc/src/remove.c similarity index 100% rename from containers/posix/libc2/src/remove.c rename to containers/posix/libc/src/remove.c diff --git a/containers/posix/libc2/src/rename.c b/containers/posix/libc/src/rename.c similarity index 100% rename from containers/posix/libc2/src/rename.c rename to containers/posix/libc/src/rename.c diff --git a/containers/posix/libc2/src/rewind.c b/containers/posix/libc/src/rewind.c similarity index 100% rename from containers/posix/libc2/src/rewind.c rename to containers/posix/libc/src/rewind.c diff --git a/containers/posix/libc2/src/snprintf.c b/containers/posix/libc/src/snprintf.c similarity index 100% rename from containers/posix/libc2/src/snprintf.c rename to containers/posix/libc/src/snprintf.c diff --git a/containers/posix/libc2/src/sprintf.c b/containers/posix/libc/src/sprintf.c similarity index 100% rename from containers/posix/libc2/src/sprintf.c rename to containers/posix/libc/src/sprintf.c diff --git a/containers/posix/libc2/src/srand.c b/containers/posix/libc/src/srand.c similarity index 100% rename from containers/posix/libc2/src/srand.c rename to containers/posix/libc/src/srand.c diff --git a/containers/posix/libc2/src/strcat.c b/containers/posix/libc/src/strcat.c similarity index 100% rename from containers/posix/libc2/src/strcat.c rename to containers/posix/libc/src/strcat.c diff --git a/containers/posix/libc2/src/strchr.c b/containers/posix/libc/src/strchr.c similarity index 100% rename from containers/posix/libc2/src/strchr.c rename to containers/posix/libc/src/strchr.c diff --git a/containers/posix/libc2/src/strcmp.c b/containers/posix/libc/src/strcmp.c similarity index 100% rename from containers/posix/libc2/src/strcmp.c rename to containers/posix/libc/src/strcmp.c diff --git a/containers/posix/libc2/src/strcoll.c b/containers/posix/libc/src/strcoll.c similarity index 100% rename from containers/posix/libc2/src/strcoll.c rename to containers/posix/libc/src/strcoll.c diff --git a/containers/posix/libc2/src/strcpy.c b/containers/posix/libc/src/strcpy.c similarity index 100% rename from containers/posix/libc2/src/strcpy.c rename to containers/posix/libc/src/strcpy.c diff --git a/containers/posix/libc2/src/strcspn.c b/containers/posix/libc/src/strcspn.c similarity index 100% rename from containers/posix/libc2/src/strcspn.c rename to containers/posix/libc/src/strcspn.c diff --git a/containers/posix/libc2/src/strdup.c b/containers/posix/libc/src/strdup.c similarity index 100% rename from containers/posix/libc2/src/strdup.c rename to containers/posix/libc/src/strdup.c diff --git a/containers/posix/libc2/src/strerror.c b/containers/posix/libc/src/strerror.c similarity index 100% rename from containers/posix/libc2/src/strerror.c rename to containers/posix/libc/src/strerror.c diff --git a/containers/posix/libc2/src/strftime.c b/containers/posix/libc/src/strftime.c similarity index 100% rename from containers/posix/libc2/src/strftime.c rename to containers/posix/libc/src/strftime.c diff --git a/containers/posix/libc2/src/strlen.c b/containers/posix/libc/src/strlen.c similarity index 100% rename from containers/posix/libc2/src/strlen.c rename to containers/posix/libc/src/strlen.c diff --git a/containers/posix/libc2/src/strncat.c b/containers/posix/libc/src/strncat.c similarity index 100% rename from containers/posix/libc2/src/strncat.c rename to containers/posix/libc/src/strncat.c diff --git a/containers/posix/libc2/src/strncmp.c b/containers/posix/libc/src/strncmp.c similarity index 100% rename from containers/posix/libc2/src/strncmp.c rename to containers/posix/libc/src/strncmp.c diff --git a/containers/posix/libc2/src/strncpy.c b/containers/posix/libc/src/strncpy.c similarity index 100% rename from containers/posix/libc2/src/strncpy.c rename to containers/posix/libc/src/strncpy.c diff --git a/containers/posix/libc2/src/strpbrk.c b/containers/posix/libc/src/strpbrk.c similarity index 100% rename from containers/posix/libc2/src/strpbrk.c rename to containers/posix/libc/src/strpbrk.c diff --git a/containers/posix/libc2/src/strrchr.c b/containers/posix/libc/src/strrchr.c similarity index 100% rename from containers/posix/libc2/src/strrchr.c rename to containers/posix/libc/src/strrchr.c diff --git a/containers/posix/libc2/src/strspn.c b/containers/posix/libc/src/strspn.c similarity index 100% rename from containers/posix/libc2/src/strspn.c rename to containers/posix/libc/src/strspn.c diff --git a/containers/posix/libc2/src/strstr.c b/containers/posix/libc/src/strstr.c similarity index 100% rename from containers/posix/libc2/src/strstr.c rename to containers/posix/libc/src/strstr.c diff --git a/containers/posix/libc2/src/strtod.c b/containers/posix/libc/src/strtod.c similarity index 100% rename from containers/posix/libc2/src/strtod.c rename to containers/posix/libc/src/strtod.c diff --git a/containers/posix/libc2/src/strtok.c b/containers/posix/libc/src/strtok.c similarity index 100% rename from containers/posix/libc2/src/strtok.c rename to containers/posix/libc/src/strtok.c diff --git a/containers/posix/libc2/src/strtol.c b/containers/posix/libc/src/strtol.c similarity index 100% rename from containers/posix/libc2/src/strtol.c rename to containers/posix/libc/src/strtol.c diff --git a/containers/posix/libc2/src/strtoul.c b/containers/posix/libc/src/strtoul.c similarity index 100% rename from containers/posix/libc2/src/strtoul.c rename to containers/posix/libc/src/strtoul.c diff --git a/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c b/containers/posix/libc/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c similarity index 100% rename from containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c rename to containers/posix/libc/src/sys-baremetal/arch-arm/plat-pb926/platform_init.c diff --git a/containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c b/containers/posix/libc/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c similarity index 100% rename from containers/posix/libc2/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c rename to containers/posix/libc/src/sys-baremetal/arch-arm/plat-pb926/sys_fputc.c diff --git a/containers/posix/libc2/src/sys-baremetal/arch-arm/sys_stdio.c b/containers/posix/libc/src/sys-baremetal/arch-arm/sys_stdio.c similarity index 100% rename from containers/posix/libc2/src/sys-baremetal/arch-arm/sys_stdio.c rename to containers/posix/libc/src/sys-baremetal/arch-arm/sys_stdio.c diff --git a/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/platform_init.c b/containers/posix/libc/src/sys-userspace/arch-arm/plat-pb926/platform_init.c similarity index 100% rename from containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/platform_init.c rename to containers/posix/libc/src/sys-userspace/arch-arm/plat-pb926/platform_init.c diff --git a/containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c b/containers/posix/libc/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c similarity index 100% rename from containers/posix/libc2/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c rename to containers/posix/libc/src/sys-userspace/arch-arm/plat-pb926/sys_fputc.c diff --git a/containers/posix/libc2/src/sys-userspace/arch-arm/sys_stdio.c b/containers/posix/libc/src/sys-userspace/arch-arm/sys_stdio.c similarity index 100% rename from containers/posix/libc2/src/sys-userspace/arch-arm/sys_stdio.c rename to containers/posix/libc/src/sys-userspace/arch-arm/sys_stdio.c diff --git a/containers/posix/libc2/src/system.c b/containers/posix/libc/src/system.c similarity index 100% rename from containers/posix/libc2/src/system.c rename to containers/posix/libc/src/system.c diff --git a/containers/posix/libc2/src/time.c b/containers/posix/libc/src/time.c similarity index 100% rename from containers/posix/libc2/src/time.c rename to containers/posix/libc/src/time.c diff --git a/containers/posix/libc2/src/tmpfile.c b/containers/posix/libc/src/tmpfile.c similarity index 100% rename from containers/posix/libc2/src/tmpfile.c rename to containers/posix/libc/src/tmpfile.c diff --git a/containers/posix/libc2/src/ungetc.c b/containers/posix/libc/src/ungetc.c similarity index 100% rename from containers/posix/libc2/src/ungetc.c rename to containers/posix/libc/src/ungetc.c diff --git a/containers/posix/libc2/src/vfprintf.c b/containers/posix/libc/src/vfprintf.c similarity index 100% rename from containers/posix/libc2/src/vfprintf.c rename to containers/posix/libc/src/vfprintf.c diff --git a/containers/posix/libc2/src/vprintf.c b/containers/posix/libc/src/vprintf.c similarity index 100% rename from containers/posix/libc2/src/vprintf.c rename to containers/posix/libc/src/vprintf.c diff --git a/containers/posix/libc2/src/vsnprintf.c b/containers/posix/libc/src/vsnprintf.c similarity index 100% rename from containers/posix/libc2/src/vsnprintf.c rename to containers/posix/libc/src/vsnprintf.c diff --git a/containers/posix/libposix/include/posix/bits/sched.h b/containers/posix/libposix/include/posix/bits/sched.h index b48a0c8..a174960 100644 --- a/containers/posix/libposix/include/posix/bits/sched.h +++ b/containers/posix/libposix/include/posix/bits/sched.h @@ -20,9 +20,9 @@ #ifndef __need_schedparam -#ifndef _SCHED_H -# error "Never include directly; use instead." -#endif +//#ifndef _SCHED_H +//# error "Never include directly; use instead." +//#endif /* Scheduling algorithms. */ diff --git a/containers/posix/libposix/include/posix/unistd.h b/containers/posix/libposix/include/posix/unistd.h index 7590640..94d2fd8 100644 --- a/containers/posix/libposix/include/posix/unistd.h +++ b/containers/posix/libposix/include/posix/unistd.h @@ -277,10 +277,16 @@ extern int faccessat (int __fd, __const char *__file, int __type, int __flag) /* Values for the WHENCE argument to lseek. */ #ifndef _STDIO_H /* has the same definitions. */ +#ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ +#endif +#ifndef SEEK_CUR # define SEEK_CUR 1 /* Seek from current position. */ +#endif +#ifndef SEEK_END # define SEEK_END 2 /* Seek from end of file. */ #endif +#endif #if defined __USE_BSD && !defined L_SET /* Old BSD names for the same constants; just for compatibility. */ diff --git a/containers/posix/mm0/main.c b/containers/posix/mm0/main.c index fe32503..1e29ab9 100644 --- a/containers/posix/mm0/main.c +++ b/containers/posix/mm0/main.c @@ -170,7 +170,7 @@ void handle_requests(void) printf("%s: Unrecognised ipc tag (%d) " "received from (%d). Full mr reading: " "%u, %u, %u, %u, %u, %u. Ignoring.\n", - __TASKNAME__, tag, sender, read_mr(0), + __TASKNAME__, tag, senderid, read_mr(0), read_mr(1), read_mr(2), read_mr(3), read_mr(4), read_mr(5)); } diff --git a/containers/posix/mm0/src/file.c b/containers/posix/mm0/src/file.c index 0b8f0d5..5e5b91d 100644 --- a/containers/posix/mm0/src/file.c +++ b/containers/posix/mm0/src/file.c @@ -348,7 +348,7 @@ int read_file_pages(struct vm_file *vmfile, unsigned long pfn_start, f_offset); if (IS_ERR(page)) { printf("%s: %s:Could not read page %d " - "from file with vnum: 0x%x\n", __TASKNAME__, + "from file with vnum: 0x%lu\n", __TASKNAME__, __FUNCTION__, f_offset, vm_file_to_vnum(vmfile)); return (int)page; } @@ -460,7 +460,7 @@ int write_file_pages(struct vm_file *f, unsigned long pfn_start, err = f->vm_obj.pager->ops.page_out(&f->vm_obj, f_offset); if (err < 0) { printf("%s: %s:Could not write page %d " - "to file with vnum: 0x%x\n", __TASKNAME__, + "to file with vnum: 0x%lu\n", __TASKNAME__, __FUNCTION__, f_offset, vm_file_to_vnum(f)); return err; } diff --git a/containers/posix/mm0/src/mmap.c b/containers/posix/mm0/src/mmap.c index 5acb0e4..857385c 100644 --- a/containers/posix/mm0/src/mmap.c +++ b/containers/posix/mm0/src/mmap.c @@ -239,8 +239,8 @@ void *do_mmap(struct vm_file *mapfile, unsigned long file_offset, /* Get total file pages, check if mapping is within file size */ file_npages = __pfn(page_align_up(mapfile->length)); if (npages > file_npages - file_offset) { - printf("%s: Trying to map %d pages from page %d, " - "but file length is %d\n", __FUNCTION__, + printf("%s: Trying to map %d pages from page %lu, " + "but file length is %lu\n", __FUNCTION__, npages, file_offset, file_npages); return PTR_ERR(-EINVAL); } diff --git a/containers/posix/mm0/src/pagers.c b/containers/posix/mm0/src/pagers.c index ed3512f..fd46d59 100644 --- a/containers/posix/mm0/src/pagers.c +++ b/containers/posix/mm0/src/pagers.c @@ -71,8 +71,8 @@ int file_page_out(struct vm_object *vm_obj, unsigned long page_offset) /* Check first if the file has such a page at all */ if (__pfn(page_align_up(f->length) <= page_offset)) { - printf("%s: %s: Trying to look up page %d, but file length " - "is %d bytes.\n", __TASKNAME__, __FUNCTION__, + printf("%s: %s: Trying to look up page %lu, but file length " + "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, page_offset, f->length); BUG(); } @@ -123,8 +123,8 @@ struct page *file_page_in(struct vm_object *vm_obj, unsigned long page_offset) /* Check first if the file has such a page at all */ if (__pfn(page_align_up(f->length) <= page_offset)) { - printf("%s: %s: Trying to look up page %d, but file length " - "is %d bytes.\n", __TASKNAME__, __FUNCTION__, + printf("%s: %s: Trying to look up page %lu, but file length " + "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, page_offset, f->length); BUG(); } @@ -253,8 +253,8 @@ struct page *bootfile_page_in(struct vm_object *vm_obj, /* Check first if the file has such a page at all */ if (__pfn(page_align_up(boot_file->length) <= offset)) { - printf("%s: %s: Trying to look up page %d, but file length " - "is %d bytes.\n", __TASKNAME__, __FUNCTION__, + printf("%s: %s: Trying to look up page %lu, but file length " + "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, offset, boot_file->length); BUG(); } diff --git a/containers/posix/mm0/src/utcb.c b/containers/posix/mm0/src/utcb.c index 6add67c..3e7c814 100644 --- a/containers/posix/mm0/src/utcb.c +++ b/containers/posix/mm0/src/utcb.c @@ -140,7 +140,7 @@ out: if (IS_ERR(err = do_mmap(0, 0, task, slot, VMA_ANONYMOUS | VMA_PRIVATE | VMA_FIXED | VM_READ | VM_WRITE, 1))) { - printf("UTCB: mmapping failed with %d\n", err); + printf("UTCB: mmapping failed with %d\n", (int)err); return (int)err; } } diff --git a/containers/posix/test0/src/clonetest.c b/containers/posix/test0/src/clonetest.c index a0f50d2..093b7e4 100644 --- a/containers/posix/test0/src/clonetest.c +++ b/containers/posix/test0/src/clonetest.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/containers/posix/test0/src/dirtest.c b/containers/posix/test0/src/dirtest.c index a091248..5eb8130 100644 --- a/containers/posix/test0/src/dirtest.c +++ b/containers/posix/test0/src/dirtest.c @@ -16,7 +16,7 @@ void print_fsize(struct stat *s) { - printf("%d", s->st_size); + printf("%lu", s->st_size); } void print_flink(struct stat *s) diff --git a/containers/posix/test0/src/exectest.c b/containers/posix/test0/src/exectest.c index 9b9d945..5fba722 100644 --- a/containers/posix/test0/src/exectest.c +++ b/containers/posix/test0/src/exectest.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include extern char _start_test_exec[]; extern char _end_test_exec[]; diff --git a/containers/posix/test0/src/test_exec/test_exec.c b/containers/posix/test0/src/test_exec/test_exec.c index b1287b7..5e40cb5 100644 --- a/containers/posix/test0/src/test_exec/test_exec.c +++ b/containers/posix/test0/src/test_exec/test_exec.c @@ -26,7 +26,7 @@ void main(void) { wait_pager(0); if (getpid() == 2) { - printf("EXECVE TEST -- PASSED --\n", getpid()); + printf("EXECVE TEST -- PASSED --\n"); printf("\nThread (%d): Continues to sync with the pager...\n\n", getpid()); while (1) wait_pager(0); From b12102be2d8c13581111eeaac79aef28d4b9b841 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 29 Aug 2009 18:02:42 +0300 Subject: [PATCH 6/9] arm.cml looking better --- configs/arm.cml | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/configs/arm.cml b/configs/arm.cml index c592241..aa58d3a 100644 --- a/configs/arm.cml +++ b/configs/arm.cml @@ -5,74 +5,93 @@ start main_menu ############# symbols -DUMMY 'DUMMY' ARCH_ARM 'ARM' -ARCH_TEST 'TEST' arm_cpu_type 'ARM Processor Type' -ARM_CPU_ARM920T 'ARM920T Not supported yet' -ARM_CPU_ARM925 'ARM925 Not supported yet' +ARM_CPU_ARM1136 'ARM1136 - To be added' +ARM_CPU_ARM11MPCore 'ARM11 MPCore - To be added' ARM_CPU_ARM926 'ARM926EJ-S' +ARM_CPU_CORTEXA8 'ARM Cortex-A8 - Not supported' arm_subarch_type 'ARM Architecture Family' -ARM_SUBARCH_V5 'ARM V5 Architecture' -ARM_SUBARCH_V6 'ARM V6 Architecture, Unsupported yet' +ARM_SUBARCH_V5 'ARM v5 Architecture' +ARM_SUBARCH_V6 'ARM v6 Architecture, To be added' +ARM_SUBARCH_V7 'ARM v7 Architecture, To be added' arm_platform_type 'ARM Platform Type' ARM_PLATFORM_EB 'Realview EB Platform, Unsupported yet' ARM_PLATFORM_AB926 'Versatile AB926 Platform, Unsupported yet' ARM_PLATFORM_PB926 'Versatile PB926 Platform' +ARM_PLATFORM_PBMPCORE 'Realview PB11MPCore Platform' +ARM_PLATFORM_PBA8 'Realview PB-A8 Platform' DRIVER_UART_PL011 'ARM UART Primecell driver PL011' DRIVER_TIMER_SP804 'ARM Dual Timer Primecell driver SP804' -DRIVER_IRQ_PL190 'ARM Vectored Interrupt Controller PL190' +DRIVER_IRQ_PL190 'ARM Vectored Interrupt Controller PL190' +DRIVER_IRQ_GIC 'ARM Generic Interrupt Controller GIC' main_menu 'Codezero Microkernel Configurator' arm_menu 'ARM Architecture Configuration' +#arm_subarch_menu 'ARM Architecture Version' +arm_cpu_menu 'ARM CPU type' +arm_platform_menu 'ARM Platform Type' drivers_menu 'Platform Drivers' arch_type 'Main architecture' + ############# # CHOICES # ############# choices arch_type - ARCH_TEST ARCH_ARM default ARCH_ARM choices arm_subarch_type ARM_SUBARCH_V5 ARM_SUBARCH_V6 + ARM_SUBARCH_V7 default ARM_SUBARCH_V5 choices arm_cpu_type - ARM_CPU_ARM920T ARM_CPU_ARM926 - ARM_CPU_ARM925 + ARM_CPU_ARM1136 + ARM_CPU_ARM11MPCore + ARM_CPU_CORTEXA8 default ARM_CPU_ARM926 choices arm_platform_type ARM_PLATFORM_EB ARM_PLATFORM_AB926 ARM_PLATFORM_PB926 + ARM_PLATFORM_PBMPCORE + ARM_PLATFORM_PBA8 default ARM_PLATFORM_PB926 ############# # MENUS # ############# + +menu arm_cpu_menu + arm_cpu_type + +menu arm_platform_menu + arm_platform_type + menu drivers_menu DRIVER_UART_PL011 DRIVER_TIMER_SP804 DRIVER_IRQ_PL190 + DRIVER_IRQ_GIC + menu arm_menu - arm_cpu_type arm_subarch_type - arm_platform_type + arm_cpu_menu + arm_platform_menu drivers_menu menu main_menu arch_type arm_menu - DUMMY + ############# # RULES # ############# @@ -81,6 +100,7 @@ menu main_menu # dependencies. Instead, a choice symbol is declared in a menu, and # suppress statement is used to make sym visible, instead of a # { sym } model under the choices. +unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 unless ARCH_ARM suppress arm_menu unless ARM_PLATFORM_PB926 suppress DRIVER_UART_PL011 unless ARM_PLATFORM_PB926 suppress DRIVER_TIMER_SP804 From 6b1c5618087b741527ddd3967e6f55cea04d7ece Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sun, 30 Aug 2009 13:07:10 +0300 Subject: [PATCH 7/9] Added cml rule for inclusion of right irq controller driver. GIC is included on GIC platforms. PL190 is included on relevant platforms. --- configs/arm.cml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/configs/arm.cml b/configs/arm.cml index aa58d3a..e5dc5ec 100644 --- a/configs/arm.cml +++ b/configs/arm.cml @@ -9,7 +9,7 @@ ARCH_ARM 'ARM' arm_cpu_type 'ARM Processor Type' ARM_CPU_ARM1136 'ARM1136 - To be added' -ARM_CPU_ARM11MPCore 'ARM11 MPCore - To be added' +ARM_CPU_ARM11MPCORE 'ARM11 MPCore - To be added' ARM_CPU_ARM926 'ARM926EJ-S' ARM_CPU_CORTEXA8 'ARM Cortex-A8 - Not supported' @@ -54,7 +54,7 @@ choices arm_subarch_type choices arm_cpu_type ARM_CPU_ARM926 ARM_CPU_ARM1136 - ARM_CPU_ARM11MPCore + ARM_CPU_ARM11MPCORE ARM_CPU_CORTEXA8 default ARM_CPU_ARM926 @@ -96,18 +96,31 @@ menu main_menu # RULES # ############# +#Platform rules: +unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 +unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_AB926 +unless ARM_SUBARCH_V6 suppress ARM_PLATFORM_PBMPCORE +unless ARM_SUBARCH_V7 suppress ARM_PLATFORM_PBA8 + +#CPU rules: +unless ARM_SUBARCH_V5 suppress ARM_CPU_ARM926 +unless ARM_SUBARCH_V6 suppress ARM_CPU_ARM1136 +unless ARM_SUBARCH_V6 suppress ARM_CPU_ARM11MPCORE +unless ARM_SUBARCH_V7 suppress ARM_CPU_CORTEXA8 + # NOTE: Unlike menus, choices dont take { sym } model of visibility # dependencies. Instead, a choice symbol is declared in a menu, and # suppress statement is used to make sym visible, instead of a # { sym } model under the choices. unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 unless ARCH_ARM suppress arm_menu -unless ARM_PLATFORM_PB926 suppress DRIVER_UART_PL011 -unless ARM_PLATFORM_PB926 suppress DRIVER_TIMER_SP804 -unless ARM_PLATFORM_PB926 suppress DRIVER_IRQ_PL190 +unless ARM_PLATFORM_PB926 or ARM_PLATFORM_AB926 suppress DRIVER_IRQ_PL190 +unless ARM_PLATFORM_EB or ARM_PLATFORM_PBA8 or ARM_PLATFORM_PBMPCORE suppress DRIVER_IRQ_GIC default DRIVER_UART_PL011 from y default DRIVER_TIMER_SP804 from y default DRIVER_IRQ_PL190 from y +default DRIVER_IRQ_GIC from y + # USELESS!! This doesnt force it to define invisible symbols as says in the manual. #when ARCH_TEST save SUBARCH_TEST PLATFORM_TEST #derive SUBARCH_TEST from ARCH_TEST From bda0e064affa295871e6d1e062aefd9a52b270cc Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sun, 30 Aug 2009 13:21:25 +0300 Subject: [PATCH 8/9] Added new subarch, platform, cpu, driver variants for configuration testing. New files are an exact copy of pb926 files, but will help in testing different configurations and compilations. --- configs/arm.cml | 3 +- include/l4/arch/arm/v6/arm1136/cpu.h | 13 + include/l4/arch/arm/v6/arm11mpcore/cpu.h | 13 + include/l4/arch/arm/v6/mm.h | 160 +++++ include/l4/arch/arm/v6/mmu_ops.h | 34 + include/l4/arch/arm/v6/mutex.h | 0 include/l4/arch/arm/v7/cortexa8/cpu.h | 13 + include/l4/arch/arm/v7/mm.h | 160 +++++ include/l4/arch/arm/v7/mmu_ops.h | 34 + include/l4/arch/arm/v7/mutex.h | 0 include/l4/drivers/irq/gic.h | 13 - include/l4/drivers/irq/gic/gic.h | 56 ++ include/l4/platform/ab926/irq.h | 27 + include/l4/platform/ab926/offsets.h | 60 ++ include/l4/platform/ab926/platform.h | 22 + include/l4/platform/ab926/printascii.h | 15 + include/l4/platform/ab926/uart.h | 20 + include/l4/platform/eb/irq.h | 27 + include/l4/platform/eb/offsets.h | 60 ++ include/l4/platform/eb/platform.h | 22 + include/l4/platform/eb/printascii.h | 15 + include/l4/platform/eb/uart.h | 20 + include/l4/platform/pb11mpcore/irq.h | 27 + include/l4/platform/pb11mpcore/offsets.h | 60 ++ include/l4/platform/pb11mpcore/platform.h | 22 + include/l4/platform/pb11mpcore/printascii.h | 15 + include/l4/platform/pb11mpcore/uart.h | 20 + include/l4/platform/pba8/irq.h | 27 + include/l4/platform/pba8/offsets.h | 60 ++ include/l4/platform/pba8/platform.h | 22 + include/l4/platform/pba8/printascii.h | 15 + include/l4/platform/pba8/uart.h | 20 + src/arch/arm/v6/mm.c | 725 ++++++++++++++++++- src/arch/arm/v6/mmu_ops.S | 155 +++++ src/arch/arm/v6/mutex.S | 90 +++ src/arch/arm/v7/mm.c | 726 ++++++++++++++++++++ src/arch/arm/v7/mmu_ops.S | 155 +++++ src/arch/arm/v7/mutex.S | 90 +++ src/drivers/irq/gic/gic.c | 104 +++ src/platform/ab926/irq.c | 57 ++ src/platform/ab926/platform.c | 62 ++ src/platform/ab926/printascii.S | 110 +++ src/platform/ab926/timer.c | 28 + src/platform/ab926/uart.c | 28 + src/platform/eb/irq.c | 57 ++ src/platform/eb/platform.c | 62 ++ src/platform/eb/printascii.S | 110 +++ src/platform/eb/timer.c | 28 + src/platform/eb/uart.c | 28 + src/platform/pb11mpcore/irq.c | 57 ++ src/platform/pb11mpcore/platform.c | 62 ++ src/platform/pb11mpcore/printascii.S | 110 +++ src/platform/pb11mpcore/timer.c | 28 + src/platform/pb11mpcore/uart.c | 28 + src/platform/pba8/irq.c | 57 ++ src/platform/pba8/platform.c | 62 ++ src/platform/pba8/printascii.S | 110 +++ src/platform/pba8/timer.c | 28 + src/platform/pba8/uart.c | 28 + 59 files changed, 4243 insertions(+), 17 deletions(-) create mode 100644 include/l4/arch/arm/v6/arm1136/cpu.h create mode 100644 include/l4/arch/arm/v6/arm11mpcore/cpu.h create mode 100644 include/l4/arch/arm/v6/mm.h create mode 100644 include/l4/arch/arm/v6/mmu_ops.h create mode 100644 include/l4/arch/arm/v6/mutex.h create mode 100644 include/l4/arch/arm/v7/cortexa8/cpu.h create mode 100644 include/l4/arch/arm/v7/mm.h create mode 100644 include/l4/arch/arm/v7/mmu_ops.h create mode 100644 include/l4/arch/arm/v7/mutex.h delete mode 100644 include/l4/drivers/irq/gic.h create mode 100644 include/l4/drivers/irq/gic/gic.h create mode 100644 include/l4/platform/ab926/irq.h create mode 100644 include/l4/platform/ab926/offsets.h create mode 100644 include/l4/platform/ab926/platform.h create mode 100644 include/l4/platform/ab926/printascii.h create mode 100644 include/l4/platform/ab926/uart.h create mode 100644 include/l4/platform/eb/irq.h create mode 100644 include/l4/platform/eb/offsets.h create mode 100644 include/l4/platform/eb/platform.h create mode 100644 include/l4/platform/eb/printascii.h create mode 100644 include/l4/platform/eb/uart.h create mode 100644 include/l4/platform/pb11mpcore/irq.h create mode 100644 include/l4/platform/pb11mpcore/offsets.h create mode 100644 include/l4/platform/pb11mpcore/platform.h create mode 100644 include/l4/platform/pb11mpcore/printascii.h create mode 100644 include/l4/platform/pb11mpcore/uart.h create mode 100644 include/l4/platform/pba8/irq.h create mode 100644 include/l4/platform/pba8/offsets.h create mode 100644 include/l4/platform/pba8/platform.h create mode 100644 include/l4/platform/pba8/printascii.h create mode 100644 include/l4/platform/pba8/uart.h create mode 100644 src/arch/arm/v6/mutex.S create mode 100644 src/arch/arm/v7/mm.c create mode 100644 src/arch/arm/v7/mmu_ops.S create mode 100644 src/arch/arm/v7/mutex.S create mode 100644 src/drivers/irq/gic/gic.c create mode 100644 src/platform/ab926/irq.c create mode 100644 src/platform/ab926/platform.c create mode 100644 src/platform/ab926/printascii.S create mode 100644 src/platform/ab926/timer.c create mode 100644 src/platform/ab926/uart.c create mode 100644 src/platform/eb/irq.c create mode 100644 src/platform/eb/platform.c create mode 100644 src/platform/eb/printascii.S create mode 100644 src/platform/eb/timer.c create mode 100644 src/platform/eb/uart.c create mode 100644 src/platform/pb11mpcore/irq.c create mode 100644 src/platform/pb11mpcore/platform.c create mode 100644 src/platform/pb11mpcore/printascii.S create mode 100644 src/platform/pb11mpcore/timer.c create mode 100644 src/platform/pb11mpcore/uart.c create mode 100644 src/platform/pba8/irq.c create mode 100644 src/platform/pba8/platform.c create mode 100644 src/platform/pba8/printascii.S create mode 100644 src/platform/pba8/timer.c create mode 100644 src/platform/pba8/uart.c diff --git a/configs/arm.cml b/configs/arm.cml index e5dc5ec..7d2ce4d 100644 --- a/configs/arm.cml +++ b/configs/arm.cml @@ -111,7 +111,8 @@ unless ARM_SUBARCH_V7 suppress ARM_CPU_CORTEXA8 # NOTE: Unlike menus, choices dont take { sym } model of visibility # dependencies. Instead, a choice symbol is declared in a menu, and # suppress statement is used to make sym visible, instead of a -# { sym } model under the choices. +# { sym } model under the choices. (See manual for { sym } usage). + unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 unless ARCH_ARM suppress arm_menu unless ARM_PLATFORM_PB926 or ARM_PLATFORM_AB926 suppress DRIVER_IRQ_PL190 diff --git a/include/l4/arch/arm/v6/arm1136/cpu.h b/include/l4/arch/arm/v6/arm1136/cpu.h new file mode 100644 index 0000000..2d11b60 --- /dev/null +++ b/include/l4/arch/arm/v6/arm1136/cpu.h @@ -0,0 +1,13 @@ +/* + * + * Copyright (C) 2005 Bahadir Balban + * + */ +#ifndef __ARM926EJS__H__ +#define __ARM926EJS__H__ + + + + + +#endif /* __ARM926EJS__H__ */ diff --git a/include/l4/arch/arm/v6/arm11mpcore/cpu.h b/include/l4/arch/arm/v6/arm11mpcore/cpu.h new file mode 100644 index 0000000..2d11b60 --- /dev/null +++ b/include/l4/arch/arm/v6/arm11mpcore/cpu.h @@ -0,0 +1,13 @@ +/* + * + * Copyright (C) 2005 Bahadir Balban + * + */ +#ifndef __ARM926EJS__H__ +#define __ARM926EJS__H__ + + + + + +#endif /* __ARM926EJS__H__ */ diff --git a/include/l4/arch/arm/v6/mm.h b/include/l4/arch/arm/v6/mm.h new file mode 100644 index 0000000..35b763b --- /dev/null +++ b/include/l4/arch/arm/v6/mm.h @@ -0,0 +1,160 @@ +/* + * ARM v5-specific virtual memory details + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __V5_MM_H__ +#define __V5_MM_H__ + +/* ARM specific definitions */ +#define VIRT_MEM_START 0 +#define VIRT_MEM_END 0xFFFFFFFF +#define ARM_SECTION_SIZE SZ_1MB +#define ARM_SECTION_MASK (ARM_SECTION_SIZE - 1) +#define ARM_SECTION_BITS 20 +#define ARM_PAGE_SIZE SZ_4K +#define ARM_PAGE_MASK 0xFFF +#define ARM_PAGE_BITS 12 + +#define PGD_SIZE SZ_4K * 4 +#define PGD_ENTRY_TOTAL SZ_4K +#define PGD_TYPE_MASK 0x3 +#define PGD_COARSE_ALIGN_MASK 0xFFFFFC00 +#define PGD_SECTION_ALIGN_MASK 0xFFF00000 +#define PGD_FINE_ALIGN_MASK 0xFFFFF000 +#define PGD_TYPE_FAULT 0 +#define PGD_TYPE_COARSE 1 +#define PGD_TYPE_SECTION 2 +#define PGD_TYPE_FINE 3 + +#define PMD_TYPE_MASK 0x3 +#define PMD_TYPE_FAULT 0 +#define PMD_TYPE_LARGE 1 +#define PMD_TYPE_SMALL 2 +#define PMD_TYPE_TINY 3 + +/* Permission field offsets */ +#define SECTION_AP0 10 + +#define PMD_SIZE SZ_1K +#define PMD_ENTRY_TOTAL 256 +#define PMD_MAP_SIZE SZ_1MB + +/* Type-checkable page table elements */ +typedef u32 pgd_t; +typedef u32 pmd_t; +typedef u32 pte_t; + +/* Page global directory made up of pgd_t entries */ +typedef struct pgd_table { + pgd_t entry[PGD_ENTRY_TOTAL]; +} pgd_table_t; + +/* Page middle directory made up of pmd_t entries */ +typedef struct pmd_table { + pmd_t entry[PMD_ENTRY_TOTAL]; +} pmd_table_t; + +/* Applies for both small and large pages */ +#define PAGE_AP0 4 +#define PAGE_AP1 6 +#define PAGE_AP2 8 +#define PAGE_AP3 10 + +/* Permission values with rom and sys bits ignored */ +#define SVC_RW_USR_NONE 1 +#define SVC_RW_USR_RO 2 +#define SVC_RW_USR_RW 3 + +#define PTE_PROT_MASK (0xFF << 4) + +#define CACHEABILITY 3 +#define BUFFERABILITY 2 +#define cacheable (1 << CACHEABILITY) +#define bufferable (1 << BUFFERABILITY) +#define uncacheable 0 +#define unbufferable 0 + +/* Helper macros for common cases */ +#define __MAP_USR_RW_FLAGS (cacheable | bufferable | (SVC_RW_USR_RW << PAGE_AP0) \ + | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2) \ + | (SVC_RW_USR_RW << PAGE_AP3)) +#define __MAP_USR_RO_FLAGS (cacheable | bufferable | (SVC_RW_USR_RO << PAGE_AP0) \ + | (SVC_RW_USR_RO << PAGE_AP1) | (SVC_RW_USR_RO << PAGE_AP2) \ + | (SVC_RW_USR_RO << PAGE_AP3)) +#define __MAP_SVC_RW_FLAGS (cacheable | bufferable | (SVC_RW_USR_NONE << PAGE_AP0) \ + | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \ + | (SVC_RW_USR_NONE << PAGE_AP3)) +#define __MAP_SVC_IO_FLAGS (uncacheable | unbufferable | (SVC_RW_USR_NONE << PAGE_AP0) \ + | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \ + | (SVC_RW_USR_NONE << PAGE_AP3)) +#define __MAP_USR_IO_FLAGS (uncacheable | unbufferable | (SVC_RW_USR_RW << PAGE_AP0) \ + | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2) \ + | (SVC_RW_USR_RW << PAGE_AP3)) + +/* Abort information */ + +/*FIXME: Carry all these definitions to an abort.h, Also carry all abort code to abort.c. Much neater!!! */ + +/* Abort type */ +#define ARM_PABT 1 +#define ARM_DABT 0 +/* The kernel makes use of bit 8 (Always Zero) of FSR to define which type of abort */ +#define set_abort_type(fsr, x) { fsr &= ~(1 << 8); fsr |= ((x & 1) << 8); } +#define ARM_FSR_MASK 0xF +#define is_prefetch_abort(fsr) ((fsr >> 8) & 0x1) +#define is_data_abort(fsr) (!is_prefetch_abort(fsr)) + +/* + * v5 Architecture-defined data abort values for FSR ordered + * in highest to lowest priority. + */ +#define DABT_TERMINAL 0x2 +#define DABT_VECTOR 0x0 /* Obsolete */ +#define DABT_ALIGN 0x1 +#define DABT_EXT_XLATE_LEVEL1 0xC +#define DABT_EXT_XLATE_LEVEL2 0xE +#define DABT_XLATE_SECT 0x5 +#define DABT_XLATE_PAGE 0x7 +#define DABT_DOMAIN_SECT 0x9 +#define DABT_DOMAIN_PAGE 0xB +#define DABT_PERM_SECT 0xD +#define DABT_PERM_PAGE 0xF +#define DABT_EXT_LFETCH_SECT 0x4 +#define DABT_EXT_LFETCH_PAGE 0x6 +#define DABT_EXT_NON_LFETCH_SECT 0x8 +#define DABT_EXT_NON_LFETCH_PAGE 0xA + +#define TASK_PGD(x) (x)->space->pgd + +#define STACK_ALIGNMENT 8 + +/* Kernel's data about the fault */ +typedef struct fault_kdata { + u32 faulty_pc; + u32 fsr; + u32 far; + pte_t pte; +} __attribute__ ((__packed__)) fault_kdata_t; + +void arch_hardware_flush(pgd_table_t *pgd); +void add_section_mapping_init(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags); + +void add_boot_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags); + +struct address_space; +int delete_page_tables(struct address_space *space); +int copy_user_tables(struct address_space *new, struct address_space *orig); +pgd_table_t *copy_page_tables(pgd_table_t *from); +void remap_as_pages(void *vstart, void *vend); + +int pgd_count_pmds(pgd_table_t *pgd); +pgd_table_t *realloc_page_tables(void); +void remove_section_mapping(unsigned long vaddr); + +void copy_pgds_by_vrange(pgd_table_t *to, pgd_table_t *from, + unsigned long start, unsigned long end); + +#endif /* __V5_MM_H__ */ diff --git a/include/l4/arch/arm/v6/mmu_ops.h b/include/l4/arch/arm/v6/mmu_ops.h new file mode 100644 index 0000000..f7f0b88 --- /dev/null +++ b/include/l4/arch/arm/v6/mmu_ops.h @@ -0,0 +1,34 @@ +#ifndef __MMU__OPS__H__ +#define __MMU__OPS__H__ +/* + * Prototypes for low level mmu operations + * + * Copyright (C) 2005 Bahadir Balban + * + */ + +void arm_set_ttb(unsigned int); +void arm_set_domain(unsigned int); +unsigned int arm_get_domain(void); +void arm_enable_mmu(void); +void arm_enable_icache(void); +void arm_enable_dcache(void); +void arm_enable_wbuffer(void); +void arm_enable_high_vectors(void); +void arm_invalidate_cache(void); +void arm_invalidate_icache(void); +void arm_invalidate_dcache(void); +void arm_clean_invalidate_dcache(void); +void arm_clean_invalidate_cache(void); +void arm_drain_writebuffer(void); +void arm_invalidate_tlb(void); +void arm_invalidate_itlb(void); +void arm_invalidate_dtlb(void); + +static inline void arm_enable_caches(void) +{ + arm_enable_icache(); + arm_enable_dcache(); +} + +#endif /* __MMU__OPS__H__ */ diff --git a/include/l4/arch/arm/v6/mutex.h b/include/l4/arch/arm/v6/mutex.h new file mode 100644 index 0000000..e69de29 diff --git a/include/l4/arch/arm/v7/cortexa8/cpu.h b/include/l4/arch/arm/v7/cortexa8/cpu.h new file mode 100644 index 0000000..2d11b60 --- /dev/null +++ b/include/l4/arch/arm/v7/cortexa8/cpu.h @@ -0,0 +1,13 @@ +/* + * + * Copyright (C) 2005 Bahadir Balban + * + */ +#ifndef __ARM926EJS__H__ +#define __ARM926EJS__H__ + + + + + +#endif /* __ARM926EJS__H__ */ diff --git a/include/l4/arch/arm/v7/mm.h b/include/l4/arch/arm/v7/mm.h new file mode 100644 index 0000000..35b763b --- /dev/null +++ b/include/l4/arch/arm/v7/mm.h @@ -0,0 +1,160 @@ +/* + * ARM v5-specific virtual memory details + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __V5_MM_H__ +#define __V5_MM_H__ + +/* ARM specific definitions */ +#define VIRT_MEM_START 0 +#define VIRT_MEM_END 0xFFFFFFFF +#define ARM_SECTION_SIZE SZ_1MB +#define ARM_SECTION_MASK (ARM_SECTION_SIZE - 1) +#define ARM_SECTION_BITS 20 +#define ARM_PAGE_SIZE SZ_4K +#define ARM_PAGE_MASK 0xFFF +#define ARM_PAGE_BITS 12 + +#define PGD_SIZE SZ_4K * 4 +#define PGD_ENTRY_TOTAL SZ_4K +#define PGD_TYPE_MASK 0x3 +#define PGD_COARSE_ALIGN_MASK 0xFFFFFC00 +#define PGD_SECTION_ALIGN_MASK 0xFFF00000 +#define PGD_FINE_ALIGN_MASK 0xFFFFF000 +#define PGD_TYPE_FAULT 0 +#define PGD_TYPE_COARSE 1 +#define PGD_TYPE_SECTION 2 +#define PGD_TYPE_FINE 3 + +#define PMD_TYPE_MASK 0x3 +#define PMD_TYPE_FAULT 0 +#define PMD_TYPE_LARGE 1 +#define PMD_TYPE_SMALL 2 +#define PMD_TYPE_TINY 3 + +/* Permission field offsets */ +#define SECTION_AP0 10 + +#define PMD_SIZE SZ_1K +#define PMD_ENTRY_TOTAL 256 +#define PMD_MAP_SIZE SZ_1MB + +/* Type-checkable page table elements */ +typedef u32 pgd_t; +typedef u32 pmd_t; +typedef u32 pte_t; + +/* Page global directory made up of pgd_t entries */ +typedef struct pgd_table { + pgd_t entry[PGD_ENTRY_TOTAL]; +} pgd_table_t; + +/* Page middle directory made up of pmd_t entries */ +typedef struct pmd_table { + pmd_t entry[PMD_ENTRY_TOTAL]; +} pmd_table_t; + +/* Applies for both small and large pages */ +#define PAGE_AP0 4 +#define PAGE_AP1 6 +#define PAGE_AP2 8 +#define PAGE_AP3 10 + +/* Permission values with rom and sys bits ignored */ +#define SVC_RW_USR_NONE 1 +#define SVC_RW_USR_RO 2 +#define SVC_RW_USR_RW 3 + +#define PTE_PROT_MASK (0xFF << 4) + +#define CACHEABILITY 3 +#define BUFFERABILITY 2 +#define cacheable (1 << CACHEABILITY) +#define bufferable (1 << BUFFERABILITY) +#define uncacheable 0 +#define unbufferable 0 + +/* Helper macros for common cases */ +#define __MAP_USR_RW_FLAGS (cacheable | bufferable | (SVC_RW_USR_RW << PAGE_AP0) \ + | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2) \ + | (SVC_RW_USR_RW << PAGE_AP3)) +#define __MAP_USR_RO_FLAGS (cacheable | bufferable | (SVC_RW_USR_RO << PAGE_AP0) \ + | (SVC_RW_USR_RO << PAGE_AP1) | (SVC_RW_USR_RO << PAGE_AP2) \ + | (SVC_RW_USR_RO << PAGE_AP3)) +#define __MAP_SVC_RW_FLAGS (cacheable | bufferable | (SVC_RW_USR_NONE << PAGE_AP0) \ + | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \ + | (SVC_RW_USR_NONE << PAGE_AP3)) +#define __MAP_SVC_IO_FLAGS (uncacheable | unbufferable | (SVC_RW_USR_NONE << PAGE_AP0) \ + | (SVC_RW_USR_NONE << PAGE_AP1) | (SVC_RW_USR_NONE << PAGE_AP2) \ + | (SVC_RW_USR_NONE << PAGE_AP3)) +#define __MAP_USR_IO_FLAGS (uncacheable | unbufferable | (SVC_RW_USR_RW << PAGE_AP0) \ + | (SVC_RW_USR_RW << PAGE_AP1) | (SVC_RW_USR_RW << PAGE_AP2) \ + | (SVC_RW_USR_RW << PAGE_AP3)) + +/* Abort information */ + +/*FIXME: Carry all these definitions to an abort.h, Also carry all abort code to abort.c. Much neater!!! */ + +/* Abort type */ +#define ARM_PABT 1 +#define ARM_DABT 0 +/* The kernel makes use of bit 8 (Always Zero) of FSR to define which type of abort */ +#define set_abort_type(fsr, x) { fsr &= ~(1 << 8); fsr |= ((x & 1) << 8); } +#define ARM_FSR_MASK 0xF +#define is_prefetch_abort(fsr) ((fsr >> 8) & 0x1) +#define is_data_abort(fsr) (!is_prefetch_abort(fsr)) + +/* + * v5 Architecture-defined data abort values for FSR ordered + * in highest to lowest priority. + */ +#define DABT_TERMINAL 0x2 +#define DABT_VECTOR 0x0 /* Obsolete */ +#define DABT_ALIGN 0x1 +#define DABT_EXT_XLATE_LEVEL1 0xC +#define DABT_EXT_XLATE_LEVEL2 0xE +#define DABT_XLATE_SECT 0x5 +#define DABT_XLATE_PAGE 0x7 +#define DABT_DOMAIN_SECT 0x9 +#define DABT_DOMAIN_PAGE 0xB +#define DABT_PERM_SECT 0xD +#define DABT_PERM_PAGE 0xF +#define DABT_EXT_LFETCH_SECT 0x4 +#define DABT_EXT_LFETCH_PAGE 0x6 +#define DABT_EXT_NON_LFETCH_SECT 0x8 +#define DABT_EXT_NON_LFETCH_PAGE 0xA + +#define TASK_PGD(x) (x)->space->pgd + +#define STACK_ALIGNMENT 8 + +/* Kernel's data about the fault */ +typedef struct fault_kdata { + u32 faulty_pc; + u32 fsr; + u32 far; + pte_t pte; +} __attribute__ ((__packed__)) fault_kdata_t; + +void arch_hardware_flush(pgd_table_t *pgd); +void add_section_mapping_init(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags); + +void add_boot_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags); + +struct address_space; +int delete_page_tables(struct address_space *space); +int copy_user_tables(struct address_space *new, struct address_space *orig); +pgd_table_t *copy_page_tables(pgd_table_t *from); +void remap_as_pages(void *vstart, void *vend); + +int pgd_count_pmds(pgd_table_t *pgd); +pgd_table_t *realloc_page_tables(void); +void remove_section_mapping(unsigned long vaddr); + +void copy_pgds_by_vrange(pgd_table_t *to, pgd_table_t *from, + unsigned long start, unsigned long end); + +#endif /* __V5_MM_H__ */ diff --git a/include/l4/arch/arm/v7/mmu_ops.h b/include/l4/arch/arm/v7/mmu_ops.h new file mode 100644 index 0000000..f7f0b88 --- /dev/null +++ b/include/l4/arch/arm/v7/mmu_ops.h @@ -0,0 +1,34 @@ +#ifndef __MMU__OPS__H__ +#define __MMU__OPS__H__ +/* + * Prototypes for low level mmu operations + * + * Copyright (C) 2005 Bahadir Balban + * + */ + +void arm_set_ttb(unsigned int); +void arm_set_domain(unsigned int); +unsigned int arm_get_domain(void); +void arm_enable_mmu(void); +void arm_enable_icache(void); +void arm_enable_dcache(void); +void arm_enable_wbuffer(void); +void arm_enable_high_vectors(void); +void arm_invalidate_cache(void); +void arm_invalidate_icache(void); +void arm_invalidate_dcache(void); +void arm_clean_invalidate_dcache(void); +void arm_clean_invalidate_cache(void); +void arm_drain_writebuffer(void); +void arm_invalidate_tlb(void); +void arm_invalidate_itlb(void); +void arm_invalidate_dtlb(void); + +static inline void arm_enable_caches(void) +{ + arm_enable_icache(); + arm_enable_dcache(); +} + +#endif /* __MMU__OPS__H__ */ diff --git a/include/l4/arch/arm/v7/mutex.h b/include/l4/arch/arm/v7/mutex.h new file mode 100644 index 0000000..e69de29 diff --git a/include/l4/drivers/irq/gic.h b/include/l4/drivers/irq/gic.h deleted file mode 100644 index a69af61..0000000 --- a/include/l4/drivers/irq/gic.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * - * Copyright (C) 2007 Bahadir Balban - * - */ -#ifndef __GIC_H__ -#define __GIC_H__ - - - - - -#endif /* __GIC_H__ */ diff --git a/include/l4/drivers/irq/gic/gic.h b/include/l4/drivers/irq/gic/gic.h new file mode 100644 index 0000000..65adb79 --- /dev/null +++ b/include/l4/drivers/irq/gic/gic.h @@ -0,0 +1,56 @@ +/* + * PL190 Primecell Vectored Interrupt Controller offsets + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#ifndef __PL190_VIC_H__ +#define __PL190_VIC_H__ + +#include INC_PLAT(platform.h) + +#define PL190_BASE PLATFORM_IRQCTRL_BASE +#define PL190_SIC_BASE PLATFORM_SIRQCTRL_BASE + +/* VIC register offsets */ +#define PL190_VIC_IRQSTATUS (PL190_BASE + 0x00) +#define PL190_VIC_FIQSTATUS (PL190_BASE + 0x04) +#define PL190_VIC_RAWINTR (PL190_BASE + 0x08) +#define PL190_VIC_INTSELECT (PL190_BASE + 0x0C) +#define PL190_VIC_INTENABLE (PL190_BASE + 0x10) +#define PL190_VIC_INTENCLEAR (PL190_BASE + 0x14) +#define PL190_VIC_SOFTINT (PL190_BASE + 0x18) +#define PL190_VIC_SOFTINTCLEAR (PL190_BASE + 0x1C) +#define PL190_VIC_PROTECTION (PL190_BASE + 0x20) +#define PL190_VIC_VECTADDR (PL190_BASE + 0x30) +#define PL190_VIC_DEFVECTADDR (PL190_BASE + 0x34) +#define PL190_VIC_VECTADDR0 (PL190_BASE + 0x100) +/* 15 PIC_VECTADDR registers up to 0x13C */ +#define PL190_VIC_VECTCNTL0 (PL190_BASE + 0x200) +/* 15 PIC_VECTCNTL registers up to 0x23C */ + +#define PL190_SIC_STATUS (PL190_SIC_BASE + 0x0) +#define PL190_SIC_RAWSTAT (PL190_SIC_BASE + 0x04) +#define PL190_SIC_ENABLE (PL190_SIC_BASE + 0x08) +#define PL190_SIC_ENSET (PL190_SIC_BASE + 0x08) +#define PL190_SIC_ENCLR (PL190_SIC_BASE + 0x0C) +#define PL190_SIC_SOFTINTSET (PL190_SIC_BASE + 0x10) +#define PL190_SIC_SOFTINTCLR (PL190_SIC_BASE + 0x14) +#define PL190_SIC_PICENABLE (PL190_SIC_BASE + 0x20) +#define PL190_SIC_PICENSET (PL190_SIC_BASE + 0x20) +#define PL190_SIC_PICENCLR (PL190_SIC_BASE + 0x24) + +void pl190_vic_init(void); +void pl190_ack_irq(int irq); +void pl190_mask_irq(int irq); +void pl190_unmask_irq(int irq); +int pl190_read_irq(void); + +int pl190_sic_read_irq(void); +void pl190_sic_mask_irq(int irq); +void pl190_sic_mask_irq(int irq); +void pl190_sic_ack_irq(int irq); +void pl190_sic_unmask_irq(int irq); +void pl190_sic_init(void); +#endif /* __PL190_VIC_H__ */ diff --git a/include/l4/platform/ab926/irq.h b/include/l4/platform/ab926/irq.h new file mode 100644 index 0000000..ecfad92 --- /dev/null +++ b/include/l4/platform/ab926/irq.h @@ -0,0 +1,27 @@ +#ifndef __PLATFORM_IRQ_H__ +#define __PLATFORM_IRQ_H__ + +#define IRQ_CHIPS_MAX 2 +#define IRQS_MAX 64 + +/* IRQ indices. */ +#define IRQ_TIMER01 4 +#define IRQ_TIMER23 5 +#define IRQ_RTC 10 +#define IRQ_UART0 12 +#define IRQ_UART1 13 +#define IRQ_UART2 14 +#define IRQ_SIC 31 + +/* Cascading definitions */ + +#define PIC_IRQS_MAX 31 /* Total irqs on PIC */ +/* The local irq line of the dummy peripheral on this chip */ +#define LOCALIRQ_DUMMY 15 +/* The irq index offset of this chip, is the maximum of previous chip + 1 */ +#define SIRQ_CHIP_OFFSET (PIC_IRQS_MAX + 1) +/* The global irq number of dummy is the local irq line + it's chip offset */ +#define IRQ_DUMMY (LOCALIRQ_DUMMY + SIRQ_CHIP_OFFSET) + + +#endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/ab926/offsets.h b/include/l4/platform/ab926/offsets.h new file mode 100644 index 0000000..4a49729 --- /dev/null +++ b/include/l4/platform/ab926/offsets.h @@ -0,0 +1,60 @@ +/* + * Describes physical memory layout of pb926 platform. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __PLATFORM_PB926_OFFSETS_H__ +#define __PLATFORM_PB926_OFFSETS_H__ + +/* Physical memory base */ +#define PHYS_MEM_START 0x00000000 /* inclusive */ +#define PHYS_MEM_END 0x08000000 /* 128 MB, exclusive */ + +/* + * These bases taken from where kernel is `physically' linked at, + * also used to calculate virtual-to-physical translation offset. + * See the linker script for their sources. PHYS_ADDR_BASE can't + * use a linker variable because it's referred from assembler. + */ +#define PHYS_ADDR_BASE 0x100000 + +/* Device memory base */ +#define PB926_DEV_PHYS 0x10000000 + +/* Device offsets in physical memory */ +#define PB926_SYSTEM_REGISTERS 0x10000000 /* System registers */ +#define PB926_SYSCTRL_BASE 0x101E0000 /* System controller */ +#define PB926_WATCHDOG_BASE 0x101E1000 /* Watchdog */ +#define PB926_TIMER01_BASE 0x101E2000 /* Timers 0 and 1 */ +#define PB926_TIMER23_BASE 0x101E3000 /* Timers 2 and 3 */ +#define PB926_RTC_BASE 0x101E8000 /* Real Time Clock */ +#define PB926_VIC_BASE 0x10140000 /* Primary Vectored IC */ +#define PB926_SIC_BASE 0x10003000 /* Secondary IC */ +#define PB926_UART0_BASE 0x101F1000 /* Console port (UART0) */ + +/* + * Uart virtual address until a file-based console access + * is available for userspace + */ +#define USERSPACE_UART_BASE 0x500000 + +/* + * Device offsets in virtual memory. They offset to some virtual + * device base address. Each page on this virtual base is consecutively + * allocated to devices. Nice and smooth. + */ +#define PB926_TIMER01_VOFFSET 0x00000000 +#define PB926_UART0_VOFFSET 0x00001000 +#define PB926_VIC_VOFFSET 0x00002000 +#define PB926_SIC_VOFFSET 0x00003000 +#define PB926_SYSREGS_VOFFSET 0x00005000 +#define PB926_SYSCTRL_VOFFSET 0x00006000 + +#define PB926_UART0_VBASE (IO_AREA0_VADDR + PB926_UART0_VOFFSET) +#define PB926_TIMER01_VBASE (IO_AREA0_VADDR + PB926_TIMER01_VOFFSET) +#define PB926_SYSCTRL_VBASE (IO_AREA0_VADDR + PB926_SYSCTRL_VOFFSET) +#define PB926_VIC_VBASE (IO_AREA0_VADDR + PB926_VIC_VOFFSET) +#define PB926_SIC_VBASE (IO_AREA0_VADDR + PB926_SIC_VOFFSET) +#endif /* __PLATFORM_PB926_OFFSETS_H__ */ + diff --git a/include/l4/platform/ab926/platform.h b/include/l4/platform/ab926/platform.h new file mode 100644 index 0000000..dd4f4cb --- /dev/null +++ b/include/l4/platform/ab926/platform.h @@ -0,0 +1,22 @@ +#ifndef __PLATFORM_PB926_PLATFORM_H__ +#define __PLATFORM_PB926_PLATFORM_H__ +/* + * Platform specific ties between drivers and generic APIs used by the kernel. + * E.g. system timer and console. + * + * Copyright (C) Bahadir Balban 2007 + */ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#define PLATFORM_TIMER_BASE PB926_TIMER01_VBASE +#define PLATFORM_SP810_BASE PB926_SYSCTRL_VBASE +#define PLATFORM_IRQCTRL_BASE PB926_VIC_VBASE +#define PLATFORM_SIRQCTRL_BASE PB926_SIC_VBASE + +void platform_irq_enable(int irq); +void platform_irq_disable(int irq); +void timer_start(void); +#endif /* __PLATFORM_PB926_PLATFORM_H__ */ diff --git a/include/l4/platform/ab926/printascii.h b/include/l4/platform/ab926/printascii.h new file mode 100644 index 0000000..0d0be28 --- /dev/null +++ b/include/l4/platform/ab926/printascii.h @@ -0,0 +1,15 @@ +#ifndef __PLATFORM__PB926__PRINTASCII__H__ +#define __PLATFORM__PB926__PRINTASCII__H__ + +#define dprintk(str, val) \ +{ \ + printascii(str); \ + printascii("0x"); \ + printhex8((val)); \ + printascii("\n"); \ +} + +void printascii(char *str); +void printhex8(unsigned int); + +#endif /* __PLATFORM__PB926__PRINTASCII__H__ */ diff --git a/include/l4/platform/ab926/uart.h b/include/l4/platform/ab926/uart.h new file mode 100644 index 0000000..366590f --- /dev/null +++ b/include/l4/platform/ab926/uart.h @@ -0,0 +1,20 @@ +/* + * Platform specific ties to generic uart functions that putc expects. + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#ifndef __PLATFORM_PB926_UART_H__ +#define __PLATFORM_PB926_UART_H__ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#include + +void uart_init(void); +void uart_putc(char c); + +#endif /* __PLATFORM_PB926_UART_H__ */ diff --git a/include/l4/platform/eb/irq.h b/include/l4/platform/eb/irq.h new file mode 100644 index 0000000..ecfad92 --- /dev/null +++ b/include/l4/platform/eb/irq.h @@ -0,0 +1,27 @@ +#ifndef __PLATFORM_IRQ_H__ +#define __PLATFORM_IRQ_H__ + +#define IRQ_CHIPS_MAX 2 +#define IRQS_MAX 64 + +/* IRQ indices. */ +#define IRQ_TIMER01 4 +#define IRQ_TIMER23 5 +#define IRQ_RTC 10 +#define IRQ_UART0 12 +#define IRQ_UART1 13 +#define IRQ_UART2 14 +#define IRQ_SIC 31 + +/* Cascading definitions */ + +#define PIC_IRQS_MAX 31 /* Total irqs on PIC */ +/* The local irq line of the dummy peripheral on this chip */ +#define LOCALIRQ_DUMMY 15 +/* The irq index offset of this chip, is the maximum of previous chip + 1 */ +#define SIRQ_CHIP_OFFSET (PIC_IRQS_MAX + 1) +/* The global irq number of dummy is the local irq line + it's chip offset */ +#define IRQ_DUMMY (LOCALIRQ_DUMMY + SIRQ_CHIP_OFFSET) + + +#endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/eb/offsets.h b/include/l4/platform/eb/offsets.h new file mode 100644 index 0000000..4a49729 --- /dev/null +++ b/include/l4/platform/eb/offsets.h @@ -0,0 +1,60 @@ +/* + * Describes physical memory layout of pb926 platform. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __PLATFORM_PB926_OFFSETS_H__ +#define __PLATFORM_PB926_OFFSETS_H__ + +/* Physical memory base */ +#define PHYS_MEM_START 0x00000000 /* inclusive */ +#define PHYS_MEM_END 0x08000000 /* 128 MB, exclusive */ + +/* + * These bases taken from where kernel is `physically' linked at, + * also used to calculate virtual-to-physical translation offset. + * See the linker script for their sources. PHYS_ADDR_BASE can't + * use a linker variable because it's referred from assembler. + */ +#define PHYS_ADDR_BASE 0x100000 + +/* Device memory base */ +#define PB926_DEV_PHYS 0x10000000 + +/* Device offsets in physical memory */ +#define PB926_SYSTEM_REGISTERS 0x10000000 /* System registers */ +#define PB926_SYSCTRL_BASE 0x101E0000 /* System controller */ +#define PB926_WATCHDOG_BASE 0x101E1000 /* Watchdog */ +#define PB926_TIMER01_BASE 0x101E2000 /* Timers 0 and 1 */ +#define PB926_TIMER23_BASE 0x101E3000 /* Timers 2 and 3 */ +#define PB926_RTC_BASE 0x101E8000 /* Real Time Clock */ +#define PB926_VIC_BASE 0x10140000 /* Primary Vectored IC */ +#define PB926_SIC_BASE 0x10003000 /* Secondary IC */ +#define PB926_UART0_BASE 0x101F1000 /* Console port (UART0) */ + +/* + * Uart virtual address until a file-based console access + * is available for userspace + */ +#define USERSPACE_UART_BASE 0x500000 + +/* + * Device offsets in virtual memory. They offset to some virtual + * device base address. Each page on this virtual base is consecutively + * allocated to devices. Nice and smooth. + */ +#define PB926_TIMER01_VOFFSET 0x00000000 +#define PB926_UART0_VOFFSET 0x00001000 +#define PB926_VIC_VOFFSET 0x00002000 +#define PB926_SIC_VOFFSET 0x00003000 +#define PB926_SYSREGS_VOFFSET 0x00005000 +#define PB926_SYSCTRL_VOFFSET 0x00006000 + +#define PB926_UART0_VBASE (IO_AREA0_VADDR + PB926_UART0_VOFFSET) +#define PB926_TIMER01_VBASE (IO_AREA0_VADDR + PB926_TIMER01_VOFFSET) +#define PB926_SYSCTRL_VBASE (IO_AREA0_VADDR + PB926_SYSCTRL_VOFFSET) +#define PB926_VIC_VBASE (IO_AREA0_VADDR + PB926_VIC_VOFFSET) +#define PB926_SIC_VBASE (IO_AREA0_VADDR + PB926_SIC_VOFFSET) +#endif /* __PLATFORM_PB926_OFFSETS_H__ */ + diff --git a/include/l4/platform/eb/platform.h b/include/l4/platform/eb/platform.h new file mode 100644 index 0000000..dd4f4cb --- /dev/null +++ b/include/l4/platform/eb/platform.h @@ -0,0 +1,22 @@ +#ifndef __PLATFORM_PB926_PLATFORM_H__ +#define __PLATFORM_PB926_PLATFORM_H__ +/* + * Platform specific ties between drivers and generic APIs used by the kernel. + * E.g. system timer and console. + * + * Copyright (C) Bahadir Balban 2007 + */ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#define PLATFORM_TIMER_BASE PB926_TIMER01_VBASE +#define PLATFORM_SP810_BASE PB926_SYSCTRL_VBASE +#define PLATFORM_IRQCTRL_BASE PB926_VIC_VBASE +#define PLATFORM_SIRQCTRL_BASE PB926_SIC_VBASE + +void platform_irq_enable(int irq); +void platform_irq_disable(int irq); +void timer_start(void); +#endif /* __PLATFORM_PB926_PLATFORM_H__ */ diff --git a/include/l4/platform/eb/printascii.h b/include/l4/platform/eb/printascii.h new file mode 100644 index 0000000..0d0be28 --- /dev/null +++ b/include/l4/platform/eb/printascii.h @@ -0,0 +1,15 @@ +#ifndef __PLATFORM__PB926__PRINTASCII__H__ +#define __PLATFORM__PB926__PRINTASCII__H__ + +#define dprintk(str, val) \ +{ \ + printascii(str); \ + printascii("0x"); \ + printhex8((val)); \ + printascii("\n"); \ +} + +void printascii(char *str); +void printhex8(unsigned int); + +#endif /* __PLATFORM__PB926__PRINTASCII__H__ */ diff --git a/include/l4/platform/eb/uart.h b/include/l4/platform/eb/uart.h new file mode 100644 index 0000000..366590f --- /dev/null +++ b/include/l4/platform/eb/uart.h @@ -0,0 +1,20 @@ +/* + * Platform specific ties to generic uart functions that putc expects. + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#ifndef __PLATFORM_PB926_UART_H__ +#define __PLATFORM_PB926_UART_H__ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#include + +void uart_init(void); +void uart_putc(char c); + +#endif /* __PLATFORM_PB926_UART_H__ */ diff --git a/include/l4/platform/pb11mpcore/irq.h b/include/l4/platform/pb11mpcore/irq.h new file mode 100644 index 0000000..ecfad92 --- /dev/null +++ b/include/l4/platform/pb11mpcore/irq.h @@ -0,0 +1,27 @@ +#ifndef __PLATFORM_IRQ_H__ +#define __PLATFORM_IRQ_H__ + +#define IRQ_CHIPS_MAX 2 +#define IRQS_MAX 64 + +/* IRQ indices. */ +#define IRQ_TIMER01 4 +#define IRQ_TIMER23 5 +#define IRQ_RTC 10 +#define IRQ_UART0 12 +#define IRQ_UART1 13 +#define IRQ_UART2 14 +#define IRQ_SIC 31 + +/* Cascading definitions */ + +#define PIC_IRQS_MAX 31 /* Total irqs on PIC */ +/* The local irq line of the dummy peripheral on this chip */ +#define LOCALIRQ_DUMMY 15 +/* The irq index offset of this chip, is the maximum of previous chip + 1 */ +#define SIRQ_CHIP_OFFSET (PIC_IRQS_MAX + 1) +/* The global irq number of dummy is the local irq line + it's chip offset */ +#define IRQ_DUMMY (LOCALIRQ_DUMMY + SIRQ_CHIP_OFFSET) + + +#endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/pb11mpcore/offsets.h b/include/l4/platform/pb11mpcore/offsets.h new file mode 100644 index 0000000..4a49729 --- /dev/null +++ b/include/l4/platform/pb11mpcore/offsets.h @@ -0,0 +1,60 @@ +/* + * Describes physical memory layout of pb926 platform. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __PLATFORM_PB926_OFFSETS_H__ +#define __PLATFORM_PB926_OFFSETS_H__ + +/* Physical memory base */ +#define PHYS_MEM_START 0x00000000 /* inclusive */ +#define PHYS_MEM_END 0x08000000 /* 128 MB, exclusive */ + +/* + * These bases taken from where kernel is `physically' linked at, + * also used to calculate virtual-to-physical translation offset. + * See the linker script for their sources. PHYS_ADDR_BASE can't + * use a linker variable because it's referred from assembler. + */ +#define PHYS_ADDR_BASE 0x100000 + +/* Device memory base */ +#define PB926_DEV_PHYS 0x10000000 + +/* Device offsets in physical memory */ +#define PB926_SYSTEM_REGISTERS 0x10000000 /* System registers */ +#define PB926_SYSCTRL_BASE 0x101E0000 /* System controller */ +#define PB926_WATCHDOG_BASE 0x101E1000 /* Watchdog */ +#define PB926_TIMER01_BASE 0x101E2000 /* Timers 0 and 1 */ +#define PB926_TIMER23_BASE 0x101E3000 /* Timers 2 and 3 */ +#define PB926_RTC_BASE 0x101E8000 /* Real Time Clock */ +#define PB926_VIC_BASE 0x10140000 /* Primary Vectored IC */ +#define PB926_SIC_BASE 0x10003000 /* Secondary IC */ +#define PB926_UART0_BASE 0x101F1000 /* Console port (UART0) */ + +/* + * Uart virtual address until a file-based console access + * is available for userspace + */ +#define USERSPACE_UART_BASE 0x500000 + +/* + * Device offsets in virtual memory. They offset to some virtual + * device base address. Each page on this virtual base is consecutively + * allocated to devices. Nice and smooth. + */ +#define PB926_TIMER01_VOFFSET 0x00000000 +#define PB926_UART0_VOFFSET 0x00001000 +#define PB926_VIC_VOFFSET 0x00002000 +#define PB926_SIC_VOFFSET 0x00003000 +#define PB926_SYSREGS_VOFFSET 0x00005000 +#define PB926_SYSCTRL_VOFFSET 0x00006000 + +#define PB926_UART0_VBASE (IO_AREA0_VADDR + PB926_UART0_VOFFSET) +#define PB926_TIMER01_VBASE (IO_AREA0_VADDR + PB926_TIMER01_VOFFSET) +#define PB926_SYSCTRL_VBASE (IO_AREA0_VADDR + PB926_SYSCTRL_VOFFSET) +#define PB926_VIC_VBASE (IO_AREA0_VADDR + PB926_VIC_VOFFSET) +#define PB926_SIC_VBASE (IO_AREA0_VADDR + PB926_SIC_VOFFSET) +#endif /* __PLATFORM_PB926_OFFSETS_H__ */ + diff --git a/include/l4/platform/pb11mpcore/platform.h b/include/l4/platform/pb11mpcore/platform.h new file mode 100644 index 0000000..dd4f4cb --- /dev/null +++ b/include/l4/platform/pb11mpcore/platform.h @@ -0,0 +1,22 @@ +#ifndef __PLATFORM_PB926_PLATFORM_H__ +#define __PLATFORM_PB926_PLATFORM_H__ +/* + * Platform specific ties between drivers and generic APIs used by the kernel. + * E.g. system timer and console. + * + * Copyright (C) Bahadir Balban 2007 + */ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#define PLATFORM_TIMER_BASE PB926_TIMER01_VBASE +#define PLATFORM_SP810_BASE PB926_SYSCTRL_VBASE +#define PLATFORM_IRQCTRL_BASE PB926_VIC_VBASE +#define PLATFORM_SIRQCTRL_BASE PB926_SIC_VBASE + +void platform_irq_enable(int irq); +void platform_irq_disable(int irq); +void timer_start(void); +#endif /* __PLATFORM_PB926_PLATFORM_H__ */ diff --git a/include/l4/platform/pb11mpcore/printascii.h b/include/l4/platform/pb11mpcore/printascii.h new file mode 100644 index 0000000..0d0be28 --- /dev/null +++ b/include/l4/platform/pb11mpcore/printascii.h @@ -0,0 +1,15 @@ +#ifndef __PLATFORM__PB926__PRINTASCII__H__ +#define __PLATFORM__PB926__PRINTASCII__H__ + +#define dprintk(str, val) \ +{ \ + printascii(str); \ + printascii("0x"); \ + printhex8((val)); \ + printascii("\n"); \ +} + +void printascii(char *str); +void printhex8(unsigned int); + +#endif /* __PLATFORM__PB926__PRINTASCII__H__ */ diff --git a/include/l4/platform/pb11mpcore/uart.h b/include/l4/platform/pb11mpcore/uart.h new file mode 100644 index 0000000..366590f --- /dev/null +++ b/include/l4/platform/pb11mpcore/uart.h @@ -0,0 +1,20 @@ +/* + * Platform specific ties to generic uart functions that putc expects. + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#ifndef __PLATFORM_PB926_UART_H__ +#define __PLATFORM_PB926_UART_H__ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#include + +void uart_init(void); +void uart_putc(char c); + +#endif /* __PLATFORM_PB926_UART_H__ */ diff --git a/include/l4/platform/pba8/irq.h b/include/l4/platform/pba8/irq.h new file mode 100644 index 0000000..ecfad92 --- /dev/null +++ b/include/l4/platform/pba8/irq.h @@ -0,0 +1,27 @@ +#ifndef __PLATFORM_IRQ_H__ +#define __PLATFORM_IRQ_H__ + +#define IRQ_CHIPS_MAX 2 +#define IRQS_MAX 64 + +/* IRQ indices. */ +#define IRQ_TIMER01 4 +#define IRQ_TIMER23 5 +#define IRQ_RTC 10 +#define IRQ_UART0 12 +#define IRQ_UART1 13 +#define IRQ_UART2 14 +#define IRQ_SIC 31 + +/* Cascading definitions */ + +#define PIC_IRQS_MAX 31 /* Total irqs on PIC */ +/* The local irq line of the dummy peripheral on this chip */ +#define LOCALIRQ_DUMMY 15 +/* The irq index offset of this chip, is the maximum of previous chip + 1 */ +#define SIRQ_CHIP_OFFSET (PIC_IRQS_MAX + 1) +/* The global irq number of dummy is the local irq line + it's chip offset */ +#define IRQ_DUMMY (LOCALIRQ_DUMMY + SIRQ_CHIP_OFFSET) + + +#endif /* __PLATFORM_IRQ_H__ */ diff --git a/include/l4/platform/pba8/offsets.h b/include/l4/platform/pba8/offsets.h new file mode 100644 index 0000000..4a49729 --- /dev/null +++ b/include/l4/platform/pba8/offsets.h @@ -0,0 +1,60 @@ +/* + * Describes physical memory layout of pb926 platform. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#ifndef __PLATFORM_PB926_OFFSETS_H__ +#define __PLATFORM_PB926_OFFSETS_H__ + +/* Physical memory base */ +#define PHYS_MEM_START 0x00000000 /* inclusive */ +#define PHYS_MEM_END 0x08000000 /* 128 MB, exclusive */ + +/* + * These bases taken from where kernel is `physically' linked at, + * also used to calculate virtual-to-physical translation offset. + * See the linker script for their sources. PHYS_ADDR_BASE can't + * use a linker variable because it's referred from assembler. + */ +#define PHYS_ADDR_BASE 0x100000 + +/* Device memory base */ +#define PB926_DEV_PHYS 0x10000000 + +/* Device offsets in physical memory */ +#define PB926_SYSTEM_REGISTERS 0x10000000 /* System registers */ +#define PB926_SYSCTRL_BASE 0x101E0000 /* System controller */ +#define PB926_WATCHDOG_BASE 0x101E1000 /* Watchdog */ +#define PB926_TIMER01_BASE 0x101E2000 /* Timers 0 and 1 */ +#define PB926_TIMER23_BASE 0x101E3000 /* Timers 2 and 3 */ +#define PB926_RTC_BASE 0x101E8000 /* Real Time Clock */ +#define PB926_VIC_BASE 0x10140000 /* Primary Vectored IC */ +#define PB926_SIC_BASE 0x10003000 /* Secondary IC */ +#define PB926_UART0_BASE 0x101F1000 /* Console port (UART0) */ + +/* + * Uart virtual address until a file-based console access + * is available for userspace + */ +#define USERSPACE_UART_BASE 0x500000 + +/* + * Device offsets in virtual memory. They offset to some virtual + * device base address. Each page on this virtual base is consecutively + * allocated to devices. Nice and smooth. + */ +#define PB926_TIMER01_VOFFSET 0x00000000 +#define PB926_UART0_VOFFSET 0x00001000 +#define PB926_VIC_VOFFSET 0x00002000 +#define PB926_SIC_VOFFSET 0x00003000 +#define PB926_SYSREGS_VOFFSET 0x00005000 +#define PB926_SYSCTRL_VOFFSET 0x00006000 + +#define PB926_UART0_VBASE (IO_AREA0_VADDR + PB926_UART0_VOFFSET) +#define PB926_TIMER01_VBASE (IO_AREA0_VADDR + PB926_TIMER01_VOFFSET) +#define PB926_SYSCTRL_VBASE (IO_AREA0_VADDR + PB926_SYSCTRL_VOFFSET) +#define PB926_VIC_VBASE (IO_AREA0_VADDR + PB926_VIC_VOFFSET) +#define PB926_SIC_VBASE (IO_AREA0_VADDR + PB926_SIC_VOFFSET) +#endif /* __PLATFORM_PB926_OFFSETS_H__ */ + diff --git a/include/l4/platform/pba8/platform.h b/include/l4/platform/pba8/platform.h new file mode 100644 index 0000000..dd4f4cb --- /dev/null +++ b/include/l4/platform/pba8/platform.h @@ -0,0 +1,22 @@ +#ifndef __PLATFORM_PB926_PLATFORM_H__ +#define __PLATFORM_PB926_PLATFORM_H__ +/* + * Platform specific ties between drivers and generic APIs used by the kernel. + * E.g. system timer and console. + * + * Copyright (C) Bahadir Balban 2007 + */ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#define PLATFORM_TIMER_BASE PB926_TIMER01_VBASE +#define PLATFORM_SP810_BASE PB926_SYSCTRL_VBASE +#define PLATFORM_IRQCTRL_BASE PB926_VIC_VBASE +#define PLATFORM_SIRQCTRL_BASE PB926_SIC_VBASE + +void platform_irq_enable(int irq); +void platform_irq_disable(int irq); +void timer_start(void); +#endif /* __PLATFORM_PB926_PLATFORM_H__ */ diff --git a/include/l4/platform/pba8/printascii.h b/include/l4/platform/pba8/printascii.h new file mode 100644 index 0000000..0d0be28 --- /dev/null +++ b/include/l4/platform/pba8/printascii.h @@ -0,0 +1,15 @@ +#ifndef __PLATFORM__PB926__PRINTASCII__H__ +#define __PLATFORM__PB926__PRINTASCII__H__ + +#define dprintk(str, val) \ +{ \ + printascii(str); \ + printascii("0x"); \ + printhex8((val)); \ + printascii("\n"); \ +} + +void printascii(char *str); +void printhex8(unsigned int); + +#endif /* __PLATFORM__PB926__PRINTASCII__H__ */ diff --git a/include/l4/platform/pba8/uart.h b/include/l4/platform/pba8/uart.h new file mode 100644 index 0000000..366590f --- /dev/null +++ b/include/l4/platform/pba8/uart.h @@ -0,0 +1,20 @@ +/* + * Platform specific ties to generic uart functions that putc expects. + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#ifndef __PLATFORM_PB926_UART_H__ +#define __PLATFORM_PB926_UART_H__ + +#include INC_PLAT(offsets.h) +#include INC_GLUE(memlayout.h) + +#define PLATFORM_CONSOLE_BASE PB926_UART0_VBASE +#include + +void uart_init(void); +void uart_putc(char c); + +#endif /* __PLATFORM_PB926_UART_H__ */ diff --git a/src/arch/arm/v6/mm.c b/src/arch/arm/v6/mm.c index 190504b..1b7e339 100644 --- a/src/arch/arm/v6/mm.c +++ b/src/arch/arm/v6/mm.c @@ -1,7 +1,726 @@ /* - * - * Copyright Bahadir Balban (C) 2005 - * + * Copyright (C) 2007 Bahadir Balban */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(mmu_ops.h) +#include INC_GLUE(memory.h) +#include INC_PLAT(printascii.h) +#include INC_GLUE(memlayout.h) +#include INC_ARCH(linker.h) +#include INC_ARCH(asm.h) +#include INC_API(kip.h) + +/* + * These are indices into arrays with pgd_t or pmd_t sized elements, + * therefore the index must be divided by appropriate element size + */ +#define PGD_INDEX(x) (((((unsigned long)(x)) >> 18) & 0x3FFC) / sizeof(pgd_t)) +/* Strip out the page offset in this megabyte from a total of 256 pages. */ +#define PMD_INDEX(x) (((((unsigned long)(x)) >> 10) & 0x3FC) / sizeof (pmd_t)) + +/* + * Removes initial mappings needed for transition to virtual memory. + * Used one-time only. + */ +void remove_section_mapping(unsigned long vaddr) +{ + pgd_table_t *pgd = &init_pgd;; + pgd_t pgd_i = PGD_INDEX(vaddr); + if (!((pgd->entry[pgd_i] & PGD_TYPE_MASK) + & PGD_TYPE_SECTION)) + while(1); + pgd->entry[pgd_i] = 0; + pgd->entry[pgd_i] |= PGD_TYPE_FAULT; + arm_invalidate_tlb(); +} + +/* + * Maps given section-aligned @paddr to @vaddr using enough number + * of section-units to fulfill @size in sections. Note this overwrites + * a mapping if same virtual address was already mapped. + */ +void __add_section_mapping_init(unsigned int paddr, + unsigned int vaddr, + unsigned int size, + unsigned int flags) +{ + pte_t *ppte; + unsigned int l1_ptab; + unsigned int l1_offset; + + /* 1st level page table address */ + l1_ptab = virt_to_phys(&init_pgd); + + /* Get the section offset for this vaddr */ + l1_offset = (vaddr >> 18) & 0x3FFC; + + /* The beginning entry for mapping */ + ppte = (unsigned int *)(l1_ptab + l1_offset); + for(int i = 0; i < size; i++) { + *ppte = 0; /* Clear out old value */ + *ppte |= paddr; /* Assign physical address */ + *ppte |= PGD_TYPE_SECTION; /* Assign translation type */ + /* Domain is 0, therefore no writes. */ + /* Only kernel access allowed */ + *ppte |= (SVC_RW_USR_NONE << SECTION_AP0); + /* Cacheability/Bufferability flags */ + *ppte |= flags; + ppte++; /* Next section entry */ + paddr += ARM_SECTION_SIZE; /* Next physical section */ + } + return; +} + +void add_section_mapping_init(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags) +{ + unsigned int psection; + unsigned int vsection; + + /* Align each address to the pages they reside in */ + psection = paddr & ~ARM_SECTION_MASK; + vsection = vaddr & ~ARM_SECTION_MASK; + + if(size == 0) + return; + + __add_section_mapping_init(psection, vsection, size, flags); + + return; +} + +/* TODO: Make sure to flush tlb entry and caches */ +void __add_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int flags, pmd_table_t *pmd) +{ + unsigned int pmd_i = PMD_INDEX(vaddr); + pmd->entry[pmd_i] = paddr; + pmd->entry[pmd_i] |= PMD_TYPE_SMALL; /* Small page type */ + pmd->entry[pmd_i] |= flags; + + /* TODO: Is both required? Investigate */ + + /* TEST: + * I think cleaning or invalidating the cache is not required, + * because the entries in the cache aren't for the new mapping anyway. + * It's required if a mapping is removed, but not when newly added. + */ + arm_clean_invalidate_cache(); + + /* TEST: tlb must be flushed because a new mapping is present in page + * tables, and tlb is inconsistent with the page tables */ + arm_invalidate_tlb(); +} + +/* Return whether a pmd associated with @vaddr is mapped on a pgd or not. */ +pmd_table_t *pmd_exists(pgd_table_t *pgd, unsigned long vaddr) +{ + unsigned int pgd_i = PGD_INDEX(vaddr); + + /* Return true if non-zero pgd entry */ + switch (pgd->entry[pgd_i] & PGD_TYPE_MASK) { + case PGD_TYPE_COARSE: + return (pmd_table_t *) + phys_to_virt((pgd->entry[pgd_i] & + PGD_COARSE_ALIGN_MASK)); + break; + + case PGD_TYPE_FAULT: + return 0; + break; + + case PGD_TYPE_SECTION: + dprintk("Warning, a section is already mapped " + "where a coarse page mapping is attempted:", + (u32)(pgd->entry[pgd_i] + & PGD_SECTION_ALIGN_MASK)); + BUG(); + break; + + case PGD_TYPE_FINE: + dprintk("Warning, a fine page table is already mapped " + "where a coarse page mapping is attempted:", + (u32)(pgd->entry[pgd_i] + & PGD_FINE_ALIGN_MASK)); + printk("Fine tables are unsupported. "); + printk("What is this doing here?"); + BUG(); + break; + + default: + dprintk("Unrecognised pmd type @ pgd index:", pgd_i); + BUG(); + break; + } + return 0; +} + +/* Convert a virtual address to a pte if it exists in the page tables. */ +pte_t virt_to_pte_from_pgd(unsigned long virtual, pgd_table_t *pgd) +{ + pmd_table_t *pmd = pmd_exists(pgd, virtual); + + if (pmd) + return (pte_t)pmd->entry[PMD_INDEX(virtual)]; + else + return (pte_t)0; +} + +/* Convert a virtual address to a pte if it exists in the page tables. */ +pte_t virt_to_pte(unsigned long virtual) +{ + return virt_to_pte_from_pgd(virtual, TASK_PGD(current)); +} + +unsigned long virt_to_phys_by_pgd(unsigned long vaddr, pgd_table_t *pgd) +{ + pte_t pte = virt_to_pte_from_pgd(vaddr, pgd); + return pte & ~PAGE_MASK; +} + +unsigned long virt_to_phys_by_task(unsigned long vaddr, struct ktcb *task) +{ + return virt_to_phys_by_pgd(vaddr, TASK_PGD(task)); +} + +void attach_pmd(pgd_table_t *pgd, pmd_table_t *pmd, unsigned int vaddr) +{ + u32 pgd_i = PGD_INDEX(vaddr); + u32 pmd_phys = virt_to_phys(pmd); + + /* Domain is 0, therefore no writes. */ + pgd->entry[pgd_i] = (pgd_t)pmd_phys; + pgd->entry[pgd_i] |= PGD_TYPE_COARSE; +} + +/* + * Same as normal mapping but with some boot tweaks. + */ +void add_boot_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags) +{ + pmd_table_t *pmd; + pgd_table_t *pgd = &init_pgd; + unsigned int numpages = (size >> PAGE_BITS); + + if (size < PAGE_SIZE) { + printascii("Error: Mapping size must be in bytes not pages.\n"); + while(1); + } + if (size & PAGE_MASK) + numpages++; + + /* Convert generic map flags to pagetable-specific */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + /* Map all consecutive pages that cover given size */ + for (int i = 0; i < numpages; i++) { + /* Check if another mapping already has a pmd attached. */ + pmd = pmd_exists(pgd, vaddr); + if (!pmd) { + /* + * If this is the first vaddr in + * this pmd, allocate new pmd + */ + pmd = alloc_boot_pmd(); + + /* Attach pmd to its entry in pgd */ + attach_pmd(pgd, pmd, vaddr); + } + + /* Attach paddr to this pmd */ + __add_mapping(page_align(paddr), + page_align(vaddr), flags, pmd); + + /* Go to the next page to be mapped */ + paddr += PAGE_SIZE; + vaddr += PAGE_SIZE; + } +} + +/* + * Maps @paddr to @vaddr, covering @size bytes also allocates new pmd if + * necessary. This flavor explicitly supplies the pgd to modify. This is useful + * when modifying userspace of processes that are not currently running. (Only + * makes sense for userspace mappings since kernel mappings are common.) + */ +void add_mapping_pgd(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags, + pgd_table_t *pgd) +{ + pmd_table_t *pmd; + unsigned int numpages = (size >> PAGE_BITS); + if (size < PAGE_SIZE) { + printascii("Error: Mapping size must be in bytes not pages.\n"); + while(1); + } + if (size & PAGE_MASK) + numpages++; + + /* Convert generic map flags to pagetable-specific */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + /* Map all consecutive pages that cover given size */ + for (int i = 0; i < numpages; i++) { + /* Check if another mapping already has a pmd attached. */ + pmd = pmd_exists(pgd, vaddr); + if (!pmd) { + /* + * If this is the first vaddr in + * this pmd, allocate new pmd + */ + pmd = alloc_pmd(); + + /* Attach pmd to its entry in pgd */ + attach_pmd(pgd, pmd, vaddr); + } + + /* Attach paddr to this pmd */ + __add_mapping(page_align(paddr), + page_align(vaddr), flags, pmd); + + /* Go to the next page to be mapped */ + paddr += PAGE_SIZE; + vaddr += PAGE_SIZE; + } +} + +void add_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags) +{ + add_mapping_pgd(paddr, vaddr, size, flags, TASK_PGD(current)); +} + +/* + * Checks if a virtual address range has same or more permissive + * flags than the given ones, returns 0 if not, and 1 if OK. + */ +int check_mapping_pgd(unsigned long vaddr, unsigned long size, + unsigned int flags, pgd_table_t *pgd) +{ + unsigned int npages = __pfn(align_up(size, PAGE_SIZE)); + pte_t pte; + + /* Convert generic map flags to pagetable-specific */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + for (int i = 0; i < npages; i++) { + pte = virt_to_pte_from_pgd(vaddr + i * PAGE_SIZE, pgd); + + /* Check if pte perms are equal or gt given flags */ + if ((pte & PTE_PROT_MASK) >= (flags & PTE_PROT_MASK)) + continue; + else + return 0; + } + + return 1; +} + +int check_mapping(unsigned long vaddr, unsigned long size, + unsigned int flags) +{ + return check_mapping_pgd(vaddr, size, flags, TASK_PGD(current)); +} + +/* FIXME: Empty PMDs should be returned here !!! */ +int __remove_mapping(pmd_table_t *pmd, unsigned long vaddr) +{ + pmd_t pmd_i = PMD_INDEX(vaddr); + int ret; + + switch (pmd->entry[pmd_i] & PMD_TYPE_MASK) { + case PMD_TYPE_FAULT: + ret = -ENOENT; + break; + case PMD_TYPE_LARGE: + pmd->entry[pmd_i] = 0; + pmd->entry[pmd_i] |= PMD_TYPE_FAULT; + ret = 0; + break; + case PMD_TYPE_SMALL: + pmd->entry[pmd_i] = 0; + pmd->entry[pmd_i] |= PMD_TYPE_FAULT; + ret = 0; + break; + default: + printk("Unknown page mapping in pmd. Assuming bug.\n"); + BUG(); + } + return ret; +} + +/* + * Tell if a pgd index is a common kernel index. This is used to distinguish + * common kernel entries in a pgd, when copying page tables. + */ +int is_kern_pgdi(int i) +{ + if ((i >= PGD_INDEX(KERNEL_AREA_START) && i < PGD_INDEX(KERNEL_AREA_END)) || + (i >= PGD_INDEX(IO_AREA_START) && i < PGD_INDEX(IO_AREA_END)) || + (i == PGD_INDEX(USER_KIP_PAGE)) || + (i == PGD_INDEX(ARM_HIGH_VECTOR)) || + (i == PGD_INDEX(ARM_SYSCALL_VECTOR)) || + (i == PGD_INDEX(USERSPACE_UART_BASE))) + return 1; + else + return 0; +} + +/* + * Removes all userspace mappings from a pgd. Frees any pmds that it + * detects to be user pmds + */ +int remove_mapping_pgd_all_user(pgd_table_t *pgd) +{ + pmd_table_t *pmd; + + /* Traverse through all pgd entries */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + + /* Detect a pgd entry that is not a kernel entry */ + if (!is_kern_pgdi(i)) { + + /* Detect a pmd entry */ + if (((pgd->entry[i] & PGD_TYPE_MASK) + == PGD_TYPE_COARSE)) { + + /* Obtain the user pmd handle */ + pmd = (pmd_table_t *) + phys_to_virt((pgd->entry[i] & + PGD_COARSE_ALIGN_MASK)); + /* Free it */ + free_pmd(pmd); + } + + /* Clear the pgd entry */ + pgd->entry[i] = PGD_TYPE_FAULT; + } + } + + return 0; +} + +int remove_mapping_pgd(unsigned long vaddr, pgd_table_t *pgd) +{ + pgd_t pgd_i = PGD_INDEX(vaddr); + pmd_table_t *pmd; + pmd_t pmd_i; + int ret; + + /* + * Clean the cache to main memory before removing the mapping. Otherwise + * entries in the cache for this mapping will cause tranlation faults + * if they're cleaned to main memory after the mapping is removed. + */ + arm_clean_invalidate_cache(); + + /* TEST: + * Can't think of a valid reason to flush tlbs here, but keeping it just + * to be safe. REMOVE: Remove it if it's unnecessary. + */ + arm_invalidate_tlb(); + + /* Return true if non-zero pgd entry */ + switch (pgd->entry[pgd_i] & PGD_TYPE_MASK) { + case PGD_TYPE_COARSE: + // printk("Removing coarse mapping @ 0x%x\n", vaddr); + pmd = (pmd_table_t *) + phys_to_virt((pgd->entry[pgd_i] + & PGD_COARSE_ALIGN_MASK)); + pmd_i = PMD_INDEX(vaddr); + ret = __remove_mapping(pmd, vaddr); + break; + + case PGD_TYPE_FAULT: + ret = -1; + break; + + case PGD_TYPE_SECTION: + printk("Removing section mapping for 0x%lx", + vaddr); + pgd->entry[pgd_i] = 0; + pgd->entry[pgd_i] |= PGD_TYPE_FAULT; + ret = 0; + break; + + case PGD_TYPE_FINE: + printk("Table mapped is a fine page table.\n" + "Fine tables are unsupported. Assuming bug.\n"); + BUG(); + break; + + default: + dprintk("Unrecognised pmd type @ pgd index:", pgd_i); + printk("Assuming bug.\n"); + BUG(); + break; + } + /* The tlb must be invalidated here because it might have cached the + * old translation for this mapping. */ + arm_invalidate_tlb(); + + return ret; +} + +int remove_mapping(unsigned long vaddr) +{ + return remove_mapping_pgd(vaddr, TASK_PGD(current)); +} + +int delete_page_tables(struct address_space *space) +{ + remove_mapping_pgd_all_user(space->pgd); + free_pgd(space->pgd); + return 0; +} + +/* + * Copies userspace entries of one task to another. In order to do that, + * it allocates new pmds and copies the original values into new ones. + */ +int copy_user_tables(struct address_space *new, struct address_space *orig_space) +{ + pgd_table_t *to = new->pgd, *from = orig_space->pgd; + pmd_table_t *pmd, *orig; + + /* Allocate and copy all pmds that will be exclusive to new task. */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Detect a pmd entry that is not a kernel pmd? */ + if (!is_kern_pgdi(i) && + ((from->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE)) { + /* Allocate new pmd */ + if (!(pmd = alloc_pmd())) + goto out_error; + + /* Find original pmd */ + orig = (pmd_table_t *) + phys_to_virt((from->entry[i] & + PGD_COARSE_ALIGN_MASK)); + + /* Copy original to new */ + memcpy(pmd, orig, sizeof(pmd_table_t)); + + /* Replace original pmd entry in pgd with new */ + to->entry[i] = (pgd_t)virt_to_phys(pmd); + to->entry[i] |= PGD_TYPE_COARSE; + } + } + + return 0; + +out_error: + /* Find all non-kernel pmds we have just allocated and free them */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Non-kernel pmd that has just been allocated. */ + if (!is_kern_pgdi(i) && + (to->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) { + /* Obtain the pmd handle */ + pmd = (pmd_table_t *) + phys_to_virt((to->entry[i] & + PGD_COARSE_ALIGN_MASK)); + /* Free pmd */ + free_pmd(pmd); + } + } + return -ENOMEM; +} + +int pgd_count_pmds(pgd_table_t *pgd) +{ + int npmd = 0; + + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) + if ((pgd->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) + npmd++; + return npmd; +} + +/* + * Allocates and copies all levels of page tables from one task to another. + * Useful when forking. + * + * The copied page tables end up having shared pmds for kernel entries + * and private copies of same pmds for user entries. + */ +pgd_table_t *copy_page_tables(pgd_table_t *from) +{ + pmd_table_t *pmd, *orig; + pgd_table_t *pgd; + + /* Allocate and copy pgd. This includes all kernel entries */ + if (!(pgd = alloc_pgd())) + return PTR_ERR(-ENOMEM); + + /* First copy whole pgd entries */ + memcpy(pgd, from, sizeof(pgd_table_t)); + + /* Allocate and copy all pmds that will be exclusive to new task. */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Detect a pmd entry that is not a kernel pmd? */ + if (!is_kern_pgdi(i) && + ((pgd->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE)) { + /* Allocate new pmd */ + if (!(pmd = alloc_pmd())) + goto out_error; + + /* Find original pmd */ + orig = (pmd_table_t *) + phys_to_virt((pgd->entry[i] & + PGD_COARSE_ALIGN_MASK)); + + /* Copy original to new */ + memcpy(pmd, orig, sizeof(pmd_table_t)); + + /* Replace original pmd entry in pgd with new */ + pgd->entry[i] = (pgd_t)virt_to_phys(pmd); + pgd->entry[i] |= PGD_TYPE_COARSE; + } + } + + return pgd; + +out_error: + /* Find all allocated non-kernel pmds and free them */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Non-kernel pmd that has just been allocated. */ + if (!is_kern_pgdi(i) && + (pgd->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) { + /* Obtain the pmd handle */ + pmd = (pmd_table_t *) + phys_to_virt((pgd->entry[i] & + PGD_COARSE_ALIGN_MASK)); + /* Free pmd */ + free_pmd(pmd); + } + } + /* Free the pgd */ + free_pgd(pgd); + return PTR_ERR(-ENOMEM); +} + +extern pmd_table_t *pmd_array; + +/* + * Jumps from boot pmd/pgd page tables to tables allocated from the cache. + */ +pgd_table_t *realloc_page_tables(void) +{ + pgd_table_t *pgd_new = alloc_pgd(); + pgd_table_t *pgd_old = &init_pgd; + pmd_table_t *orig, *pmd; + + /* Copy whole pgd entries */ + memcpy(pgd_new, pgd_old, sizeof(pgd_table_t)); + + /* Allocate and copy all pmds */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Detect a pmd entry */ + if ((pgd_old->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) { + /* Allocate new pmd */ + if (!(pmd = alloc_pmd())) { + printk("FATAL: PMD allocation " + "failed during system initialization\n"); + BUG(); + } + + /* Find original pmd */ + orig = (pmd_table_t *) + phys_to_virt((pgd_old->entry[i] & + PGD_COARSE_ALIGN_MASK)); + + /* Copy original to new */ + memcpy(pmd, orig, sizeof(pmd_table_t)); + + /* Replace original pmd entry in pgd with new */ + pgd_new->entry[i] = (pgd_t)virt_to_phys(pmd); + pgd_new->entry[i] |= PGD_TYPE_COARSE; + } + } + + /* Switch the virtual memory system into new area */ + arm_clean_invalidate_cache(); + arm_drain_writebuffer(); + arm_invalidate_tlb(); + arm_set_ttb(virt_to_phys(pgd_new)); + arm_invalidate_tlb(); + + printk("%s: Initial page tables moved from 0x%x to 0x%x physical\n", + __KERNELNAME__, virt_to_phys(pgd_old), + virt_to_phys(pgd_new)); + + return pgd_new; +} + +/* + * Useful for upgrading to page-grained control over a section mapping: + * Remaps a section mapping in pages. It allocates a pmd, (at all times because + * there can't really be an already existing pmd for a section mapping) fills + * in the page information, and origaces the direct section physical translation + * with the address of the pmd. Flushes the caches/tlbs. + */ +void remap_as_pages(void *vstart, void *vend) +{ + unsigned long pstart = virt_to_phys(vstart); + unsigned long pend = virt_to_phys(vend); + unsigned long paddr = pstart; + pgd_t pgd_i = PGD_INDEX(vstart); + pmd_t pmd_i = PMD_INDEX(vstart); + pgd_table_t *pgd = &init_pgd; + pmd_table_t *pmd = alloc_boot_pmd(); + u32 pmd_phys = virt_to_phys(pmd); + int numpages = __pfn(pend - pstart); + + /* Fill in the pmd first */ + for (int n = 0; n < numpages; n++) { + pmd->entry[pmd_i + n] = paddr; + pmd->entry[pmd_i + n] |= PMD_TYPE_SMALL; /* Small page type */ + pmd->entry[pmd_i + n] |= space_flags_to_ptflags(MAP_SVC_DEFAULT_FLAGS); + paddr += PAGE_SIZE; + } + + /* Fill in the type to produce a complete pmd translator information */ + pmd_phys |= PGD_TYPE_COARSE; + + /* Make sure memory is coherent first. */ + arm_clean_invalidate_cache(); + arm_invalidate_tlb(); + + /* Replace the direct section physical address with pmd's address */ + pgd->entry[pgd_i] = (pgd_t)pmd_phys; + printk("%s: Kernel area 0x%lx - 0x%lx remapped as %d pages\n", __KERNELNAME__, + (unsigned long)vstart, (unsigned long)vend, numpages); +} + +void copy_pgds_by_vrange(pgd_table_t *to, pgd_table_t *from, + unsigned long start, unsigned long end) +{ + unsigned long start_i = PGD_INDEX(start); + unsigned long end_i = PGD_INDEX(end); + unsigned long irange = (end_i != 0) ? (end_i - start_i) + : (PGD_ENTRY_TOTAL - start_i); + + memcpy(&to->entry[start_i], &from->entry[start_i], + irange * sizeof(pgd_t)); +} + + +/* Scheduler uses this to switch context */ +void arch_hardware_flush(pgd_table_t *pgd) +{ + arm_clean_invalidate_cache(); + arm_invalidate_tlb(); + arm_set_ttb(virt_to_phys(pgd)); + arm_invalidate_tlb(); +} + diff --git a/src/arch/arm/v6/mmu_ops.S b/src/arch/arm/v6/mmu_ops.S index e69de29..eb6d9da 100644 --- a/src/arch/arm/v6/mmu_ops.S +++ b/src/arch/arm/v6/mmu_ops.S @@ -0,0 +1,155 @@ +/* + * low-level mmu operations + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include INC_ARCH(asm.h) + +#define C15_id c0 +#define C15_control c1 +#define C15_ttb c2 +#define C15_dom c3 +#define C15_fsr c5 +#define C15_far c6 +#define C15_tlb c8 + +#define C15_C0_M 0x0001 /* MMU */ +#define C15_C0_A 0x0002 /* Alignment */ +#define C15_C0_C 0x0004 /* (D) Cache */ +#define C15_C0_W 0x0008 /* Write buffer */ +#define C15_C0_B 0x0080 /* Endianness */ +#define C15_C0_S 0x0100 /* System */ +#define C15_C0_R 0x0200 /* ROM */ +#define C15_C0_Z 0x0800 /* Branch Prediction */ +#define C15_C0_I 0x1000 /* I cache */ +#define C15_C0_V 0x2000 /* High vectors */ + +/* FIXME: Make sure the ops that need r0 dont trash r0, or if they do, + * save it on stack before these operations. + */ + +/* + * In ARM terminology, flushing the cache means invalidating its contents. + * Cleaning the cache means, writing the contents of the cache back to + * main memory. In write-back caches the cache must be cleaned before + * flushing otherwise in-cache data is lost. + */ + +BEGIN_PROC(arm_set_ttb) + mcr p15, 0, r0, C15_ttb, c0, 0 + mov pc, lr +END_PROC(arm_set_ttb) + +BEGIN_PROC(arm_get_domain) + mrc p15, 0, r0, C15_dom, c0, 0 + mov pc, lr +END_PROC(arm_get_domain) + +BEGIN_PROC(arm_set_domain) + mcr p15, 0, r0, C15_dom, c0, 0 + mov pc, lr +END_PROC(arm_set_domain) + +BEGIN_PROC(arm_enable_mmu) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_M + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_mmu) + +BEGIN_PROC(arm_enable_icache) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_I + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_icache) + +BEGIN_PROC(arm_enable_dcache) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_C + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_dcache) + +BEGIN_PROC(arm_enable_wbuffer) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_W + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_wbuffer) + +BEGIN_PROC(arm_enable_high_vectors) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_V + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_high_vectors) + +BEGIN_PROC(arm_invalidate_cache) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c7 @ Flush I cache and D cache + mov pc, lr +END_PROC(arm_invalidate_cache) + +BEGIN_PROC(arm_invalidate_icache) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c5, 0 @ Flush I cache + mov pc, lr +END_PROC(arm_invalidate_icache) + +BEGIN_PROC(arm_invalidate_dcache) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c6, 0 @ Flush D cache + mov pc, lr +END_PROC(arm_invalidate_dcache) + +BEGIN_PROC(arm_clean_dcache) + mcr p15, 0 , pc, c7, c10, 3 @ Test/clean dcache line + bne arm_clean_dcache + mcr p15, 0, ip, c7, c10, 4 @ Drain WB + mov pc, lr +END_PROC(arm_clean_dcache) + +BEGIN_PROC(arm_clean_invalidate_dcache) +1: + mrc p15, 0, pc, c7, c14, 3 @ Test/clean/flush dcache line + @ COMMENT: Why use PC? + bne 1b + mcr p15, 0, ip, c7, c10, 4 @ Drain WB + mov pc, lr +END_PROC(arm_clean_invalidate_dcache) + +BEGIN_PROC(arm_clean_invalidate_cache) +1: + mrc p15, 0, r15, c7, c14, 3 @ Test/clean/flush dcache line + @ COMMENT: Why use PC? + bne 1b + mcr p15, 0, ip, c7, c5, 0 @ Flush icache + mcr p15, 0, ip, c7, c10, 4 @ Drain WB + mov pc, lr +END_PROC(arm_clean_invalidate_cache) + +BEGIN_PROC(arm_drain_writebuffer) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c10, 4 + mov pc, lr +END_PROC(arm_drain_writebuffer) + +BEGIN_PROC(arm_invalidate_tlb) + mcr p15, 0, ip, c8, c7 + mov pc, lr +END_PROC(arm_invalidate_tlb) + +BEGIN_PROC(arm_invalidate_itlb) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c8, c5, 0 + mov pc, lr +END_PROC(arm_invalidate_itlb) + +BEGIN_PROC(arm_invalidate_dtlb) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c8, c6, 0 + mov pc, lr +END_PROC(arm_invalidate_dtlb) + diff --git a/src/arch/arm/v6/mutex.S b/src/arch/arm/v6/mutex.S new file mode 100644 index 0000000..bc81708 --- /dev/null +++ b/src/arch/arm/v6/mutex.S @@ -0,0 +1,90 @@ +/* + * ARM v5 Binary semaphore (mutex) implementation. + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#include INC_ARCH(asm.h) + +/* Recap on swp: + * swp rx, ry, [rz] + * In one instruction: + * 1) Stores the value in ry into location pointed by rz. + * 2) Loads the value in the location of rz into rx. + * By doing so, in one instruction one can attempt to lock + * a word, and discover whether it was already locked. + */ + +#define MUTEX_UNLOCKED 0 +#define MUTEX_LOCKED 1 + +BEGIN_PROC(__spin_lock) + mov r1, #1 +__spin: + swp r2, r1, [r0] + cmp r2, #0 + bne __spin + mov pc, lr +END_PROC(__spin_lock) + +BEGIN_PROC(__spin_unlock) + mov r1, #0 + swp r2, r1, [r0] + cmp r2, #1 @ Debug check. +1: + bne 1b + mov pc, lr +END_PROC(__spin_unlock) + + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_lock) + mov r1, #1 + swp r2, r1, [r0] + cmp r2, #0 + movne r0, #0 + moveq r0, #1 + mov pc, lr +END_PROC(__mutex_lock) + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_unlock) + mov r1, #0 + swp r2, r1, [r0] + cmp r2, #1 +1: @ Debug check. + bne 1b + mov pc, lr +END_PROC(__mutex_unlock) + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_inc) + swp r2, r1, [r0] + mov r1, #1 + swp r2, r1, [r0] + cmp r2, #0 + movne r0, #0 + moveq r0, #1 + mov pc, lr +END_PROC(__mutex_inc) + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_dec) + mov r1, #0 + swp r2, r1, [r0] + cmp r2, #1 +1: @ Debug check. + bne 1b + mov pc, lr +END_PROC(__mutex_dec) + + diff --git a/src/arch/arm/v7/mm.c b/src/arch/arm/v7/mm.c new file mode 100644 index 0000000..1b7e339 --- /dev/null +++ b/src/arch/arm/v7/mm.c @@ -0,0 +1,726 @@ +/* + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(mmu_ops.h) +#include INC_GLUE(memory.h) +#include INC_PLAT(printascii.h) +#include INC_GLUE(memlayout.h) +#include INC_ARCH(linker.h) +#include INC_ARCH(asm.h) +#include INC_API(kip.h) + +/* + * These are indices into arrays with pgd_t or pmd_t sized elements, + * therefore the index must be divided by appropriate element size + */ +#define PGD_INDEX(x) (((((unsigned long)(x)) >> 18) & 0x3FFC) / sizeof(pgd_t)) +/* Strip out the page offset in this megabyte from a total of 256 pages. */ +#define PMD_INDEX(x) (((((unsigned long)(x)) >> 10) & 0x3FC) / sizeof (pmd_t)) + +/* + * Removes initial mappings needed for transition to virtual memory. + * Used one-time only. + */ +void remove_section_mapping(unsigned long vaddr) +{ + pgd_table_t *pgd = &init_pgd;; + pgd_t pgd_i = PGD_INDEX(vaddr); + if (!((pgd->entry[pgd_i] & PGD_TYPE_MASK) + & PGD_TYPE_SECTION)) + while(1); + pgd->entry[pgd_i] = 0; + pgd->entry[pgd_i] |= PGD_TYPE_FAULT; + arm_invalidate_tlb(); +} + +/* + * Maps given section-aligned @paddr to @vaddr using enough number + * of section-units to fulfill @size in sections. Note this overwrites + * a mapping if same virtual address was already mapped. + */ +void __add_section_mapping_init(unsigned int paddr, + unsigned int vaddr, + unsigned int size, + unsigned int flags) +{ + pte_t *ppte; + unsigned int l1_ptab; + unsigned int l1_offset; + + /* 1st level page table address */ + l1_ptab = virt_to_phys(&init_pgd); + + /* Get the section offset for this vaddr */ + l1_offset = (vaddr >> 18) & 0x3FFC; + + /* The beginning entry for mapping */ + ppte = (unsigned int *)(l1_ptab + l1_offset); + for(int i = 0; i < size; i++) { + *ppte = 0; /* Clear out old value */ + *ppte |= paddr; /* Assign physical address */ + *ppte |= PGD_TYPE_SECTION; /* Assign translation type */ + /* Domain is 0, therefore no writes. */ + /* Only kernel access allowed */ + *ppte |= (SVC_RW_USR_NONE << SECTION_AP0); + /* Cacheability/Bufferability flags */ + *ppte |= flags; + ppte++; /* Next section entry */ + paddr += ARM_SECTION_SIZE; /* Next physical section */ + } + return; +} + +void add_section_mapping_init(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags) +{ + unsigned int psection; + unsigned int vsection; + + /* Align each address to the pages they reside in */ + psection = paddr & ~ARM_SECTION_MASK; + vsection = vaddr & ~ARM_SECTION_MASK; + + if(size == 0) + return; + + __add_section_mapping_init(psection, vsection, size, flags); + + return; +} + +/* TODO: Make sure to flush tlb entry and caches */ +void __add_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int flags, pmd_table_t *pmd) +{ + unsigned int pmd_i = PMD_INDEX(vaddr); + pmd->entry[pmd_i] = paddr; + pmd->entry[pmd_i] |= PMD_TYPE_SMALL; /* Small page type */ + pmd->entry[pmd_i] |= flags; + + /* TODO: Is both required? Investigate */ + + /* TEST: + * I think cleaning or invalidating the cache is not required, + * because the entries in the cache aren't for the new mapping anyway. + * It's required if a mapping is removed, but not when newly added. + */ + arm_clean_invalidate_cache(); + + /* TEST: tlb must be flushed because a new mapping is present in page + * tables, and tlb is inconsistent with the page tables */ + arm_invalidate_tlb(); +} + +/* Return whether a pmd associated with @vaddr is mapped on a pgd or not. */ +pmd_table_t *pmd_exists(pgd_table_t *pgd, unsigned long vaddr) +{ + unsigned int pgd_i = PGD_INDEX(vaddr); + + /* Return true if non-zero pgd entry */ + switch (pgd->entry[pgd_i] & PGD_TYPE_MASK) { + case PGD_TYPE_COARSE: + return (pmd_table_t *) + phys_to_virt((pgd->entry[pgd_i] & + PGD_COARSE_ALIGN_MASK)); + break; + + case PGD_TYPE_FAULT: + return 0; + break; + + case PGD_TYPE_SECTION: + dprintk("Warning, a section is already mapped " + "where a coarse page mapping is attempted:", + (u32)(pgd->entry[pgd_i] + & PGD_SECTION_ALIGN_MASK)); + BUG(); + break; + + case PGD_TYPE_FINE: + dprintk("Warning, a fine page table is already mapped " + "where a coarse page mapping is attempted:", + (u32)(pgd->entry[pgd_i] + & PGD_FINE_ALIGN_MASK)); + printk("Fine tables are unsupported. "); + printk("What is this doing here?"); + BUG(); + break; + + default: + dprintk("Unrecognised pmd type @ pgd index:", pgd_i); + BUG(); + break; + } + return 0; +} + +/* Convert a virtual address to a pte if it exists in the page tables. */ +pte_t virt_to_pte_from_pgd(unsigned long virtual, pgd_table_t *pgd) +{ + pmd_table_t *pmd = pmd_exists(pgd, virtual); + + if (pmd) + return (pte_t)pmd->entry[PMD_INDEX(virtual)]; + else + return (pte_t)0; +} + +/* Convert a virtual address to a pte if it exists in the page tables. */ +pte_t virt_to_pte(unsigned long virtual) +{ + return virt_to_pte_from_pgd(virtual, TASK_PGD(current)); +} + +unsigned long virt_to_phys_by_pgd(unsigned long vaddr, pgd_table_t *pgd) +{ + pte_t pte = virt_to_pte_from_pgd(vaddr, pgd); + return pte & ~PAGE_MASK; +} + +unsigned long virt_to_phys_by_task(unsigned long vaddr, struct ktcb *task) +{ + return virt_to_phys_by_pgd(vaddr, TASK_PGD(task)); +} + +void attach_pmd(pgd_table_t *pgd, pmd_table_t *pmd, unsigned int vaddr) +{ + u32 pgd_i = PGD_INDEX(vaddr); + u32 pmd_phys = virt_to_phys(pmd); + + /* Domain is 0, therefore no writes. */ + pgd->entry[pgd_i] = (pgd_t)pmd_phys; + pgd->entry[pgd_i] |= PGD_TYPE_COARSE; +} + +/* + * Same as normal mapping but with some boot tweaks. + */ +void add_boot_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags) +{ + pmd_table_t *pmd; + pgd_table_t *pgd = &init_pgd; + unsigned int numpages = (size >> PAGE_BITS); + + if (size < PAGE_SIZE) { + printascii("Error: Mapping size must be in bytes not pages.\n"); + while(1); + } + if (size & PAGE_MASK) + numpages++; + + /* Convert generic map flags to pagetable-specific */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + /* Map all consecutive pages that cover given size */ + for (int i = 0; i < numpages; i++) { + /* Check if another mapping already has a pmd attached. */ + pmd = pmd_exists(pgd, vaddr); + if (!pmd) { + /* + * If this is the first vaddr in + * this pmd, allocate new pmd + */ + pmd = alloc_boot_pmd(); + + /* Attach pmd to its entry in pgd */ + attach_pmd(pgd, pmd, vaddr); + } + + /* Attach paddr to this pmd */ + __add_mapping(page_align(paddr), + page_align(vaddr), flags, pmd); + + /* Go to the next page to be mapped */ + paddr += PAGE_SIZE; + vaddr += PAGE_SIZE; + } +} + +/* + * Maps @paddr to @vaddr, covering @size bytes also allocates new pmd if + * necessary. This flavor explicitly supplies the pgd to modify. This is useful + * when modifying userspace of processes that are not currently running. (Only + * makes sense for userspace mappings since kernel mappings are common.) + */ +void add_mapping_pgd(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags, + pgd_table_t *pgd) +{ + pmd_table_t *pmd; + unsigned int numpages = (size >> PAGE_BITS); + + + if (size < PAGE_SIZE) { + printascii("Error: Mapping size must be in bytes not pages.\n"); + while(1); + } + if (size & PAGE_MASK) + numpages++; + + /* Convert generic map flags to pagetable-specific */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + /* Map all consecutive pages that cover given size */ + for (int i = 0; i < numpages; i++) { + /* Check if another mapping already has a pmd attached. */ + pmd = pmd_exists(pgd, vaddr); + if (!pmd) { + /* + * If this is the first vaddr in + * this pmd, allocate new pmd + */ + pmd = alloc_pmd(); + + /* Attach pmd to its entry in pgd */ + attach_pmd(pgd, pmd, vaddr); + } + + /* Attach paddr to this pmd */ + __add_mapping(page_align(paddr), + page_align(vaddr), flags, pmd); + + /* Go to the next page to be mapped */ + paddr += PAGE_SIZE; + vaddr += PAGE_SIZE; + } +} + +void add_mapping(unsigned int paddr, unsigned int vaddr, + unsigned int size, unsigned int flags) +{ + add_mapping_pgd(paddr, vaddr, size, flags, TASK_PGD(current)); +} + +/* + * Checks if a virtual address range has same or more permissive + * flags than the given ones, returns 0 if not, and 1 if OK. + */ +int check_mapping_pgd(unsigned long vaddr, unsigned long size, + unsigned int flags, pgd_table_t *pgd) +{ + unsigned int npages = __pfn(align_up(size, PAGE_SIZE)); + pte_t pte; + + /* Convert generic map flags to pagetable-specific */ + BUG_ON(!(flags = space_flags_to_ptflags(flags))); + + for (int i = 0; i < npages; i++) { + pte = virt_to_pte_from_pgd(vaddr + i * PAGE_SIZE, pgd); + + /* Check if pte perms are equal or gt given flags */ + if ((pte & PTE_PROT_MASK) >= (flags & PTE_PROT_MASK)) + continue; + else + return 0; + } + + return 1; +} + +int check_mapping(unsigned long vaddr, unsigned long size, + unsigned int flags) +{ + return check_mapping_pgd(vaddr, size, flags, TASK_PGD(current)); +} + +/* FIXME: Empty PMDs should be returned here !!! */ +int __remove_mapping(pmd_table_t *pmd, unsigned long vaddr) +{ + pmd_t pmd_i = PMD_INDEX(vaddr); + int ret; + + switch (pmd->entry[pmd_i] & PMD_TYPE_MASK) { + case PMD_TYPE_FAULT: + ret = -ENOENT; + break; + case PMD_TYPE_LARGE: + pmd->entry[pmd_i] = 0; + pmd->entry[pmd_i] |= PMD_TYPE_FAULT; + ret = 0; + break; + case PMD_TYPE_SMALL: + pmd->entry[pmd_i] = 0; + pmd->entry[pmd_i] |= PMD_TYPE_FAULT; + ret = 0; + break; + default: + printk("Unknown page mapping in pmd. Assuming bug.\n"); + BUG(); + } + return ret; +} + +/* + * Tell if a pgd index is a common kernel index. This is used to distinguish + * common kernel entries in a pgd, when copying page tables. + */ +int is_kern_pgdi(int i) +{ + if ((i >= PGD_INDEX(KERNEL_AREA_START) && i < PGD_INDEX(KERNEL_AREA_END)) || + (i >= PGD_INDEX(IO_AREA_START) && i < PGD_INDEX(IO_AREA_END)) || + (i == PGD_INDEX(USER_KIP_PAGE)) || + (i == PGD_INDEX(ARM_HIGH_VECTOR)) || + (i == PGD_INDEX(ARM_SYSCALL_VECTOR)) || + (i == PGD_INDEX(USERSPACE_UART_BASE))) + return 1; + else + return 0; +} + +/* + * Removes all userspace mappings from a pgd. Frees any pmds that it + * detects to be user pmds + */ +int remove_mapping_pgd_all_user(pgd_table_t *pgd) +{ + pmd_table_t *pmd; + + /* Traverse through all pgd entries */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + + /* Detect a pgd entry that is not a kernel entry */ + if (!is_kern_pgdi(i)) { + + /* Detect a pmd entry */ + if (((pgd->entry[i] & PGD_TYPE_MASK) + == PGD_TYPE_COARSE)) { + + /* Obtain the user pmd handle */ + pmd = (pmd_table_t *) + phys_to_virt((pgd->entry[i] & + PGD_COARSE_ALIGN_MASK)); + /* Free it */ + free_pmd(pmd); + } + + /* Clear the pgd entry */ + pgd->entry[i] = PGD_TYPE_FAULT; + } + } + + return 0; +} + +int remove_mapping_pgd(unsigned long vaddr, pgd_table_t *pgd) +{ + pgd_t pgd_i = PGD_INDEX(vaddr); + pmd_table_t *pmd; + pmd_t pmd_i; + int ret; + + /* + * Clean the cache to main memory before removing the mapping. Otherwise + * entries in the cache for this mapping will cause tranlation faults + * if they're cleaned to main memory after the mapping is removed. + */ + arm_clean_invalidate_cache(); + + /* TEST: + * Can't think of a valid reason to flush tlbs here, but keeping it just + * to be safe. REMOVE: Remove it if it's unnecessary. + */ + arm_invalidate_tlb(); + + /* Return true if non-zero pgd entry */ + switch (pgd->entry[pgd_i] & PGD_TYPE_MASK) { + case PGD_TYPE_COARSE: + // printk("Removing coarse mapping @ 0x%x\n", vaddr); + pmd = (pmd_table_t *) + phys_to_virt((pgd->entry[pgd_i] + & PGD_COARSE_ALIGN_MASK)); + pmd_i = PMD_INDEX(vaddr); + ret = __remove_mapping(pmd, vaddr); + break; + + case PGD_TYPE_FAULT: + ret = -1; + break; + + case PGD_TYPE_SECTION: + printk("Removing section mapping for 0x%lx", + vaddr); + pgd->entry[pgd_i] = 0; + pgd->entry[pgd_i] |= PGD_TYPE_FAULT; + ret = 0; + break; + + case PGD_TYPE_FINE: + printk("Table mapped is a fine page table.\n" + "Fine tables are unsupported. Assuming bug.\n"); + BUG(); + break; + + default: + dprintk("Unrecognised pmd type @ pgd index:", pgd_i); + printk("Assuming bug.\n"); + BUG(); + break; + } + /* The tlb must be invalidated here because it might have cached the + * old translation for this mapping. */ + arm_invalidate_tlb(); + + return ret; +} + +int remove_mapping(unsigned long vaddr) +{ + return remove_mapping_pgd(vaddr, TASK_PGD(current)); +} + +int delete_page_tables(struct address_space *space) +{ + remove_mapping_pgd_all_user(space->pgd); + free_pgd(space->pgd); + return 0; +} + +/* + * Copies userspace entries of one task to another. In order to do that, + * it allocates new pmds and copies the original values into new ones. + */ +int copy_user_tables(struct address_space *new, struct address_space *orig_space) +{ + pgd_table_t *to = new->pgd, *from = orig_space->pgd; + pmd_table_t *pmd, *orig; + + /* Allocate and copy all pmds that will be exclusive to new task. */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Detect a pmd entry that is not a kernel pmd? */ + if (!is_kern_pgdi(i) && + ((from->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE)) { + /* Allocate new pmd */ + if (!(pmd = alloc_pmd())) + goto out_error; + + /* Find original pmd */ + orig = (pmd_table_t *) + phys_to_virt((from->entry[i] & + PGD_COARSE_ALIGN_MASK)); + + /* Copy original to new */ + memcpy(pmd, orig, sizeof(pmd_table_t)); + + /* Replace original pmd entry in pgd with new */ + to->entry[i] = (pgd_t)virt_to_phys(pmd); + to->entry[i] |= PGD_TYPE_COARSE; + } + } + + return 0; + +out_error: + /* Find all non-kernel pmds we have just allocated and free them */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Non-kernel pmd that has just been allocated. */ + if (!is_kern_pgdi(i) && + (to->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) { + /* Obtain the pmd handle */ + pmd = (pmd_table_t *) + phys_to_virt((to->entry[i] & + PGD_COARSE_ALIGN_MASK)); + /* Free pmd */ + free_pmd(pmd); + } + } + return -ENOMEM; +} + +int pgd_count_pmds(pgd_table_t *pgd) +{ + int npmd = 0; + + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) + if ((pgd->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) + npmd++; + return npmd; +} + +/* + * Allocates and copies all levels of page tables from one task to another. + * Useful when forking. + * + * The copied page tables end up having shared pmds for kernel entries + * and private copies of same pmds for user entries. + */ +pgd_table_t *copy_page_tables(pgd_table_t *from) +{ + pmd_table_t *pmd, *orig; + pgd_table_t *pgd; + + /* Allocate and copy pgd. This includes all kernel entries */ + if (!(pgd = alloc_pgd())) + return PTR_ERR(-ENOMEM); + + /* First copy whole pgd entries */ + memcpy(pgd, from, sizeof(pgd_table_t)); + + /* Allocate and copy all pmds that will be exclusive to new task. */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Detect a pmd entry that is not a kernel pmd? */ + if (!is_kern_pgdi(i) && + ((pgd->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE)) { + /* Allocate new pmd */ + if (!(pmd = alloc_pmd())) + goto out_error; + + /* Find original pmd */ + orig = (pmd_table_t *) + phys_to_virt((pgd->entry[i] & + PGD_COARSE_ALIGN_MASK)); + + /* Copy original to new */ + memcpy(pmd, orig, sizeof(pmd_table_t)); + + /* Replace original pmd entry in pgd with new */ + pgd->entry[i] = (pgd_t)virt_to_phys(pmd); + pgd->entry[i] |= PGD_TYPE_COARSE; + } + } + + return pgd; + +out_error: + /* Find all allocated non-kernel pmds and free them */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Non-kernel pmd that has just been allocated. */ + if (!is_kern_pgdi(i) && + (pgd->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) { + /* Obtain the pmd handle */ + pmd = (pmd_table_t *) + phys_to_virt((pgd->entry[i] & + PGD_COARSE_ALIGN_MASK)); + /* Free pmd */ + free_pmd(pmd); + } + } + /* Free the pgd */ + free_pgd(pgd); + return PTR_ERR(-ENOMEM); +} + +extern pmd_table_t *pmd_array; + +/* + * Jumps from boot pmd/pgd page tables to tables allocated from the cache. + */ +pgd_table_t *realloc_page_tables(void) +{ + pgd_table_t *pgd_new = alloc_pgd(); + pgd_table_t *pgd_old = &init_pgd; + pmd_table_t *orig, *pmd; + + /* Copy whole pgd entries */ + memcpy(pgd_new, pgd_old, sizeof(pgd_table_t)); + + /* Allocate and copy all pmds */ + for (int i = 0; i < PGD_ENTRY_TOTAL; i++) { + /* Detect a pmd entry */ + if ((pgd_old->entry[i] & PGD_TYPE_MASK) == PGD_TYPE_COARSE) { + /* Allocate new pmd */ + if (!(pmd = alloc_pmd())) { + printk("FATAL: PMD allocation " + "failed during system initialization\n"); + BUG(); + } + + /* Find original pmd */ + orig = (pmd_table_t *) + phys_to_virt((pgd_old->entry[i] & + PGD_COARSE_ALIGN_MASK)); + + /* Copy original to new */ + memcpy(pmd, orig, sizeof(pmd_table_t)); + + /* Replace original pmd entry in pgd with new */ + pgd_new->entry[i] = (pgd_t)virt_to_phys(pmd); + pgd_new->entry[i] |= PGD_TYPE_COARSE; + } + } + + /* Switch the virtual memory system into new area */ + arm_clean_invalidate_cache(); + arm_drain_writebuffer(); + arm_invalidate_tlb(); + arm_set_ttb(virt_to_phys(pgd_new)); + arm_invalidate_tlb(); + + printk("%s: Initial page tables moved from 0x%x to 0x%x physical\n", + __KERNELNAME__, virt_to_phys(pgd_old), + virt_to_phys(pgd_new)); + + return pgd_new; +} + +/* + * Useful for upgrading to page-grained control over a section mapping: + * Remaps a section mapping in pages. It allocates a pmd, (at all times because + * there can't really be an already existing pmd for a section mapping) fills + * in the page information, and origaces the direct section physical translation + * with the address of the pmd. Flushes the caches/tlbs. + */ +void remap_as_pages(void *vstart, void *vend) +{ + unsigned long pstart = virt_to_phys(vstart); + unsigned long pend = virt_to_phys(vend); + unsigned long paddr = pstart; + pgd_t pgd_i = PGD_INDEX(vstart); + pmd_t pmd_i = PMD_INDEX(vstart); + pgd_table_t *pgd = &init_pgd; + pmd_table_t *pmd = alloc_boot_pmd(); + u32 pmd_phys = virt_to_phys(pmd); + int numpages = __pfn(pend - pstart); + + /* Fill in the pmd first */ + for (int n = 0; n < numpages; n++) { + pmd->entry[pmd_i + n] = paddr; + pmd->entry[pmd_i + n] |= PMD_TYPE_SMALL; /* Small page type */ + pmd->entry[pmd_i + n] |= space_flags_to_ptflags(MAP_SVC_DEFAULT_FLAGS); + paddr += PAGE_SIZE; + } + + /* Fill in the type to produce a complete pmd translator information */ + pmd_phys |= PGD_TYPE_COARSE; + + /* Make sure memory is coherent first. */ + arm_clean_invalidate_cache(); + arm_invalidate_tlb(); + + /* Replace the direct section physical address with pmd's address */ + pgd->entry[pgd_i] = (pgd_t)pmd_phys; + printk("%s: Kernel area 0x%lx - 0x%lx remapped as %d pages\n", __KERNELNAME__, + (unsigned long)vstart, (unsigned long)vend, numpages); +} + +void copy_pgds_by_vrange(pgd_table_t *to, pgd_table_t *from, + unsigned long start, unsigned long end) +{ + unsigned long start_i = PGD_INDEX(start); + unsigned long end_i = PGD_INDEX(end); + unsigned long irange = (end_i != 0) ? (end_i - start_i) + : (PGD_ENTRY_TOTAL - start_i); + + memcpy(&to->entry[start_i], &from->entry[start_i], + irange * sizeof(pgd_t)); +} + + +/* Scheduler uses this to switch context */ +void arch_hardware_flush(pgd_table_t *pgd) +{ + arm_clean_invalidate_cache(); + arm_invalidate_tlb(); + arm_set_ttb(virt_to_phys(pgd)); + arm_invalidate_tlb(); +} + diff --git a/src/arch/arm/v7/mmu_ops.S b/src/arch/arm/v7/mmu_ops.S new file mode 100644 index 0000000..eb6d9da --- /dev/null +++ b/src/arch/arm/v7/mmu_ops.S @@ -0,0 +1,155 @@ +/* + * low-level mmu operations + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include INC_ARCH(asm.h) + +#define C15_id c0 +#define C15_control c1 +#define C15_ttb c2 +#define C15_dom c3 +#define C15_fsr c5 +#define C15_far c6 +#define C15_tlb c8 + +#define C15_C0_M 0x0001 /* MMU */ +#define C15_C0_A 0x0002 /* Alignment */ +#define C15_C0_C 0x0004 /* (D) Cache */ +#define C15_C0_W 0x0008 /* Write buffer */ +#define C15_C0_B 0x0080 /* Endianness */ +#define C15_C0_S 0x0100 /* System */ +#define C15_C0_R 0x0200 /* ROM */ +#define C15_C0_Z 0x0800 /* Branch Prediction */ +#define C15_C0_I 0x1000 /* I cache */ +#define C15_C0_V 0x2000 /* High vectors */ + +/* FIXME: Make sure the ops that need r0 dont trash r0, or if they do, + * save it on stack before these operations. + */ + +/* + * In ARM terminology, flushing the cache means invalidating its contents. + * Cleaning the cache means, writing the contents of the cache back to + * main memory. In write-back caches the cache must be cleaned before + * flushing otherwise in-cache data is lost. + */ + +BEGIN_PROC(arm_set_ttb) + mcr p15, 0, r0, C15_ttb, c0, 0 + mov pc, lr +END_PROC(arm_set_ttb) + +BEGIN_PROC(arm_get_domain) + mrc p15, 0, r0, C15_dom, c0, 0 + mov pc, lr +END_PROC(arm_get_domain) + +BEGIN_PROC(arm_set_domain) + mcr p15, 0, r0, C15_dom, c0, 0 + mov pc, lr +END_PROC(arm_set_domain) + +BEGIN_PROC(arm_enable_mmu) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_M + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_mmu) + +BEGIN_PROC(arm_enable_icache) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_I + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_icache) + +BEGIN_PROC(arm_enable_dcache) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_C + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_dcache) + +BEGIN_PROC(arm_enable_wbuffer) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_W + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_wbuffer) + +BEGIN_PROC(arm_enable_high_vectors) + mrc p15, 0, r0, C15_control, c0, 0 + orr r0, r0, #C15_C0_V + mcr p15, 0, r0, C15_control, c0, 0 + mov pc, lr +END_PROC(arm_enable_high_vectors) + +BEGIN_PROC(arm_invalidate_cache) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c7 @ Flush I cache and D cache + mov pc, lr +END_PROC(arm_invalidate_cache) + +BEGIN_PROC(arm_invalidate_icache) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c5, 0 @ Flush I cache + mov pc, lr +END_PROC(arm_invalidate_icache) + +BEGIN_PROC(arm_invalidate_dcache) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c6, 0 @ Flush D cache + mov pc, lr +END_PROC(arm_invalidate_dcache) + +BEGIN_PROC(arm_clean_dcache) + mcr p15, 0 , pc, c7, c10, 3 @ Test/clean dcache line + bne arm_clean_dcache + mcr p15, 0, ip, c7, c10, 4 @ Drain WB + mov pc, lr +END_PROC(arm_clean_dcache) + +BEGIN_PROC(arm_clean_invalidate_dcache) +1: + mrc p15, 0, pc, c7, c14, 3 @ Test/clean/flush dcache line + @ COMMENT: Why use PC? + bne 1b + mcr p15, 0, ip, c7, c10, 4 @ Drain WB + mov pc, lr +END_PROC(arm_clean_invalidate_dcache) + +BEGIN_PROC(arm_clean_invalidate_cache) +1: + mrc p15, 0, r15, c7, c14, 3 @ Test/clean/flush dcache line + @ COMMENT: Why use PC? + bne 1b + mcr p15, 0, ip, c7, c5, 0 @ Flush icache + mcr p15, 0, ip, c7, c10, 4 @ Drain WB + mov pc, lr +END_PROC(arm_clean_invalidate_cache) + +BEGIN_PROC(arm_drain_writebuffer) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c7, c10, 4 + mov pc, lr +END_PROC(arm_drain_writebuffer) + +BEGIN_PROC(arm_invalidate_tlb) + mcr p15, 0, ip, c8, c7 + mov pc, lr +END_PROC(arm_invalidate_tlb) + +BEGIN_PROC(arm_invalidate_itlb) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c8, c5, 0 + mov pc, lr +END_PROC(arm_invalidate_itlb) + +BEGIN_PROC(arm_invalidate_dtlb) + mov r0, #0 @ FIX THIS + mcr p15, 0, r0, c8, c6, 0 + mov pc, lr +END_PROC(arm_invalidate_dtlb) + diff --git a/src/arch/arm/v7/mutex.S b/src/arch/arm/v7/mutex.S new file mode 100644 index 0000000..bc81708 --- /dev/null +++ b/src/arch/arm/v7/mutex.S @@ -0,0 +1,90 @@ +/* + * ARM v5 Binary semaphore (mutex) implementation. + * + * Copyright (C) 2007 Bahadir Balban + * + */ + +#include INC_ARCH(asm.h) + +/* Recap on swp: + * swp rx, ry, [rz] + * In one instruction: + * 1) Stores the value in ry into location pointed by rz. + * 2) Loads the value in the location of rz into rx. + * By doing so, in one instruction one can attempt to lock + * a word, and discover whether it was already locked. + */ + +#define MUTEX_UNLOCKED 0 +#define MUTEX_LOCKED 1 + +BEGIN_PROC(__spin_lock) + mov r1, #1 +__spin: + swp r2, r1, [r0] + cmp r2, #0 + bne __spin + mov pc, lr +END_PROC(__spin_lock) + +BEGIN_PROC(__spin_unlock) + mov r1, #0 + swp r2, r1, [r0] + cmp r2, #1 @ Debug check. +1: + bne 1b + mov pc, lr +END_PROC(__spin_unlock) + + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_lock) + mov r1, #1 + swp r2, r1, [r0] + cmp r2, #0 + movne r0, #0 + moveq r0, #1 + mov pc, lr +END_PROC(__mutex_lock) + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_unlock) + mov r1, #0 + swp r2, r1, [r0] + cmp r2, #1 +1: @ Debug check. + bne 1b + mov pc, lr +END_PROC(__mutex_unlock) + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_inc) + swp r2, r1, [r0] + mov r1, #1 + swp r2, r1, [r0] + cmp r2, #0 + movne r0, #0 + moveq r0, #1 + mov pc, lr +END_PROC(__mutex_inc) + +/* + * @r0: Address of mutex location. + */ +BEGIN_PROC(__mutex_dec) + mov r1, #0 + swp r2, r1, [r0] + cmp r2, #1 +1: @ Debug check. + bne 1b + mov pc, lr +END_PROC(__mutex_dec) + + diff --git a/src/drivers/irq/gic/gic.c b/src/drivers/irq/gic/gic.c new file mode 100644 index 0000000..2b8a310 --- /dev/null +++ b/src/drivers/irq/gic/gic.c @@ -0,0 +1,104 @@ +/* + * PL190 Vectored irq controller support. + * + * This is more pb926 specific as it also touches the SIC, a partial irq + * controller.Normally, irq controller must be independent and singular. Later + * other generic code should make thlongwork in cascaded setup. + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include + +/* FIXME: Fix the stupid uart driver and change to single definition of this! */ +#if defined(read) +#undef read +#endif +#if defined(write) +#undef write +#endif + +#define read(a) *((volatile unsigned int *)(a)) +#define write(v, a) (*((volatile unsigned int *)(a)) = v) +#define setbit(bitvect, a) write(read(a) | (bitvect), a) +#define clrbit(bitvect, a) write(read(a) & ~(bitvect), a) +#define devio(base, reg, bitvect, setclr) \ + ((setclr) ? setbit(bitvect, (base + reg)) \ + : clrbit(bitvect, (base + reg))) + +/* Returns the irq number on this chip converting the irq bitvector */ +int pl190_read_irq(void) +{ + /* This also correctly returns a negative value for a spurious irq. */ + return 31 - __clz(read(PL190_VIC_IRQSTATUS)); +} + +void pl190_mask_irq(int irq) +{ + /* Reading WO registers blows QEMU/PB926. + * setbit((1 << irq), PL190_VIC_INTENCLEAR); */ + write(1 << irq, PL190_VIC_INTENCLEAR); +} + +/* Ack is same as mask */ +void pl190_ack_irq(int irq) +{ + pl190_mask_irq(irq); +} + +void pl190_unmask_irq(int irq) +{ + setbit(1 << irq, PL190_VIC_INTENABLE); +} + +int pl190_sic_read_irq(void) +{ + return 32 - __clz(read(PL190_SIC_STATUS)); +} + +void pl190_sic_mask_irq(int irq) +{ + write(1 << irq, PL190_SIC_ENCLR); +} + +void pl190_sic_ack_irq(int irq) +{ + pl190_sic_mask_irq(irq); +} + +void pl190_sic_unmask_irq(int irq) +{ + setbit(1 << irq, PL190_SIC_ENSET); +} + +/* Initialises the primary and secondary interrupt controllers */ +void pl190_vic_init(void) +{ + /* Clear all interrupts */ + write(0, PL190_VIC_INTENABLE); + write(0xFFFFFFFF, PL190_VIC_INTENCLEAR); + + /* Set all irqs as normal IRQs (i.e. not FIQ) */ + write(0, PL190_VIC_INTSELECT); + /* TODO: Is there a SIC_IRQ_SELECT for irq/fiq ??? */ + + /* Disable user-mode access to VIC registers */ + write(1, PL190_VIC_PROTECTION); + + /* Clear software interrupts */ + write(0xFFFFFFFF, PL190_VIC_SOFTINTCLEAR); + + /* At this point, all interrupts are cleared and disabled. + * the controllers are ready to receive interrupts, if enabled. */ + return; +} + +void pl190_sic_init(void) +{ + write(0, PL190_SIC_ENABLE); + write(0xFFFFFFFF, PL190_SIC_ENCLR); + /* Disable SIC-to-PIC direct routing of individual irq lines on SIC */ + write(0xFFFFFFFF, PL190_SIC_PICENCLR); +} + diff --git a/src/platform/ab926/irq.c b/src/platform/ab926/irq.c new file mode 100644 index 0000000..7b63abf --- /dev/null +++ b/src/platform/ab926/irq.c @@ -0,0 +1,57 @@ +/* + * Support for generic irq handling using platform irq controller (PL190) + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_PLAT(irq.h) +#include INC_PLAT(platform.h) +#include INC_ARCH(exception.h) +#include +#include + +struct irq_chip irq_chip_array[IRQ_CHIPS_MAX] = { + [0] = { + .name = "Vectored irq controller", + .level = 0, + .cascade = IRQ_SIC, + .offset = 0, + .ops = { + .init = pl190_vic_init, + .read_irq = pl190_read_irq, + .ack_and_mask = pl190_mask_irq, + .unmask = pl190_unmask_irq, + }, + }, + [1] = { + .name = "Secondary irq controller", + .level = 1, + .cascade = IRQ_NIL, + .offset = SIRQ_CHIP_OFFSET, + .ops = { + .init = pl190_sic_init, + .read_irq = pl190_sic_read_irq, + .ack_and_mask = pl190_sic_mask_irq, + .unmask = pl190_sic_unmask_irq, + }, + }, +}; + +static int platform_timer_handler(void) +{ + sp804_irq_handler(); + return do_timer_irq(); +} + +/* Built-in irq handlers initialised at compile time. + * Else register with register_irq() */ +struct irq_desc irq_desc_array[IRQS_MAX] = { + [IRQ_TIMER01] = { + .name = "Timer01", + .chip = &irq_chip_array[0], + .handler = platform_timer_handler, + }, +}; + diff --git a/src/platform/ab926/platform.c b/src/platform/ab926/platform.c new file mode 100644 index 0000000..d59c955 --- /dev/null +++ b/src/platform/ab926/platform.c @@ -0,0 +1,62 @@ +/* + * PB926 platform-specific initialisation and setup + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include +#include +#include INC_ARCH(linker.h) +#include INC_PLAT(printascii.h) +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(mmu_ops.h) +#include INC_GLUE(memory.h) +#include INC_GLUE(memlayout.h) +#include INC_PLAT(offsets.h) +#include INC_PLAT(platform.h) +#include INC_PLAT(uart.h) +#include INC_PLAT(irq.h) +#include INC_ARCH(asm.h) + +void init_platform_console(void) +{ + add_boot_mapping(PB926_UART0_BASE, PL011_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + + /* + * Map same UART IO area to userspace so that primitive uart-based + * userspace printf can work. Note, this raw mapping is to be + * removed in the future, when file-based io is implemented. + */ + add_boot_mapping(PB926_UART0_BASE, USERSPACE_UART_BASE, PAGE_SIZE, + MAP_USR_IO_FLAGS); + + uart_init(); +} + +void init_platform_timer(void) +{ + add_boot_mapping(PB926_TIMER01_BASE, PLATFORM_TIMER_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SYSCTRL_BASE, PB926_SYSCTRL_VBASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + timer_init(); +} + +void init_platform_irq_controller() +{ + add_boot_mapping(PB926_VIC_BASE, PLATFORM_IRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SIC_BASE, PLATFORM_SIRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + irq_controllers_init(); +} + +void platform_init(void) +{ + init_platform_console(); + init_platform_timer(); + init_platform_irq_controller(); +} + diff --git a/src/platform/ab926/printascii.S b/src/platform/ab926/printascii.S new file mode 100644 index 0000000..e727537 --- /dev/null +++ b/src/platform/ab926/printascii.S @@ -0,0 +1,110 @@ +/* + * Basic UART printing. + */ +#include INC_ARCH(asm.h) +#include INC_GLUE(memlayout.h) + +#define UART_DATA_OFFSET 0x0 + + .macro uart_address rx + mrc p15, 0, \rx, c1, c0 + tst \rx, #1 @ MMU enabled? + moveq \rx, #0x10000000 + orreq \rx, \rx, #0x001F0000 + orreq \rx, \rx, #0x00001000 + /* FIXME: This offset is incorrect */ + movne \rx, #0xf9000000 @#IO_AREA0_VADDR + addne \rx, \rx, #PB926_UART0_VOFFSET @ UART0 page offset from + @ virtual io area base. + .endm + + .macro uart_send, ry, rx + strb \ry, [\rx, #UART_DATA_OFFSET] + .endm + + .macro uart_wait, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 5 + bne 501b + .endm + + .macro uart_busy, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 3 + bne 501b + .endm + + .text +/* + * Useful debugging routines + */ +BEGIN_PROC(printhex8) + mov r1, #8 + b printhex + +BEGIN_PROC(printhex4) + mov r1, #4 + b printhex + +BEGIN_PROC(printhex2) + mov r1, #2 +printhex: adr r2, hexbuf +@printhex: ldr r2, =hexbuf + add r3, r2, r1 + mov r1, #0 + strb r1, [r3] +1: and r1, r0, #15 + mov r0, r0, lsr #4 + cmp r1, #10 + addlt r1, r1, #'0' + addge r1, r1, #'a' - 10 + strb r1, [r3, #-1]! + teq r3, r2 + bne 1b + mov r0, r2 + b printascii + + .ltorg + + + .align + + @ vmem-linked image has strings in vmem addresses. This replaces + @ the reference with corresponding physical address. Note this + @ won't work if memory offsets aren't clear cut values for + @ orr'ing and bic'ing. rm = mmu bits rs = string address. + .macro get_straddr rs, rm + mrc p15, 0, \rm, c1, c0 @ Get MMU bits. + tst \rm, #1 @ MMU enabled? + @subeq \rs, \rs, #KERNEL_AREA_START + biceq \rs, \rs, #KERNEL_AREA_START @ Clear Virtual mem offset. + @orreq \rs, \rs, #PHYS_ADDR_BASE @ Add Phy mem offset. + .endm + +BEGIN_PROC(printascii) + get_straddr r0, r1 + uart_address r3 + b 2f +1: uart_wait r2, r3 + uart_send r1, r3 + uart_busy r2, r3 + teq r1, #'\n' + moveq r1, #'\r' + beq 1b +2: teq r0, #0 + ldrneb r1, [r0], #1 + teqne r1, #0 + bne 1b + mov pc, lr +END_PROC(printascii) + +BEGIN_PROC(printch) + uart_address r3 + mov r1, r0 + mov r0, #0 + b 1b + +hexbuf: .space 16 + diff --git a/src/platform/ab926/timer.c b/src/platform/ab926/timer.c new file mode 100644 index 0000000..fc290af --- /dev/null +++ b/src/platform/ab926/timer.c @@ -0,0 +1,28 @@ +/* + * Ties up platform timer with generic timer api + * + * Copyright (C) 2007 Bahadir Balban + * + */ +#include +#include +#include INC_PLAT(platform.h) +#include +#include + +void timer_init(void) +{ + /* Set timer 0 to 1MHz */ + sp810_set_timclk(0, 1); + + /* Initialise timer */ + sp804_init(); +} + +void timer_start(void) +{ + irq_enable(IRQ_TIMER01); + sp804_set_irq(0, 1); /* Enable timer0 irq */ + sp804_enable(0, 1); /* Enable timer0 */ +} + diff --git a/src/platform/ab926/uart.c b/src/platform/ab926/uart.c new file mode 100644 index 0000000..35d94f5 --- /dev/null +++ b/src/platform/ab926/uart.c @@ -0,0 +1,28 @@ +/* + * Ties up platform's uart driver functions with generic API + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include INC_PLAT(platform.h) + +#include + +extern struct pl011_uart uart; + +void uart_init() +{ + uart.base = PL011_BASE; + uart.ops.initialise(&uart); +} + +/* Generic uart function that lib/putchar.c expects to see implemented */ +void uart_putc(char c) +{ + int res; + /* Platform specific uart implementation */ + do { + res = uart.ops.tx_char(c); + } while (res < 0); +} + diff --git a/src/platform/eb/irq.c b/src/platform/eb/irq.c new file mode 100644 index 0000000..7b63abf --- /dev/null +++ b/src/platform/eb/irq.c @@ -0,0 +1,57 @@ +/* + * Support for generic irq handling using platform irq controller (PL190) + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_PLAT(irq.h) +#include INC_PLAT(platform.h) +#include INC_ARCH(exception.h) +#include +#include + +struct irq_chip irq_chip_array[IRQ_CHIPS_MAX] = { + [0] = { + .name = "Vectored irq controller", + .level = 0, + .cascade = IRQ_SIC, + .offset = 0, + .ops = { + .init = pl190_vic_init, + .read_irq = pl190_read_irq, + .ack_and_mask = pl190_mask_irq, + .unmask = pl190_unmask_irq, + }, + }, + [1] = { + .name = "Secondary irq controller", + .level = 1, + .cascade = IRQ_NIL, + .offset = SIRQ_CHIP_OFFSET, + .ops = { + .init = pl190_sic_init, + .read_irq = pl190_sic_read_irq, + .ack_and_mask = pl190_sic_mask_irq, + .unmask = pl190_sic_unmask_irq, + }, + }, +}; + +static int platform_timer_handler(void) +{ + sp804_irq_handler(); + return do_timer_irq(); +} + +/* Built-in irq handlers initialised at compile time. + * Else register with register_irq() */ +struct irq_desc irq_desc_array[IRQS_MAX] = { + [IRQ_TIMER01] = { + .name = "Timer01", + .chip = &irq_chip_array[0], + .handler = platform_timer_handler, + }, +}; + diff --git a/src/platform/eb/platform.c b/src/platform/eb/platform.c new file mode 100644 index 0000000..d59c955 --- /dev/null +++ b/src/platform/eb/platform.c @@ -0,0 +1,62 @@ +/* + * PB926 platform-specific initialisation and setup + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include +#include +#include INC_ARCH(linker.h) +#include INC_PLAT(printascii.h) +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(mmu_ops.h) +#include INC_GLUE(memory.h) +#include INC_GLUE(memlayout.h) +#include INC_PLAT(offsets.h) +#include INC_PLAT(platform.h) +#include INC_PLAT(uart.h) +#include INC_PLAT(irq.h) +#include INC_ARCH(asm.h) + +void init_platform_console(void) +{ + add_boot_mapping(PB926_UART0_BASE, PL011_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + + /* + * Map same UART IO area to userspace so that primitive uart-based + * userspace printf can work. Note, this raw mapping is to be + * removed in the future, when file-based io is implemented. + */ + add_boot_mapping(PB926_UART0_BASE, USERSPACE_UART_BASE, PAGE_SIZE, + MAP_USR_IO_FLAGS); + + uart_init(); +} + +void init_platform_timer(void) +{ + add_boot_mapping(PB926_TIMER01_BASE, PLATFORM_TIMER_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SYSCTRL_BASE, PB926_SYSCTRL_VBASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + timer_init(); +} + +void init_platform_irq_controller() +{ + add_boot_mapping(PB926_VIC_BASE, PLATFORM_IRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SIC_BASE, PLATFORM_SIRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + irq_controllers_init(); +} + +void platform_init(void) +{ + init_platform_console(); + init_platform_timer(); + init_platform_irq_controller(); +} + diff --git a/src/platform/eb/printascii.S b/src/platform/eb/printascii.S new file mode 100644 index 0000000..e727537 --- /dev/null +++ b/src/platform/eb/printascii.S @@ -0,0 +1,110 @@ +/* + * Basic UART printing. + */ +#include INC_ARCH(asm.h) +#include INC_GLUE(memlayout.h) + +#define UART_DATA_OFFSET 0x0 + + .macro uart_address rx + mrc p15, 0, \rx, c1, c0 + tst \rx, #1 @ MMU enabled? + moveq \rx, #0x10000000 + orreq \rx, \rx, #0x001F0000 + orreq \rx, \rx, #0x00001000 + /* FIXME: This offset is incorrect */ + movne \rx, #0xf9000000 @#IO_AREA0_VADDR + addne \rx, \rx, #PB926_UART0_VOFFSET @ UART0 page offset from + @ virtual io area base. + .endm + + .macro uart_send, ry, rx + strb \ry, [\rx, #UART_DATA_OFFSET] + .endm + + .macro uart_wait, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 5 + bne 501b + .endm + + .macro uart_busy, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 3 + bne 501b + .endm + + .text +/* + * Useful debugging routines + */ +BEGIN_PROC(printhex8) + mov r1, #8 + b printhex + +BEGIN_PROC(printhex4) + mov r1, #4 + b printhex + +BEGIN_PROC(printhex2) + mov r1, #2 +printhex: adr r2, hexbuf +@printhex: ldr r2, =hexbuf + add r3, r2, r1 + mov r1, #0 + strb r1, [r3] +1: and r1, r0, #15 + mov r0, r0, lsr #4 + cmp r1, #10 + addlt r1, r1, #'0' + addge r1, r1, #'a' - 10 + strb r1, [r3, #-1]! + teq r3, r2 + bne 1b + mov r0, r2 + b printascii + + .ltorg + + + .align + + @ vmem-linked image has strings in vmem addresses. This replaces + @ the reference with corresponding physical address. Note this + @ won't work if memory offsets aren't clear cut values for + @ orr'ing and bic'ing. rm = mmu bits rs = string address. + .macro get_straddr rs, rm + mrc p15, 0, \rm, c1, c0 @ Get MMU bits. + tst \rm, #1 @ MMU enabled? + @subeq \rs, \rs, #KERNEL_AREA_START + biceq \rs, \rs, #KERNEL_AREA_START @ Clear Virtual mem offset. + @orreq \rs, \rs, #PHYS_ADDR_BASE @ Add Phy mem offset. + .endm + +BEGIN_PROC(printascii) + get_straddr r0, r1 + uart_address r3 + b 2f +1: uart_wait r2, r3 + uart_send r1, r3 + uart_busy r2, r3 + teq r1, #'\n' + moveq r1, #'\r' + beq 1b +2: teq r0, #0 + ldrneb r1, [r0], #1 + teqne r1, #0 + bne 1b + mov pc, lr +END_PROC(printascii) + +BEGIN_PROC(printch) + uart_address r3 + mov r1, r0 + mov r0, #0 + b 1b + +hexbuf: .space 16 + diff --git a/src/platform/eb/timer.c b/src/platform/eb/timer.c new file mode 100644 index 0000000..fc290af --- /dev/null +++ b/src/platform/eb/timer.c @@ -0,0 +1,28 @@ +/* + * Ties up platform timer with generic timer api + * + * Copyright (C) 2007 Bahadir Balban + * + */ +#include +#include +#include INC_PLAT(platform.h) +#include +#include + +void timer_init(void) +{ + /* Set timer 0 to 1MHz */ + sp810_set_timclk(0, 1); + + /* Initialise timer */ + sp804_init(); +} + +void timer_start(void) +{ + irq_enable(IRQ_TIMER01); + sp804_set_irq(0, 1); /* Enable timer0 irq */ + sp804_enable(0, 1); /* Enable timer0 */ +} + diff --git a/src/platform/eb/uart.c b/src/platform/eb/uart.c new file mode 100644 index 0000000..35d94f5 --- /dev/null +++ b/src/platform/eb/uart.c @@ -0,0 +1,28 @@ +/* + * Ties up platform's uart driver functions with generic API + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include INC_PLAT(platform.h) + +#include + +extern struct pl011_uart uart; + +void uart_init() +{ + uart.base = PL011_BASE; + uart.ops.initialise(&uart); +} + +/* Generic uart function that lib/putchar.c expects to see implemented */ +void uart_putc(char c) +{ + int res; + /* Platform specific uart implementation */ + do { + res = uart.ops.tx_char(c); + } while (res < 0); +} + diff --git a/src/platform/pb11mpcore/irq.c b/src/platform/pb11mpcore/irq.c new file mode 100644 index 0000000..7b63abf --- /dev/null +++ b/src/platform/pb11mpcore/irq.c @@ -0,0 +1,57 @@ +/* + * Support for generic irq handling using platform irq controller (PL190) + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_PLAT(irq.h) +#include INC_PLAT(platform.h) +#include INC_ARCH(exception.h) +#include +#include + +struct irq_chip irq_chip_array[IRQ_CHIPS_MAX] = { + [0] = { + .name = "Vectored irq controller", + .level = 0, + .cascade = IRQ_SIC, + .offset = 0, + .ops = { + .init = pl190_vic_init, + .read_irq = pl190_read_irq, + .ack_and_mask = pl190_mask_irq, + .unmask = pl190_unmask_irq, + }, + }, + [1] = { + .name = "Secondary irq controller", + .level = 1, + .cascade = IRQ_NIL, + .offset = SIRQ_CHIP_OFFSET, + .ops = { + .init = pl190_sic_init, + .read_irq = pl190_sic_read_irq, + .ack_and_mask = pl190_sic_mask_irq, + .unmask = pl190_sic_unmask_irq, + }, + }, +}; + +static int platform_timer_handler(void) +{ + sp804_irq_handler(); + return do_timer_irq(); +} + +/* Built-in irq handlers initialised at compile time. + * Else register with register_irq() */ +struct irq_desc irq_desc_array[IRQS_MAX] = { + [IRQ_TIMER01] = { + .name = "Timer01", + .chip = &irq_chip_array[0], + .handler = platform_timer_handler, + }, +}; + diff --git a/src/platform/pb11mpcore/platform.c b/src/platform/pb11mpcore/platform.c new file mode 100644 index 0000000..d59c955 --- /dev/null +++ b/src/platform/pb11mpcore/platform.c @@ -0,0 +1,62 @@ +/* + * PB926 platform-specific initialisation and setup + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include +#include +#include INC_ARCH(linker.h) +#include INC_PLAT(printascii.h) +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(mmu_ops.h) +#include INC_GLUE(memory.h) +#include INC_GLUE(memlayout.h) +#include INC_PLAT(offsets.h) +#include INC_PLAT(platform.h) +#include INC_PLAT(uart.h) +#include INC_PLAT(irq.h) +#include INC_ARCH(asm.h) + +void init_platform_console(void) +{ + add_boot_mapping(PB926_UART0_BASE, PL011_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + + /* + * Map same UART IO area to userspace so that primitive uart-based + * userspace printf can work. Note, this raw mapping is to be + * removed in the future, when file-based io is implemented. + */ + add_boot_mapping(PB926_UART0_BASE, USERSPACE_UART_BASE, PAGE_SIZE, + MAP_USR_IO_FLAGS); + + uart_init(); +} + +void init_platform_timer(void) +{ + add_boot_mapping(PB926_TIMER01_BASE, PLATFORM_TIMER_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SYSCTRL_BASE, PB926_SYSCTRL_VBASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + timer_init(); +} + +void init_platform_irq_controller() +{ + add_boot_mapping(PB926_VIC_BASE, PLATFORM_IRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SIC_BASE, PLATFORM_SIRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + irq_controllers_init(); +} + +void platform_init(void) +{ + init_platform_console(); + init_platform_timer(); + init_platform_irq_controller(); +} + diff --git a/src/platform/pb11mpcore/printascii.S b/src/platform/pb11mpcore/printascii.S new file mode 100644 index 0000000..e727537 --- /dev/null +++ b/src/platform/pb11mpcore/printascii.S @@ -0,0 +1,110 @@ +/* + * Basic UART printing. + */ +#include INC_ARCH(asm.h) +#include INC_GLUE(memlayout.h) + +#define UART_DATA_OFFSET 0x0 + + .macro uart_address rx + mrc p15, 0, \rx, c1, c0 + tst \rx, #1 @ MMU enabled? + moveq \rx, #0x10000000 + orreq \rx, \rx, #0x001F0000 + orreq \rx, \rx, #0x00001000 + /* FIXME: This offset is incorrect */ + movne \rx, #0xf9000000 @#IO_AREA0_VADDR + addne \rx, \rx, #PB926_UART0_VOFFSET @ UART0 page offset from + @ virtual io area base. + .endm + + .macro uart_send, ry, rx + strb \ry, [\rx, #UART_DATA_OFFSET] + .endm + + .macro uart_wait, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 5 + bne 501b + .endm + + .macro uart_busy, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 3 + bne 501b + .endm + + .text +/* + * Useful debugging routines + */ +BEGIN_PROC(printhex8) + mov r1, #8 + b printhex + +BEGIN_PROC(printhex4) + mov r1, #4 + b printhex + +BEGIN_PROC(printhex2) + mov r1, #2 +printhex: adr r2, hexbuf +@printhex: ldr r2, =hexbuf + add r3, r2, r1 + mov r1, #0 + strb r1, [r3] +1: and r1, r0, #15 + mov r0, r0, lsr #4 + cmp r1, #10 + addlt r1, r1, #'0' + addge r1, r1, #'a' - 10 + strb r1, [r3, #-1]! + teq r3, r2 + bne 1b + mov r0, r2 + b printascii + + .ltorg + + + .align + + @ vmem-linked image has strings in vmem addresses. This replaces + @ the reference with corresponding physical address. Note this + @ won't work if memory offsets aren't clear cut values for + @ orr'ing and bic'ing. rm = mmu bits rs = string address. + .macro get_straddr rs, rm + mrc p15, 0, \rm, c1, c0 @ Get MMU bits. + tst \rm, #1 @ MMU enabled? + @subeq \rs, \rs, #KERNEL_AREA_START + biceq \rs, \rs, #KERNEL_AREA_START @ Clear Virtual mem offset. + @orreq \rs, \rs, #PHYS_ADDR_BASE @ Add Phy mem offset. + .endm + +BEGIN_PROC(printascii) + get_straddr r0, r1 + uart_address r3 + b 2f +1: uart_wait r2, r3 + uart_send r1, r3 + uart_busy r2, r3 + teq r1, #'\n' + moveq r1, #'\r' + beq 1b +2: teq r0, #0 + ldrneb r1, [r0], #1 + teqne r1, #0 + bne 1b + mov pc, lr +END_PROC(printascii) + +BEGIN_PROC(printch) + uart_address r3 + mov r1, r0 + mov r0, #0 + b 1b + +hexbuf: .space 16 + diff --git a/src/platform/pb11mpcore/timer.c b/src/platform/pb11mpcore/timer.c new file mode 100644 index 0000000..fc290af --- /dev/null +++ b/src/platform/pb11mpcore/timer.c @@ -0,0 +1,28 @@ +/* + * Ties up platform timer with generic timer api + * + * Copyright (C) 2007 Bahadir Balban + * + */ +#include +#include +#include INC_PLAT(platform.h) +#include +#include + +void timer_init(void) +{ + /* Set timer 0 to 1MHz */ + sp810_set_timclk(0, 1); + + /* Initialise timer */ + sp804_init(); +} + +void timer_start(void) +{ + irq_enable(IRQ_TIMER01); + sp804_set_irq(0, 1); /* Enable timer0 irq */ + sp804_enable(0, 1); /* Enable timer0 */ +} + diff --git a/src/platform/pb11mpcore/uart.c b/src/platform/pb11mpcore/uart.c new file mode 100644 index 0000000..35d94f5 --- /dev/null +++ b/src/platform/pb11mpcore/uart.c @@ -0,0 +1,28 @@ +/* + * Ties up platform's uart driver functions with generic API + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include INC_PLAT(platform.h) + +#include + +extern struct pl011_uart uart; + +void uart_init() +{ + uart.base = PL011_BASE; + uart.ops.initialise(&uart); +} + +/* Generic uart function that lib/putchar.c expects to see implemented */ +void uart_putc(char c) +{ + int res; + /* Platform specific uart implementation */ + do { + res = uart.ops.tx_char(c); + } while (res < 0); +} + diff --git a/src/platform/pba8/irq.c b/src/platform/pba8/irq.c new file mode 100644 index 0000000..7b63abf --- /dev/null +++ b/src/platform/pba8/irq.c @@ -0,0 +1,57 @@ +/* + * Support for generic irq handling using platform irq controller (PL190) + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_PLAT(irq.h) +#include INC_PLAT(platform.h) +#include INC_ARCH(exception.h) +#include +#include + +struct irq_chip irq_chip_array[IRQ_CHIPS_MAX] = { + [0] = { + .name = "Vectored irq controller", + .level = 0, + .cascade = IRQ_SIC, + .offset = 0, + .ops = { + .init = pl190_vic_init, + .read_irq = pl190_read_irq, + .ack_and_mask = pl190_mask_irq, + .unmask = pl190_unmask_irq, + }, + }, + [1] = { + .name = "Secondary irq controller", + .level = 1, + .cascade = IRQ_NIL, + .offset = SIRQ_CHIP_OFFSET, + .ops = { + .init = pl190_sic_init, + .read_irq = pl190_sic_read_irq, + .ack_and_mask = pl190_sic_mask_irq, + .unmask = pl190_sic_unmask_irq, + }, + }, +}; + +static int platform_timer_handler(void) +{ + sp804_irq_handler(); + return do_timer_irq(); +} + +/* Built-in irq handlers initialised at compile time. + * Else register with register_irq() */ +struct irq_desc irq_desc_array[IRQS_MAX] = { + [IRQ_TIMER01] = { + .name = "Timer01", + .chip = &irq_chip_array[0], + .handler = platform_timer_handler, + }, +}; + diff --git a/src/platform/pba8/platform.c b/src/platform/pba8/platform.c new file mode 100644 index 0000000..d59c955 --- /dev/null +++ b/src/platform/pba8/platform.c @@ -0,0 +1,62 @@ +/* + * PB926 platform-specific initialisation and setup + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include +#include +#include INC_ARCH(linker.h) +#include INC_PLAT(printascii.h) +#include INC_SUBARCH(mm.h) +#include INC_SUBARCH(mmu_ops.h) +#include INC_GLUE(memory.h) +#include INC_GLUE(memlayout.h) +#include INC_PLAT(offsets.h) +#include INC_PLAT(platform.h) +#include INC_PLAT(uart.h) +#include INC_PLAT(irq.h) +#include INC_ARCH(asm.h) + +void init_platform_console(void) +{ + add_boot_mapping(PB926_UART0_BASE, PL011_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + + /* + * Map same UART IO area to userspace so that primitive uart-based + * userspace printf can work. Note, this raw mapping is to be + * removed in the future, when file-based io is implemented. + */ + add_boot_mapping(PB926_UART0_BASE, USERSPACE_UART_BASE, PAGE_SIZE, + MAP_USR_IO_FLAGS); + + uart_init(); +} + +void init_platform_timer(void) +{ + add_boot_mapping(PB926_TIMER01_BASE, PLATFORM_TIMER_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SYSCTRL_BASE, PB926_SYSCTRL_VBASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + timer_init(); +} + +void init_platform_irq_controller() +{ + add_boot_mapping(PB926_VIC_BASE, PLATFORM_IRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + add_boot_mapping(PB926_SIC_BASE, PLATFORM_SIRQCTRL_BASE, PAGE_SIZE, + MAP_IO_DEFAULT_FLAGS); + irq_controllers_init(); +} + +void platform_init(void) +{ + init_platform_console(); + init_platform_timer(); + init_platform_irq_controller(); +} + diff --git a/src/platform/pba8/printascii.S b/src/platform/pba8/printascii.S new file mode 100644 index 0000000..e727537 --- /dev/null +++ b/src/platform/pba8/printascii.S @@ -0,0 +1,110 @@ +/* + * Basic UART printing. + */ +#include INC_ARCH(asm.h) +#include INC_GLUE(memlayout.h) + +#define UART_DATA_OFFSET 0x0 + + .macro uart_address rx + mrc p15, 0, \rx, c1, c0 + tst \rx, #1 @ MMU enabled? + moveq \rx, #0x10000000 + orreq \rx, \rx, #0x001F0000 + orreq \rx, \rx, #0x00001000 + /* FIXME: This offset is incorrect */ + movne \rx, #0xf9000000 @#IO_AREA0_VADDR + addne \rx, \rx, #PB926_UART0_VOFFSET @ UART0 page offset from + @ virtual io area base. + .endm + + .macro uart_send, ry, rx + strb \ry, [\rx, #UART_DATA_OFFSET] + .endm + + .macro uart_wait, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 5 + bne 501b + .endm + + .macro uart_busy, ry, rx +501: + ldr \ry, [\rx, #0x18] + tst \ry, #1 << 3 + bne 501b + .endm + + .text +/* + * Useful debugging routines + */ +BEGIN_PROC(printhex8) + mov r1, #8 + b printhex + +BEGIN_PROC(printhex4) + mov r1, #4 + b printhex + +BEGIN_PROC(printhex2) + mov r1, #2 +printhex: adr r2, hexbuf +@printhex: ldr r2, =hexbuf + add r3, r2, r1 + mov r1, #0 + strb r1, [r3] +1: and r1, r0, #15 + mov r0, r0, lsr #4 + cmp r1, #10 + addlt r1, r1, #'0' + addge r1, r1, #'a' - 10 + strb r1, [r3, #-1]! + teq r3, r2 + bne 1b + mov r0, r2 + b printascii + + .ltorg + + + .align + + @ vmem-linked image has strings in vmem addresses. This replaces + @ the reference with corresponding physical address. Note this + @ won't work if memory offsets aren't clear cut values for + @ orr'ing and bic'ing. rm = mmu bits rs = string address. + .macro get_straddr rs, rm + mrc p15, 0, \rm, c1, c0 @ Get MMU bits. + tst \rm, #1 @ MMU enabled? + @subeq \rs, \rs, #KERNEL_AREA_START + biceq \rs, \rs, #KERNEL_AREA_START @ Clear Virtual mem offset. + @orreq \rs, \rs, #PHYS_ADDR_BASE @ Add Phy mem offset. + .endm + +BEGIN_PROC(printascii) + get_straddr r0, r1 + uart_address r3 + b 2f +1: uart_wait r2, r3 + uart_send r1, r3 + uart_busy r2, r3 + teq r1, #'\n' + moveq r1, #'\r' + beq 1b +2: teq r0, #0 + ldrneb r1, [r0], #1 + teqne r1, #0 + bne 1b + mov pc, lr +END_PROC(printascii) + +BEGIN_PROC(printch) + uart_address r3 + mov r1, r0 + mov r0, #0 + b 1b + +hexbuf: .space 16 + diff --git a/src/platform/pba8/timer.c b/src/platform/pba8/timer.c new file mode 100644 index 0000000..fc290af --- /dev/null +++ b/src/platform/pba8/timer.c @@ -0,0 +1,28 @@ +/* + * Ties up platform timer with generic timer api + * + * Copyright (C) 2007 Bahadir Balban + * + */ +#include +#include +#include INC_PLAT(platform.h) +#include +#include + +void timer_init(void) +{ + /* Set timer 0 to 1MHz */ + sp810_set_timclk(0, 1); + + /* Initialise timer */ + sp804_init(); +} + +void timer_start(void) +{ + irq_enable(IRQ_TIMER01); + sp804_set_irq(0, 1); /* Enable timer0 irq */ + sp804_enable(0, 1); /* Enable timer0 */ +} + diff --git a/src/platform/pba8/uart.c b/src/platform/pba8/uart.c new file mode 100644 index 0000000..35d94f5 --- /dev/null +++ b/src/platform/pba8/uart.c @@ -0,0 +1,28 @@ +/* + * Ties up platform's uart driver functions with generic API + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include INC_PLAT(platform.h) + +#include + +extern struct pl011_uart uart; + +void uart_init() +{ + uart.base = PL011_BASE; + uart.ops.initialise(&uart); +} + +/* Generic uart function that lib/putchar.c expects to see implemented */ +void uart_putc(char c) +{ + int res; + /* Platform specific uart implementation */ + do { + res = uart.ops.tx_char(c); + } while (res < 0); +} + From 07a5b0a904de07b2a3c15f6cfb0038b9ceafa883 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sun, 30 Aug 2009 13:26:09 +0300 Subject: [PATCH 9/9] CML change to rule out 1136 on mpcore platform --- configs/arm.cml | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/arm.cml b/configs/arm.cml index 7d2ce4d..bbbe126 100644 --- a/configs/arm.cml +++ b/configs/arm.cml @@ -116,6 +116,7 @@ unless ARM_SUBARCH_V7 suppress ARM_CPU_CORTEXA8 unless ARM_SUBARCH_V5 suppress ARM_PLATFORM_PB926 unless ARCH_ARM suppress arm_menu unless ARM_PLATFORM_PB926 or ARM_PLATFORM_AB926 suppress DRIVER_IRQ_PL190 +unless ARM_PLATFORM_EB suppress ARM_CPU_ARM1136 unless ARM_PLATFORM_EB or ARM_PLATFORM_PBA8 or ARM_PLATFORM_PBMPCORE suppress DRIVER_IRQ_GIC default DRIVER_UART_PL011 from y default DRIVER_TIMER_SP804 from y