FreeRTOS-Kernel/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c
Florian La Roche 995a030a92
MPS2_AN385 improvements (#1225)
* MPS2_AN385 improvements

Sync various MPS2_AN385 CORTEX-M3 QEMU targets and improve their
Makefiles and cleanup gcc support:
- FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2:
  - Makefile
    - output image size after linking
    - move -nostartfiles from compiler to linker flags
    - modernize compiler warning flags
    - add --gc-sections to linker flags
  - TCPEchoClient_SingleTasks.c: fix compiler warnings
  - main.c: fix compiler warnings (remove unused code)
  - main_networking.c
    - remove ipLOCAL_MAC_ADDRESS (unknown)
    - fix compiler warnings about unused params
  - startup.c: main(void), remove unused includes,
    silence  unused params
  - syscalls.c: remove unused defines, silence unused params,
    more compact _sbrk()
- FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc:
  - Makefile
    - CFLAGS/LDFLAGS in more readable lines
    - move -nostartfiles to linker flags
    - comment out -specs=rdimon.specs as it is not needed
  - startup_gcc.c: fix typo in comment, remove unused uart code
- FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC
  - Makefile
    - after compilation output size of image
    - remove -DQEMU_SOC_MPS2, not needed
    - update many CFLAGS/LDFLAGS settings to more modern gcc/source
    - -ffunction-sections -fdata-sections is moved to CFLAGS
  - startup.c: sync with other ports
  - syscall.c: _write(): param buf is not unused, silence unused params

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>

* remove ipLOCAL_MAC_ADDRESS completely and fix formatting errors

remove ipLOCAL_MAC_ADDRESS completely and fix formatting errors

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
2024-06-04 20:08:16 +05:30

133 lines
3.2 KiB
C

/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
typedef struct UART_t
{
volatile uint32_t DATA;
volatile uint32_t STATE;
volatile uint32_t CTRL;
volatile uint32_t INTSTATUS;
volatile uint32_t BAUDDIV;
} UART_t;
#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) )
#define UART_DR( baseaddr ) ( *( unsigned int * ) ( baseaddr ) )
#define UART_CTRL_TX_EN ( 1 << 0 )
extern unsigned long _heap_bottom;
extern unsigned long _heap_top;
static char * heap_end = ( char * ) &_heap_bottom;
/**
* @brief initializes the UART emulated hardware
*/
void uart_init( void )
{
UART0_ADDR->BAUDDIV = 16;
UART0_ADDR->CTRL = UART_CTRL_TX_EN;
}
/**
* @brief not used anywhere in the code
* @todo implement if necessary
*
*/
int _fstat( int file )
{
( void ) file;
return 0;
}
/**
* @brief not used anywhere in the code
* @todo implement if necessary
*
*/
int _read( int file,
char * buf,
int len )
{
( void ) file;
( void ) buf;
( void ) len;
return -1;
}
/**
* @brief Write bytes to the UART channel to be displayed on the command line
* with qemu
* @param [in] file ignored
* @param [in] buf buffer to send
* @param [in] len length of the buffer
* @returns the number of bytes written
*/
int _write( int file,
char * buf,
int len )
{
int todo;
( void ) file;
for( todo = 0; todo < len; todo++ )
{
UART_DR( UART0_ADDR ) = *buf++;
}
return len;
}
/**
* @brief function called by malloc and friends to reserve memory on the heap
* @param [in] incr the amount of bytes to increase or decrease
* @returns the previous top of the heap
* @note uses a global variable <b>heap_end</b> to keep track of the previous top
*/
void * _sbrk( int incr )
{
void * prev_heap_end = heap_end;
if( ( heap_end + incr ) > ( char * ) &_heap_top )
{
return ( void * ) -1;
}
heap_end += incr;
return prev_heap_end;
}
#ifdef __cplusplus
}
#endif