Skip to content

Commit

Permalink
Merge pull request #966 from jphickey/fix-832-stub-handler-replacements
Browse files Browse the repository at this point in the history
Fix #832, add "handler" feature to utassert stub API
  • Loading branch information
astrogeco authored Apr 28, 2021
2 parents f9e879e + e9f344b commit c2dc403
Show file tree
Hide file tree
Showing 129 changed files with 10,512 additions and 5,239 deletions.
94 changes: 94 additions & 0 deletions src/os/shared/inc/os-shared-console.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer"
*
* Copyright (c) 2019 United States Government as represented by
* the Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* \file
*
* \ingroup shared
*
* Table implementation and calls related to the console buffer.
*
* This is a simple ring buffer that decouples
* the OS_printf() call from actual console output.
*
* The implementation layer may optionally spawn a
* "utility task" or equivalent to forward data, or
* it may process data immediately.
*/

#ifndef OS_SHARED_CONSOLE_H
#define OS_SHARED_CONSOLE_H

#include "osapi-printf.h"
#include "os-shared-printf.h"
#include "os-shared-globaldefs.h"

/**
* The generic console data record
*/
typedef struct
{
char device_name[OS_MAX_API_NAME];

char * BufBase; /**< Start of the buffer memory */
size_t BufSize; /**< Total size of the buffer */
volatile size_t ReadPos; /**< Offset of next byte to read */
volatile size_t WritePos; /**< Offset of next byte to write */
uint32 OverflowEvents; /**< Number of lines dropped due to overflow */

} OS_console_internal_record_t;

extern OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES];

/****************************************************************************************
CONSOLE / DEBUG API LOW-LEVEL IMPLEMENTATION FUNCTIONS
****************************************************************************************/

/*---------------------------------------------------------------------------------------
Name: OS_ConsoleAPI_Init
Purpose: Initialize the OS-independent layer for console service
returns: OS_SUCCESS on success, or relevant error code
---------------------------------------------------------------------------------------*/
int32 OS_ConsoleAPI_Init(void);

/*----------------------------------------------------------------
Function: OS_ConsoleCreate_Impl
Purpose: Prepare a console device for use
For Async devices, this sets up the background writer task
------------------------------------------------------------------*/
int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token);

/*----------------------------------------------------------------
Function: OS_ConsoleWakeup_Impl
Purpose: Console output data notification
This is a notification API that is invoked whenever there
is new data available in the console output buffer.
It is only used of the console is configured for async operation,
and it should wakeup the actual console servicing thread.
------------------------------------------------------------------*/
void OS_ConsoleWakeup_Impl(const OS_object_token_t *token);

#endif /* OS_SHARED_CONSOLE_H */
9 changes: 8 additions & 1 deletion src/os/shared/inc/os-shared-idmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ struct OS_object_token
*/
typedef bool (*OS_ObjectMatchFunc_t)(void *ref, const OS_object_token_t *token, const OS_common_record_t *obj);

/*
* A function to serve as callback with object ID iterators
*
* This is the prototype of callback functions for use with OS_ObjectIdIteratorProcessEntry()
*/
typedef int32 (*OS_ObjectIdIteratorProcessFunc_t)(osal_id_t, void *);

/*
* State object associated with an object iterator
*/
Expand Down Expand Up @@ -533,7 +540,7 @@ static inline const OS_object_token_t *OS_ObjectIdIteratorRef(OS_object_iter_t *
Returns: None
------------------------------------------------------------------*/
int32 OS_ObjectIdIteratorProcessEntry(OS_object_iter_t *iter, int32 (*func)(osal_id_t, void *));
int32 OS_ObjectIdIteratorProcessEntry(OS_object_iter_t *iter, OS_ObjectIdIteratorProcessFunc_t func);

/*
* Internal helper functions
Expand Down
57 changes: 1 addition & 56 deletions src/os/shared/inc/os-shared-printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,53 +29,13 @@
#define OS_SHARED_PRINTF_H

#include "osapi-printf.h"
#include "os-shared-console.h"
#include "os-shared-globaldefs.h"

/*
* Variables related to the console buffer.
* This is a simple ring buffer that decouples
* the OS_printf() call from actual console output.
*
* The implementation layer may optionally spawn a
* "utility task" or equivalent to forward data, or
* it may process data immediately.
*/

typedef struct
{
char device_name[OS_MAX_API_NAME];

char * BufBase; /**< Start of the buffer memory */
size_t BufSize; /**< Total size of the buffer */
volatile size_t ReadPos; /**< Offset of next byte to read */
volatile size_t WritePos; /**< Offset of next byte to write */
uint32 OverflowEvents; /**< Number of lines dropped due to overflow */

} OS_console_internal_record_t;

extern OS_console_internal_record_t OS_console_table[OS_MAX_CONSOLES];

/****************************************************************************************
CONSOLE / DEBUG API LOW-LEVEL IMPLEMENTATION FUNCTIONS
****************************************************************************************/

/*---------------------------------------------------------------------------------------
Name: OS_ConsoleAPI_Init
Purpose: Initialize the OS-independent layer for console service
returns: OS_SUCCESS on success, or relevant error code
---------------------------------------------------------------------------------------*/
int32 OS_ConsoleAPI_Init(void);

/*----------------------------------------------------------------
Function: OS_ConsoleCreate_Impl
Purpose: Prepare a console device for use
For Async devices, this sets up the background writer task
------------------------------------------------------------------*/
int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token);

/*----------------------------------------------------------------
Function: OS_ConsoleOutput_Impl
Expand All @@ -88,19 +48,4 @@ int32 OS_ConsoleCreate_Impl(const OS_object_token_t *token);
------------------------------------------------------------------*/
void OS_ConsoleOutput_Impl(const OS_object_token_t *token);

/*----------------------------------------------------------------
Function: OS_ConsoleOutput_Impl
Purpose: Console output data notification
This is a notification API that is invoked whenever there
is new data available in the console output buffer.
For a synchronous console service, this may call
OS_ConsoleWrite_Impl() directly. For an async console
service, this should wakeup the actual console servicing
thread.
------------------------------------------------------------------*/
void OS_ConsoleWakeup_Impl(const OS_object_token_t *token);

#endif /* OS_SHARED_PRINTF_H */
2 changes: 2 additions & 0 deletions src/unit-test-coverage/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ set(SHARED_COVERAGE_LINK_LIST
os-shared-coverage-support
ut-adaptor-shared
ut_osapi_impl_stubs
ut_osapi_init_stubs
ut_osapi_shared_stubs
ut_osapi_table_stubs
ut_osapi_stubs
ut_libc_stubs
)
Expand Down
Loading

0 comments on commit c2dc403

Please sign in to comment.