mirror of
https://github.com/drasko/codezero.git
synced 2026-04-18 01:39:05 +02:00
Merge branch 'containers' into containersBuildDevel
This commit is contained in:
@@ -5,89 +5,124 @@ start main_menu
|
|||||||
#############
|
#############
|
||||||
symbols
|
symbols
|
||||||
|
|
||||||
DUMMY 'DUMMY'
|
|
||||||
ARCH_ARM 'ARM'
|
ARCH_ARM 'ARM'
|
||||||
ARCH_TEST 'TEST'
|
|
||||||
|
|
||||||
arm_cpu_type 'ARM Processor Type'
|
arm_cpu_type 'ARM Processor Type'
|
||||||
ARM_CPU_ARM920T 'ARM920T Not supported yet'
|
ARM_CPU_ARM1136 'ARM1136 - To be added'
|
||||||
ARM_CPU_ARM925 'ARM925 Not supported yet'
|
ARM_CPU_ARM11MPCORE 'ARM11 MPCore - To be added'
|
||||||
ARM_CPU_ARM926 'ARM926EJ-S'
|
ARM_CPU_ARM926 'ARM926EJ-S'
|
||||||
|
ARM_CPU_CORTEXA8 'ARM Cortex-A8 - Not supported'
|
||||||
|
|
||||||
arm_subarch_type 'ARM Architecture Family'
|
arm_subarch_type 'ARM Architecture Family'
|
||||||
ARM_SUBARCH_V5 'ARM V5 Architecture'
|
ARM_SUBARCH_V5 'ARM v5 Architecture'
|
||||||
ARM_SUBARCH_V6 'ARM V6 Architecture, Unsupported yet'
|
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_type 'ARM Platform Type'
|
||||||
ARM_PLATFORM_EB 'Realview EB Platform, Unsupported yet'
|
ARM_PLATFORM_EB 'Realview EB Platform, Unsupported yet'
|
||||||
ARM_PLATFORM_AB926 'Versatile AB926 Platform, Unsupported yet'
|
ARM_PLATFORM_AB926 'Versatile AB926 Platform, Unsupported yet'
|
||||||
ARM_PLATFORM_PB926 'Versatile PB926 Platform'
|
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_UART_PL011 'ARM UART Primecell driver PL011'
|
||||||
DRIVER_TIMER_SP804 'ARM Dual Timer Primecell driver SP804'
|
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'
|
main_menu 'Codezero Microkernel Configurator'
|
||||||
arm_menu 'ARM Architecture Configuration'
|
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'
|
drivers_menu 'Platform Drivers'
|
||||||
arch_type 'Main architecture'
|
arch_type 'Main architecture'
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# CHOICES #
|
# CHOICES #
|
||||||
#############
|
#############
|
||||||
choices arch_type
|
choices arch_type
|
||||||
ARCH_TEST
|
|
||||||
ARCH_ARM
|
ARCH_ARM
|
||||||
default ARCH_ARM
|
default ARCH_ARM
|
||||||
|
|
||||||
choices arm_subarch_type
|
choices arm_subarch_type
|
||||||
ARM_SUBARCH_V5
|
ARM_SUBARCH_V5
|
||||||
ARM_SUBARCH_V6
|
ARM_SUBARCH_V6
|
||||||
|
ARM_SUBARCH_V7
|
||||||
default ARM_SUBARCH_V5
|
default ARM_SUBARCH_V5
|
||||||
|
|
||||||
choices arm_cpu_type
|
choices arm_cpu_type
|
||||||
ARM_CPU_ARM920T
|
|
||||||
ARM_CPU_ARM926
|
ARM_CPU_ARM926
|
||||||
ARM_CPU_ARM925
|
ARM_CPU_ARM1136
|
||||||
|
ARM_CPU_ARM11MPCORE
|
||||||
|
ARM_CPU_CORTEXA8
|
||||||
default ARM_CPU_ARM926
|
default ARM_CPU_ARM926
|
||||||
|
|
||||||
choices arm_platform_type
|
choices arm_platform_type
|
||||||
ARM_PLATFORM_EB
|
ARM_PLATFORM_EB
|
||||||
ARM_PLATFORM_AB926
|
ARM_PLATFORM_AB926
|
||||||
ARM_PLATFORM_PB926
|
ARM_PLATFORM_PB926
|
||||||
|
ARM_PLATFORM_PBMPCORE
|
||||||
|
ARM_PLATFORM_PBA8
|
||||||
default ARM_PLATFORM_PB926
|
default ARM_PLATFORM_PB926
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# MENUS #
|
# MENUS #
|
||||||
#############
|
#############
|
||||||
|
|
||||||
|
menu arm_cpu_menu
|
||||||
|
arm_cpu_type
|
||||||
|
|
||||||
|
menu arm_platform_menu
|
||||||
|
arm_platform_type
|
||||||
|
|
||||||
menu drivers_menu
|
menu drivers_menu
|
||||||
DRIVER_UART_PL011
|
DRIVER_UART_PL011
|
||||||
DRIVER_TIMER_SP804
|
DRIVER_TIMER_SP804
|
||||||
DRIVER_IRQ_PL190
|
DRIVER_IRQ_PL190
|
||||||
|
DRIVER_IRQ_GIC
|
||||||
|
|
||||||
menu arm_menu
|
menu arm_menu
|
||||||
arm_cpu_type
|
|
||||||
arm_subarch_type
|
arm_subarch_type
|
||||||
arm_platform_type
|
arm_cpu_menu
|
||||||
|
arm_platform_menu
|
||||||
drivers_menu
|
drivers_menu
|
||||||
|
|
||||||
menu main_menu
|
menu main_menu
|
||||||
arch_type
|
arch_type
|
||||||
arm_menu
|
arm_menu
|
||||||
DUMMY
|
|
||||||
#############
|
#############
|
||||||
# RULES #
|
# 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
|
# NOTE: Unlike menus, choices dont take { sym } model of visibility
|
||||||
# dependencies. Instead, a choice symbol is declared in a menu, and
|
# dependencies. Instead, a choice symbol is declared in a menu, and
|
||||||
# suppress statement is used to make sym visible, instead of a
|
# 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 ARCH_ARM suppress arm_menu
|
||||||
unless ARM_PLATFORM_PB926 suppress DRIVER_UART_PL011
|
unless ARM_PLATFORM_PB926 or ARM_PLATFORM_AB926 suppress DRIVER_IRQ_PL190
|
||||||
unless ARM_PLATFORM_PB926 suppress DRIVER_TIMER_SP804
|
unless ARM_PLATFORM_EB suppress ARM_CPU_ARM1136
|
||||||
unless ARM_PLATFORM_PB926 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_UART_PL011 from y
|
||||||
default DRIVER_TIMER_SP804 from y
|
default DRIVER_TIMER_SP804 from y
|
||||||
default DRIVER_IRQ_PL190 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.
|
# USELESS!! This doesnt force it to define invisible symbols as says in the manual.
|
||||||
#when ARCH_TEST save SUBARCH_TEST PLATFORM_TEST
|
#when ARCH_TEST save SUBARCH_TEST PLATFORM_TEST
|
||||||
#derive SUBARCH_TEST from ARCH_TEST
|
#derive SUBARCH_TEST from ARCH_TEST
|
||||||
|
|||||||
@@ -3,12 +3,6 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
#ifndef size_t
|
|
||||||
#define size_t int
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *kmalloc(size_t size);
|
void *kmalloc(size_t size);
|
||||||
void kfree(void *blk);
|
void kfree(void *blk);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <l4/lib/list.h>
|
#include <l4/lib/list.h>
|
||||||
#include <memfs/memfs.h>
|
#include <memfs/memfs.h>
|
||||||
#include <l4/macros.h>
|
#include <l4/macros.h>
|
||||||
#include <printf.h>
|
#include <stdio.h>
|
||||||
#include <task.h>
|
#include <task.h>
|
||||||
#include <path.h>
|
#include <path.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +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.
|
||||||
|
*/
|
||||||
|
|
||||||
.section .text.head
|
#ifdef __thumb__
|
||||||
.global _start;
|
#define bl blx
|
||||||
.type _start,function;
|
#endif
|
||||||
.align;
|
|
||||||
|
|
||||||
|
.section .text.head
|
||||||
|
.code 32
|
||||||
|
.global _start;
|
||||||
|
.align;
|
||||||
_start:
|
_start:
|
||||||
ldr sp, =__stack
|
ldr sp, =__stack
|
||||||
|
bl platform_init
|
||||||
bl __container_init
|
bl __container_init
|
||||||
1:
|
1:
|
||||||
b 1b
|
b 1b
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <l4/lib/list.h>
|
#include <l4/lib/list.h>
|
||||||
#include <l4/macros.h>
|
#include <l4/macros.h>
|
||||||
#include INC_GLUE(memory.h)
|
#include INC_GLUE(memory.h)
|
||||||
#include <printf.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This reads contents of a file in pages, calling the fs-specific file read function to read-in
|
* This reads contents of a file in pages, calling the fs-specific file read function to read-in
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <lib/bit.h>
|
#include <lib/bit.h>
|
||||||
#include <l4/macros.h>
|
#include <l4/macros.h>
|
||||||
#include <l4/config.h>
|
#include <l4/config.h>
|
||||||
#include <printf.h>
|
#include <stdio.h>
|
||||||
#include INC_GLUE(memory.h)
|
#include INC_GLUE(memory.h)
|
||||||
|
|
||||||
/* Emulation of ARM's CLZ (count leading zeroes) instruction */
|
/* Emulation of ARM's CLZ (count leading zeroes) instruction */
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <lib/malloc.h> // --> This is a local library that statically allocates its heap.
|
#include <lib/malloc.h> // --> This is a local library that statically allocates its heap.
|
||||||
#include <l4/macros.h>
|
#include <l4/macros.h>
|
||||||
#include INC_GLUE(memory.h)
|
#include INC_GLUE(memory.h)
|
||||||
#include <printf.h>
|
#include <stdio.h>
|
||||||
#include <l4/api/errno.h>
|
#include <l4/api/errno.h>
|
||||||
|
|
||||||
struct id_pool *id_pool_new_init(int totalbits)
|
struct id_pool *id_pool_new_init(int totalbits)
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ Messages that indicate a software error will contain three asterisks (***).
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#include <string.h> /* memcpy(), memset() */
|
#include <string.h> /* memcpy(), memset() */
|
||||||
#include <stdio.h> /* printf() */
|
#include <stdio.h> /* printf() */
|
||||||
#include <printf.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#define _32BIT 1
|
#define _32BIT 1
|
||||||
|
|
||||||
/* use small (32K) heap for 16-bit compilers,
|
/* use small (32K) heap for 16-bit compilers,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <l4/types.h>
|
#include <l4/types.h>
|
||||||
#include INC_GLUE(memory.h)
|
#include INC_GLUE(memory.h)
|
||||||
#include <lib/vaddr.h>
|
#include <lib/vaddr.h>
|
||||||
#include <printf.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end)
|
void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,14 +19,27 @@
|
|||||||
|
|
||||||
Import('environment')
|
Import('environment')
|
||||||
|
|
||||||
|
variant = "userspace"
|
||||||
e = environment.Clone()
|
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]'))
|
objects = e.StaticObject(source)
|
||||||
Depends(objects, e['configFiles'])
|
Depends (objects, e['configFiles'])
|
||||||
library = e.StaticLibrary('c', objects)
|
library = e.StaticLibrary('c-' + variant, objects)
|
||||||
Depends(library, e['configFiles'])
|
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')
|
||||||
|
|||||||
97
containers/posix/libc/crt/sys-baremetal/arch-arm/crt0.S
Normal file
97
containers/posix/libc/crt/sys-baremetal/arch-arm/crt0.S
Normal file
@@ -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:
|
||||||
@@ -1 +0,0 @@
|
|||||||
arch-arm
|
|
||||||
@@ -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__ */
|
|
||||||
87
containers/posix/libc/include/arch/arm/arch/inttypes.h
Normal file
87
containers/posix/libc/include/arch/arm/arch/inttypes.h
Normal file
@@ -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
|
||||||
408
containers/posix/libc/include/arch/arm/arch/pl011_uart.h
Normal file
408
containers/posix/libc/include/arch/arm/arch/pl011_uart.h
Normal file
@@ -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__ */
|
||||||
|
|
||||||
83
containers/posix/libc/include/arch/arm/arch/setjmp.h
Normal file
83
containers/posix/libc/include/arch/arm/arch/setjmp.h
Normal file
@@ -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];
|
||||||
102
containers/posix/libc/include/assert.h
Normal file
102
containers/posix/libc/include/assert.h
Normal file
@@ -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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* <assert.h> 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);
|
||||||
|
|
||||||
212
containers/posix/libc/include/complex.h
Normal file
212
containers/posix/libc/include/complex.h
Normal file
@@ -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);
|
||||||
204
containers/posix/libc/include/ctype.h
Normal file
204
containers/posix/libc/include/ctype.h
Normal file
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
110
containers/posix/libc/include/errno.h
Normal file
110
containers/posix/libc/include/errno.h
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* 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_
|
||||||
|
|
||||||
|
#ifndef EDOM
|
||||||
|
#define EDOM 1
|
||||||
|
#endif
|
||||||
|
#ifndef EILSEQ
|
||||||
|
#define EILSEQ 2
|
||||||
|
#endif
|
||||||
|
#ifndef ERANGE
|
||||||
|
#define ERANGE 3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#include <l4/thread.h>
|
||||||
|
|
||||||
|
#ifndef THREAD_SAFE
|
||||||
|
extern int errno;
|
||||||
|
#else
|
||||||
|
#define errno (*((int *)__L4_TCR_ThreadLocalStorage()))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _ERRNO_H_ */
|
||||||
|
|
||||||
202
containers/posix/libc/include/inttypes.h
Normal file
202
containers/posix/libc/include/inttypes.h
Normal file
@@ -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 <stdint.h>
|
||||||
|
|
||||||
|
#include <arch/inttypes.h>
|
||||||
|
|
||||||
|
/* 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
|
||||||
101
containers/posix/libc/include/iso646.h
Normal file
101
containers/posix/libc/include/iso646.h
Normal file
@@ -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_ */
|
||||||
116
containers/posix/libc/include/limits.h
Normal file
116
containers/posix/libc/include/limits.h
Normal file
@@ -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_ */
|
||||||
117
containers/posix/libc/include/locale.h
Normal file
117
containers/posix/libc/include/locale.h
Normal file
@@ -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 <stddef.h>
|
||||||
|
|
||||||
|
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);
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
#ifndef __PRINTF_H__
|
|
||||||
#define __PRINTF_H__
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
int printf(char *format, ...) __attribute__((format (printf, 1, 2)));
|
|
||||||
|
|
||||||
#endif /* __PRINTF_H__ */
|
|
||||||
90
containers/posix/libc/include/setjmp.h
Normal file
90
containers/posix/libc/include/setjmp.h
Normal file
@@ -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 <arch/setjmp.h>
|
||||||
|
|
||||||
|
int setjmp(jmp_buf);
|
||||||
|
void longjmp(jmp_buf, int);
|
||||||
|
|
||||||
|
#endif /* _SETJMP_H_ */
|
||||||
96
containers/posix/libc/include/stdarg.h
Normal file
96
containers/posix/libc/include/stdarg.h
Normal file
@@ -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_ */
|
||||||
119
containers/posix/libc/include/stddef.h
Normal file
119
containers/posix/libc/include/stddef.h
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL ((void *)0)
|
||||||
|
#endif
|
||||||
|
#define offsetof(type, member) ((size_t) &((type *)0)->member)
|
||||||
|
|
||||||
|
#endif /* _STDDEF_H_ */
|
||||||
@@ -136,9 +136,15 @@ typedef long fpos_t; /* same */
|
|||||||
#define FILENAME_MAX 37
|
#define FILENAME_MAX 37
|
||||||
#define L_tmpnam 37
|
#define L_tmpnam 37
|
||||||
|
|
||||||
//#define SEEK_CUR 0
|
#ifndef SEEK_CUR
|
||||||
//#define SEEK_END 1
|
#define SEEK_CUR 0
|
||||||
//#define SEEK_SET 2
|
#endif
|
||||||
|
#ifndef SEEK_END
|
||||||
|
#define SEEK_END 1
|
||||||
|
#endif
|
||||||
|
#ifndef SEEK_SET
|
||||||
|
#define SEEK_SET 2
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TMP_MAX 37
|
#define TMP_MAX 37
|
||||||
|
|
||||||
@@ -161,7 +167,7 @@ int setvbuf(FILE *, char *, int, size_t);
|
|||||||
/* 7.19.6 Format i/o functions */
|
/* 7.19.6 Format i/o functions */
|
||||||
int fprintf(FILE *, const char *, ...);
|
int fprintf(FILE *, const char *, ...);
|
||||||
int fscanf(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 scanf(const char *, ...);
|
||||||
int snprintf(char *, size_t , const char *, ...);
|
int snprintf(char *, size_t , const char *, ...);
|
||||||
int sprintf(char *, const char *, ...);
|
int sprintf(char *, const char *, ...);
|
||||||
@@ -177,7 +183,7 @@ int vsscanf(const char *s, const char *format, va_list arg);
|
|||||||
/* 7.19.7 Character i/o functions */
|
/* 7.19.7 Character i/o functions */
|
||||||
int fgetc(FILE *);
|
int fgetc(FILE *);
|
||||||
char *fgets(char *, int, FILE *);
|
char *fgets(char *, int, FILE *);
|
||||||
//int fputc(int, FILE *);
|
int fputc(int, FILE *);
|
||||||
int fputs(const char *, FILE *);
|
int fputs(const char *, FILE *);
|
||||||
|
|
||||||
/* getc is specified to be the same as fgetc, so it makes
|
/* getc is specified to be the same as fgetc, so it makes
|
||||||
@@ -189,7 +195,7 @@ char *gets(char *);
|
|||||||
|
|
||||||
/* putc is specified to be the same as fputc, so it makes
|
/* putc is specified to be the same as fputc, so it makes
|
||||||
the most sense to implement as a macro here */
|
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 putchar(int);
|
||||||
int puts(const char *);
|
int puts(const char *);
|
||||||
|
|||||||
210
containers/posix/libc/include/stdlib.h
Normal file
210
containers/posix/libc/include/stdlib.h
Normal file
@@ -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 <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* 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_ */
|
||||||
@@ -1,11 +1,122 @@
|
|||||||
#ifndef __LIB_STRING_H__
|
/*
|
||||||
#define __LIB_STRING_H__
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
int strlen(const char *s);
|
#ifndef _STRING_H_
|
||||||
char *strcpy(char *to, const char *from);
|
#define _STRING_H_
|
||||||
char *strncpy(char *dest, const char *src, int count);
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* 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 strcmp(const char *s1, const char *s2);
|
||||||
void *memset(void *p, int c, int size);
|
int strcoll(const char *s1, const char *s2);
|
||||||
void *memcpy(void *d, void *s, int size);
|
int strncmp(const char *s1, const char *s2, size_t n);
|
||||||
|
size_t strxfrm(char *s1, const char *s2, size_t n);
|
||||||
|
|
||||||
#endif /* __LIB_STRING_H__ */
|
/* 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_ */
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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__ */
|
||||||
|
|
||||||
@@ -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];
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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__ */
|
||||||
|
|
||||||
@@ -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];
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -105,7 +105,7 @@ struct pl011_uart_ops {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct pl011_uart {
|
struct pl011_uart {
|
||||||
unsigned int base;
|
const unsigned int base;
|
||||||
struct pl011_uart_ops ops;
|
struct pl011_uart_ops ops;
|
||||||
unsigned int frame_errors;
|
unsigned int frame_errors;
|
||||||
unsigned int parity_errors;
|
unsigned int parity_errors;
|
||||||
@@ -281,10 +281,10 @@ static inline void pl011_set_word_width(int size)
|
|||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
if(size < 5 || size > 8) /* Default is 8 */
|
if(size < 5 || size > 8) /* Default is 8 */
|
||||||
size = 8;
|
size = 8;
|
||||||
|
|
||||||
/* Clear size field */
|
/* Clear size field */
|
||||||
read(val, PL011_UARTLCR_H);
|
read(val, PL011_UARTLCR_H);
|
||||||
val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT);
|
val &= ~(0x3 << PL011_WORD_WIDTH_SHIFT);
|
||||||
@@ -299,11 +299,11 @@ static inline void pl011_set_word_width(int size)
|
|||||||
read(val, PL011_UARTLCR_H);
|
read(val, PL011_UARTLCR_H);
|
||||||
val |= (size - 5) << PL011_WORD_WIDTH_SHIFT;
|
val |= (size - 5) << PL011_WORD_WIDTH_SHIFT;
|
||||||
write(val, PL011_UARTLCR_H);
|
write(val, PL011_UARTLCR_H);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defines at which level of fifo fullness an irq will be generated.
|
* Defines at which level of fifo fullness an irq will be generated.
|
||||||
* @xfer: tx fifo = 0, rx fifo = 1
|
* @xfer: tx fifo = 0, rx fifo = 1
|
||||||
* @level: Generate irq if:
|
* @level: Generate irq if:
|
||||||
@@ -320,8 +320,8 @@ static inline void pl011_set_irq_fifolevel(unsigned int xfer, unsigned int level
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if(level > 4) /* Invalid level */
|
if(level > 4) /* Invalid level */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
write(level << (xfer * 3), PL011_UARTIFLS);
|
write(level << (xfer * 3), PL011_UARTIFLS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ static inline unsigned int pl011_read_irqstat(void)
|
|||||||
{
|
{
|
||||||
unsigned int irqstatus;
|
unsigned int irqstatus;
|
||||||
read(irqstatus, PL011_UARTMIS);
|
read(irqstatus, PL011_UARTMIS);
|
||||||
return irqstatus;
|
return irqstatus;
|
||||||
}
|
}
|
||||||
/* Clears the given asserted irqs */
|
/* Clears the given asserted irqs */
|
||||||
static inline void pl011_irq_clear(unsigned int flags)
|
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)
|
#define PL011_RXDMAEN (1 << 0)
|
||||||
|
|
||||||
/* Enables dma transfers for uart. The dma controller
|
/* 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()
|
static inline void pl011_tx_dma_enable()
|
||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
read(val, PL011_UARTDMACR);
|
read(val, PL011_UARTDMACR);
|
||||||
val |= PL011_TXDMAEN;
|
val |= PL011_TXDMAEN;
|
||||||
write(val, PL011_UARTDMACR);
|
write(val, PL011_UARTDMACR);
|
||||||
@@ -374,7 +374,7 @@ static inline void pl011_tx_dma_disable()
|
|||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
read(val, PL011_UARTDMACR);
|
read(val, PL011_UARTDMACR);
|
||||||
val &= ~PL011_TXDMAEN;
|
val &= ~PL011_TXDMAEN;
|
||||||
write(val, PL011_UARTDMACR);
|
write(val, PL011_UARTDMACR);
|
||||||
@@ -385,7 +385,7 @@ static inline void pl011_rx_dma_enable()
|
|||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
read(val, PL011_UARTDMACR);
|
read(val, PL011_UARTDMACR);
|
||||||
val |= PL011_RXDMAEN;
|
val |= PL011_RXDMAEN;
|
||||||
write(val, PL011_UARTDMACR);
|
write(val, PL011_UARTDMACR);
|
||||||
@@ -396,12 +396,13 @@ static inline void pl011_rx_dma_disable()
|
|||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
read(val, PL011_UARTDMACR);
|
read(val, PL011_UARTDMACR);
|
||||||
val &= ~PL011_RXDMAEN;
|
val &= ~PL011_RXDMAEN;
|
||||||
write(val, PL011_UARTDMACR);
|
write(val, PL011_UARTDMACR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* __PL011__UART__ */
|
#endif /* __PL011__UART__ */
|
||||||
|
|
||||||
@@ -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];
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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__ */
|
||||||
|
|
||||||
@@ -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];
|
||||||
@@ -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
|
||||||
130
containers/posix/libc/include/time.h
Normal file
130
containers/posix/libc/include/time.h
Normal file
@@ -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 <stddef.h> /* 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_ */
|
||||||
@@ -1 +0,0 @@
|
|||||||
arch-arm
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
/* Dummies to keep Codesourcery 4.1.1 libgcc division exceptions silent. */
|
/* Dummies to keep Codesourcery 4.1.1 libgcc division exceptions silent. */
|
||||||
void raise(void)
|
void raise(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __aeabi_unwind_cpp_pr0(void)
|
void __aeabi_unwind_cpp_pr0(void)
|
||||||
|
|||||||
105
containers/posix/libc/src/arch-arm/jmp.S
Normal file
105
containers/posix/libc/src/arch-arm/jmp.S
Normal file
@@ -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)
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* Ties up platform's uart driver functions with generic API
|
|
||||||
*
|
|
||||||
* Copyright (C) 2007 Bahadir Balban
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <arch/uart.h>
|
|
||||||
#include <arch/pl011_uart.h>
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
107
containers/posix/libc/src/asctime.c
Normal file
107
containers/posix/libc/src/asctime.c
Normal file
@@ -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 <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
96
containers/posix/libc/src/assert.c
Normal file
96
containers/posix/libc/src/assert.c
Normal file
@@ -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 <assert.h> /* For __assert */
|
||||||
|
#include <stdio.h> /* For fprintf() */
|
||||||
|
#include <stdlib.h> /* 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();
|
||||||
|
}
|
||||||
95
containers/posix/libc/src/calloc.c
Normal file
95
containers/posix/libc/src/calloc.c
Normal file
@@ -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 <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void *
|
||||||
|
calloc(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
ptr = malloc(nmemb * size);
|
||||||
|
if (ptr)
|
||||||
|
memset(ptr, '\0', nmemb * size);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
88
containers/posix/libc/src/clearerr.c
Normal file
88
containers/posix/libc/src/clearerr.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
clearerr(FILE *stream)
|
||||||
|
{
|
||||||
|
lock_stream(stream);
|
||||||
|
stream->error = 0;
|
||||||
|
stream->eof = 0;
|
||||||
|
unlock_stream(stream);
|
||||||
|
}
|
||||||
86
containers/posix/libc/src/clock.c
Normal file
86
containers/posix/libc/src/clock.c
Normal file
@@ -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.h>
|
||||||
|
|
||||||
|
clock_t
|
||||||
|
clock(void)
|
||||||
|
{
|
||||||
|
return 0; /* Don't currently do time -- will probably need to be
|
||||||
|
system dependant */
|
||||||
|
}
|
||||||
0
containers/posix/libc/src/ctype.c
Normal file
0
containers/posix/libc/src/ctype.c
Normal file
86
containers/posix/libc/src/difftime.c
Normal file
86
containers/posix/libc/src/difftime.c
Normal file
@@ -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.h>
|
||||||
|
|
||||||
|
double
|
||||||
|
difftime(time_t time1, time_t time2)
|
||||||
|
{
|
||||||
|
return (double) (time1 - time2);
|
||||||
|
}
|
||||||
82
containers/posix/libc/src/errno.c
Normal file
82
containers/posix/libc/src/errno.c
Normal file
@@ -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
|
||||||
99
containers/posix/libc/src/exit.c
Normal file
99
containers/posix/libc/src/exit.c
Normal file
@@ -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 <stdlib.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
exit(int status)
|
||||||
|
{
|
||||||
|
/* Call registered atexit() functions */
|
||||||
|
|
||||||
|
/* Flush unbuffered data */
|
||||||
|
|
||||||
|
/* Close all streams */
|
||||||
|
|
||||||
|
/* Remove anything created by tmpfile() */
|
||||||
|
|
||||||
|
/* Call _Exit() */
|
||||||
|
_Exit(status);
|
||||||
|
}
|
||||||
|
|
||||||
92
containers/posix/libc/src/fclose.c
Normal file
92
containers/posix/libc/src/fclose.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
fclose(FILE *stream)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
lock_stream(stream);
|
||||||
|
r = stream->close_fn(stream->handle);
|
||||||
|
/* fflush file */
|
||||||
|
unlock_stream(stream);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
89
containers/posix/libc/src/feof.c
Normal file
89
containers/posix/libc/src/feof.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
feof(FILE *f)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
lock_stream(f);
|
||||||
|
res = f->eof;
|
||||||
|
unlock_stream(f);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
89
containers/posix/libc/src/ferror.c
Normal file
89
containers/posix/libc/src/ferror.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
ferror(FILE *stream)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
lock_stream(stream);
|
||||||
|
res = stream->error;
|
||||||
|
unlock_stream(stream);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
89
containers/posix/libc/src/fflush.c
Normal file
89
containers/posix/libc/src/fflush.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
fflush(FILE *file)
|
||||||
|
{
|
||||||
|
lock_stream(file);
|
||||||
|
/* FIXME: printf("WARNING: fflush not implemented\n"); */
|
||||||
|
unlock_stream(file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
105
containers/posix/libc/src/fgetc.c
Normal file
105
containers/posix/libc/src/fgetc.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
108
containers/posix/libc/src/fgets.c
Normal file
108
containers/posix/libc/src/fgets.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,11 +80,10 @@
|
|||||||
Authors: Cristan Szmadja, Ben Leslie
|
Authors: Cristan Szmadja, Ben Leslie
|
||||||
*/
|
*/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "stdio.h"
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#define fputc putc
|
|
||||||
/*
|
/*
|
||||||
* lookup tables for umaxtostr
|
* lookup tables for umaxtostr
|
||||||
*/
|
*/
|
||||||
|
|||||||
98
containers/posix/libc/src/fprintf.c
Normal file
98
containers/posix/libc/src/fprintf.c
Normal file
@@ -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 <benjl@cse.unsw.edu.au>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
19
containers/posix/libc/src/fputc.c
Normal file
19
containers/posix/libc/src/fputc.c
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
95
containers/posix/libc/src/fputs.c
Normal file
95
containers/posix/libc/src/fputs.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
101
containers/posix/libc/src/fread.c
Normal file
101
containers/posix/libc/src/fread.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
87
containers/posix/libc/src/fscanf.c
Normal file
87
containers/posix/libc/src/fscanf.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
fscanf(FILE *stream, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
103
containers/posix/libc/src/fseek.c
Normal file
103
containers/posix/libc/src/fseek.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
90
containers/posix/libc/src/ftell.c
Normal file
90
containers/posix/libc/src/ftell.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
long int
|
||||||
|
ftell(FILE *stream)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
lock_stream(stream);
|
||||||
|
res = stream->current_pos;
|
||||||
|
unlock_stream(stream);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
102
containers/posix/libc/src/fwrite.c
Normal file
102
containers/posix/libc/src/fwrite.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
89
containers/posix/libc/src/getchar.c
Normal file
89
containers/posix/libc/src/getchar.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
getchar(void)
|
||||||
|
{
|
||||||
|
return fgetc(stdin);
|
||||||
|
}
|
||||||
88
containers/posix/libc/src/getenv.c
Normal file
88
containers/posix/libc/src/getenv.c
Normal file
@@ -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 <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
char *
|
||||||
|
getenv(const char *name)
|
||||||
|
{
|
||||||
|
printf("WARNING: getenv not implemented\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
86
containers/posix/libc/src/gmtime.c
Normal file
86
containers/posix/libc/src/gmtime.c
Normal file
@@ -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.h>
|
||||||
|
|
||||||
|
struct tm *
|
||||||
|
gmtime(const time_t *timer)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
20
containers/posix/libc/src/k_r_malloc.h
Normal file
20
containers/posix/libc/src/k_r_malloc.h
Normal file
@@ -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_ */
|
||||||
128
containers/posix/libc/src/locale.c
Normal file
128
containers/posix/libc/src/locale.c
Normal file
@@ -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 <locale.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
86
containers/posix/libc/src/localtime.c
Normal file
86
containers/posix/libc/src/localtime.c
Normal file
@@ -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.h>
|
||||||
|
|
||||||
|
struct tm *
|
||||||
|
localtime(const time_t *timer)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
206
containers/posix/libc/src/malloc.c
Normal file
206
containers/posix/libc/src/malloc.c
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* K&R Malloc
|
||||||
|
*
|
||||||
|
* System specifc code should implement `more_core'
|
||||||
|
*/
|
||||||
|
#include "k_r_malloc.h"
|
||||||
|
#include <stddef.h> /* For NULL */
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h> /* For memcpy */
|
||||||
|
|
||||||
|
#ifdef THREAD_SAFE
|
||||||
|
#include <mutex/mutex.h>
|
||||||
|
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 <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
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: <base>\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
|
||||||
103
containers/posix/libc/src/memchr.c
Normal file
103
containers/posix/libc/src/memchr.c
Normal file
@@ -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 <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
98
containers/posix/libc/src/memcmp.c
Normal file
98
containers/posix/libc/src/memcmp.c
Normal file
@@ -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 <string.h>
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
115
containers/posix/libc/src/memcpy.c
Normal file
115
containers/posix/libc/src/memcpy.c
Normal file
@@ -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 <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
104
containers/posix/libc/src/memmove.c
Normal file
104
containers/posix/libc/src/memmove.c
Normal file
@@ -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 <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
138
containers/posix/libc/src/memset.c
Normal file
138
containers/posix/libc/src/memset.c
Normal file
@@ -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 <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
86
containers/posix/libc/src/mktime.c
Normal file
86
containers/posix/libc/src/mktime.c
Normal file
@@ -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.h>
|
||||||
|
|
||||||
|
time_t
|
||||||
|
mktime(struct tm *timeptr)
|
||||||
|
{
|
||||||
|
/* Not currently implemented */
|
||||||
|
return (time_t)(-1);
|
||||||
|
}
|
||||||
10
containers/posix/libc/src/perror.c
Normal file
10
containers/posix/libc/src/perror.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -1,446 +1,100 @@
|
|||||||
/*********************************************************************
|
/*
|
||||||
*
|
* Australian Public Licence B (OZPLB)
|
||||||
* Copyright (C) 2002-2004 Karlsruhe University
|
*
|
||||||
*
|
* Version 1-0
|
||||||
* File path: generic/printk.cc
|
*
|
||||||
* Description: Implementation of printf
|
* Copyright (c) 2004 National ICT Australia
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* All rights reserved.
|
||||||
* modification, are permitted provided that the following conditions
|
*
|
||||||
* are met:
|
* Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* National ICT Australia
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* http://www.ertos.nicta.com.au
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
*
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* Permission is granted by National ICT Australia, free of charge, to
|
||||||
* documentation and/or other materials provided with the distribution.
|
* any person obtaining a copy of this software and any associated
|
||||||
*
|
* documentation files (the "Software") to deal with the Software without
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
* restriction, including (without limitation) the rights to use, copy,
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* modify, adapt, merge, publish, distribute, communicate to the public,
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* sublicense, and/or sell, lend or rent out copies of the Software, and
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
* to permit persons to whom the Software is furnished to do so, subject
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* to the following conditions:
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
*
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* * Redistributions of source code must retain the above copyright
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* notice, this list of conditions and the following disclaimers.
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
*
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* * Redistributions in binary form must reproduce the above
|
||||||
* SUCH DAMAGE.
|
* copyright notice, this list of conditions and the following
|
||||||
*
|
* disclaimers in the documentation and/or other materials provided
|
||||||
********************************************************************/
|
* with the distribution.
|
||||||
#include <stdarg.h> /* for va_list, ... comes with gcc */
|
*
|
||||||
|
* * 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 <benjl@cse.unsw.edu.au>
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "format.h"
|
||||||
|
|
||||||
/* FIXME: LICENSE LICENCE */
|
/* All of these functions do not lock the I/O stream. They all end up calling
|
||||||
typedef unsigned int word_t;
|
* format which handles the locking. */
|
||||||
|
|
||||||
extern void putc(const char c);
|
int
|
||||||
extern int print_tid (word_t val, word_t width, word_t precision, int adjleft);
|
printf(const char *format, ...)
|
||||||
|
|
||||||
|
|
||||||
/* 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 ret;
|
||||||
int nwidth = 0;
|
va_list ap;
|
||||||
unsigned int high, low;
|
|
||||||
|
va_start(ap, format);
|
||||||
high = val >> 32;
|
ret = vfprintf(stdout, format, ap);
|
||||||
low = (unsigned int)val;
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#include <arch/uart.h>
|
|
||||||
|
|
||||||
void putc(char c)
|
|
||||||
{
|
|
||||||
if (c == '\n')
|
|
||||||
uart_putc('\r');
|
|
||||||
uart_putc(c);
|
|
||||||
}
|
|
||||||
89
containers/posix/libc/src/putchar.c
Normal file
89
containers/posix/libc/src/putchar.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
putchar(int c)
|
||||||
|
{
|
||||||
|
return fputc(c, stdout);
|
||||||
|
}
|
||||||
88
containers/posix/libc/src/puts.c
Normal file
88
containers/posix/libc/src/puts.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
puts(const char *s)
|
||||||
|
{
|
||||||
|
while(*s != '\0')
|
||||||
|
fputc(*s++, stdout);
|
||||||
|
fputc('\n', stdout);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
40
containers/posix/libc/src/qsort.c
Normal file
40
containers/posix/libc/src/qsort.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
95
containers/posix/libc/src/rand.c
Normal file
95
containers/posix/libc/src/rand.c
Normal file
@@ -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 <stdlib.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
33
containers/posix/libc/src/realloc.c
Normal file
33
containers/posix/libc/src/realloc.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* K&R Malloc
|
||||||
|
*
|
||||||
|
* System specifc code should implement `more_core'
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "k_r_malloc.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
85
containers/posix/libc/src/remove.c
Normal file
85
containers/posix/libc/src/remove.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
remove(const char *filename)
|
||||||
|
{
|
||||||
|
return 1; /* Always return failure */
|
||||||
|
}
|
||||||
85
containers/posix/libc/src/rename.c
Normal file
85
containers/posix/libc/src/rename.c
Normal file
@@ -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 <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
rename(const char *old, const char *new)
|
||||||
|
{
|
||||||
|
return 1; /* Always return failure */
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user