Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev pranjal posix #110

Merged
merged 10 commits into from
Feb 19, 2022
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@
"diffEditor.codeLens": true,
"diffEditor.wordWrap": "on",
"editor.suggest.showStatusBar": true,
"editor.formatOnSave": false,
"files.associations": {
"*.sx": "c",
"*.{c,c.dev.c.temp,c.tmp,c.old,h,h.dev,h.old,h.temp,h.tmp)": "C",
"*.{cpp,cpp.dev,cpp.temp,cpp.tmp,cpp.old}": "C++",
"*.{S,S.old,S.dev.S.temp,S.tmp,s.old,s.temp,s.tmp,s.dev,asm,asm.old,asm.dev.asm.temp,asm.tmp,inc,inc.old,inc.temp,inc.tmp,ld,ld.old,ld.temp,ld.tmp,ld.sx,ld.sx.old,ld.sx.temp,ld.sx.tmp,lst}": "coffeescript",
},
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 5000,
"files.autoSaveDelay": 100,
"files.defaultLanguage": "C",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
Expand Down
21 changes: 21 additions & 0 deletions src/include/call_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022 Year :)

*
* File Name : call_type.c
* Description : This file consists of call_typedef
* Primary Author : Pranjal Chanda [pranjalchanda08@gmail.com]
* Organisation : Cyancore Core-Team
*/

#pragma once

#if defined(ARCH_ARM_32)
typedef unsigned long call_args;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved to core header file...
This will auto typedef. Anyways we have that header file in place for core specific functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sure


#elif defined(ARCH_RISCV_64) || defined(ARCH_ARM_64)
typedef unsigned long long call_args;

#else
typedef unsigned int call_args;
#endif
5 changes: 2 additions & 3 deletions src/include/machine_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <stdint.h>
#include <status.h>
#include <call_type.h>

// Machine call IDs
typedef enum mcall_id
Expand All @@ -22,8 +23,6 @@ typedef enum mcall_id
set_sleep_mode = 0x0003,
} mcall_id_t;



typedef struct mret
{
uintptr_t p;
Expand All @@ -34,7 +33,7 @@ typedef struct mret
typedef struct mcall
{
mcall_id_t id;
mret_t (*callback)(unsigned int a0, unsigned int a1, unsigned int a2);
mret_t (*callback)(call_args a0, call_args a1, call_args a2);
} mcall_t;

#define INCLUDE_MCALL(_name, _id , _callback) \
Expand Down
14 changes: 3 additions & 11 deletions src/include/supervisor_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,15 @@

#include <stdint.h>
#include <status.h>
#include <call_type.h>

// Supervisor call IDs
typedef enum scall_id
{
scall_id_generic = 0x0000,
scall_id_is_irq,
/* pthread related */
scall_id_pthread_attr_destroy = 0x1000,
scall_id_pthread_attr_getdetachstate,
scall_id_pthread_attr_getschedparam,
scall_id_pthread_attr_getstacksize,
scall_id_pthread_attr_init,
scall_id_pthread_attr_setdetachstate,
scall_id_pthread_attr_setschedparam,
scall_id_pthread_attr_setschedpolicy,
scall_id_pthread_attr_setstacksize,
scall_id_pthread_barrier_destroy,
scall_id_pthread_barrier_destroy = 0x1000,
scall_id_pthread_barrier_init,
scall_id_pthread_barrier_wait,
scall_id_pthread_create,
Expand Down Expand Up @@ -84,7 +76,7 @@ typedef struct sret
typedef struct scall
{
scall_id_t id;
sret_t (*callback)(unsigned int a0, unsigned int a1, unsigned int a2);
sret_t (*callback)(call_args a0, call_args a1, call_args a2);
} scall_t;

#define INCLUDE_SCALL(_name, _id , _callback) \
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libposix/include/posix/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ int pthread_equal( pthread_t t1,
*
* @retval void - this function cannot return to its caller.
*/
void pthread_exit( void * value_ptr );
void pthread_exit( const void * value_ptr );

/**
* @brief Dynamic thread scheduling parameters access.
Expand Down
118 changes: 60 additions & 58 deletions src/lib/libposix/include/posix/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,174 +25,176 @@
*
* Enabled/disabled by posixconfigENABLE_CLOCK_T.
*/
#if !defined( posixconfigENABLE_CLOCK_T ) || ( posixconfigENABLE_CLOCK_T == 1 )
typedef uint32_t clock_t;
#if !defined(posixconfigENABLE_CLOCK_T) || (posixconfigENABLE_CLOCK_T == 1)
typedef uint32_t clock_t;
#endif

/**
* @brief Used for clock ID type in the clock and timer functions.
*
* Enabled/disabled by posixconfigENABLE_CLOCKID_T.
*/
#if !defined( posixconfigENABLE_CLOCKID_T ) || ( posixconfigENABLE_CLOCKID_T == 1 )
typedef int clockid_t;
#if !defined(posixconfigENABLE_CLOCKID_T) || (posixconfigENABLE_CLOCKID_T == 1)
typedef int clockid_t;
#endif

/**
* @brief Used for some file attributes.
*
* Enabled/disabled by posixconfigENABLE_MODE_T.
*/
#if !defined( posixconfigENABLE_MODE_T ) || ( posixconfigENABLE_MODE_T == 1 )
typedef int mode_t;
#if !defined(posixconfigENABLE_MODE_T) || (posixconfigENABLE_MODE_T == 1)
typedef int mode_t;
#endif

/**
* @brief Used for process IDs and process group IDs.
*
* Enabled/disabled by posixconfigENABLE_PID_T.
*/
#if !defined( posixconfigENABLE_PID_T ) || ( posixconfigENABLE_PID_T == 1 )
typedef int pid_t;
#if !defined(posixconfigENABLE_PID_T) || (posixconfigENABLE_PID_T == 1)
typedef int pid_t;
#endif

/**
* @brief Used to identify a thread attribute object.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_ATTR_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_ATTR_T ) || ( posixconfigENABLE_PTHREAD_ATTR_T == 1 )
typedef struct pthread_attr
{
int detach_state;
int policy;
sched_param_t sched_param;
size_t stacksize;
}pthread_attr_t;
#if !defined(posixconfigENABLE_PTHREAD_ATTR_T) || (posixconfigENABLE_PTHREAD_ATTR_T == 1)
typedef struct pthread_attr
{
int detach_state;
int policy;
sched_param_t sched_param;
size_t stacksize;
} pthread_attr_t;
#endif

/**
* @brief Used to identify a barrier.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_BARRIER_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_BARRIER_T ) || ( posixconfigENABLE_PTHREAD_BARRIER_T == 1 )
typedef struct pthread_barrier
{
/* pthread_barrier structure place holder */
}pthread_barrier_t;
#if !defined(posixconfigENABLE_PTHREAD_BARRIER_T) || (posixconfigENABLE_PTHREAD_BARRIER_T == 1)
typedef struct pthread_barrier
{
/* pthread_barrier structure place holder */
} pthread_barrier_t;
#endif

/**
* @brief Used to define a barrier attributes object.
*/
typedef void * pthread_barrierattr_t;
typedef void *pthread_barrierattr_t;

/**
* @brief Used for condition variables.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_COND_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_COND_T ) || ( posixconfigENABLE_PTHREAD_COND_T == 1 )
typedef struct pthread_cond
{
/* pthread_cond structure place holder */
}pthread_cond_t;
#if !defined(posixconfigENABLE_PTHREAD_COND_T) || (posixconfigENABLE_PTHREAD_COND_T == 1)
typedef struct pthread_cond
{
/* pthread_cond structure place holder */
} pthread_cond_t;
#endif

/**
* @brief Used to identify a condition attribute object.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_CONDATTR_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_CONDATTR_T ) || ( posixconfigENABLE_PTHREAD_CONDATTR_T == 1 )
typedef void * pthread_condattr_t;
#if !defined(posixconfigENABLE_PTHREAD_CONDATTR_T) || (posixconfigENABLE_PTHREAD_CONDATTR_T == 1)
typedef void *pthread_condattr_t;
#endif

/**
* @brief Used for mutexes.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEX_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_MUTEX_T ) || ( posixconfigENABLE_PTHREAD_MUTEX_T == 1 )
typedef struct pthread_mutex
{
/* pthread_mutex structure place holder */
}pthread_mutex_t;
#if !defined(posixconfigENABLE_PTHREAD_MUTEX_T) || (posixconfigENABLE_PTHREAD_MUTEX_T == 1)
typedef struct pthread_mutex
{
/* pthread_mutex structure place holder */
} pthread_mutex_t;
#endif

/**
* @brief Used to identify a mutex attribute object.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEXATTR_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_MUTEXATTR_T ) || ( posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1 )
typedef struct pthread_mutexattr
{
/* pthread_mutexattr structure place holder */
}pthread_mutexattr_t;
#if !defined(posixconfigENABLE_PTHREAD_MUTEXATTR_T) || (posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1)
typedef struct pthread_mutexattr
{
/* pthread_mutexattr structure place holder */
} pthread_mutexattr_t;
#endif

/**
* @brief Used to identify a thread.
*
* Enabled/disabled by posixconfigENABLE_PTHREAD_T.
*/
#if !defined( posixconfigENABLE_PTHREAD_T ) || ( posixconfigENABLE_PTHREAD_T == 1 )
typedef struct pthread
{
/* pthread structure place holder */
}pthread_t;
#if !defined(posixconfigENABLE_PTHREAD_T) || (posixconfigENABLE_PTHREAD_T == 1)
typedef struct pthread
{
pthread_attr_t *attr;
void *(*fn)(void *);
int pid;
} pthread_t;
#endif

/**
* @brief Used for a count of bytes or an error indication.
*
* Enabled/disabled by posixconfigENABLE_SSIZE_T.
*/
#if !defined( posixconfigENABLE_SSIZE_T ) || ( posixconfigENABLE_SSIZE_T == 1 )
typedef size_t ssize_t;
#if !defined(posixconfigENABLE_SSIZE_T) || (posixconfigENABLE_SSIZE_T == 1)
typedef size_t ssize_t;
#endif

/**
* @brief Used for time in seconds.
*
* Enabled/disabled by posixconfigENABLE_TIME_T.
*/
#if !defined( posixconfigENABLE_TIME_T ) || ( posixconfigENABLE_TIME_T == 1 )
typedef int64_t time_t;
#if !defined(posixconfigENABLE_TIME_T) || (posixconfigENABLE_TIME_T == 1)
typedef int64_t time_t;
#endif

/**
* @brief Used for timer ID returned by timer_create().
*
* Enabled/disabled by posixconfigENABLE_TIMER_T.
*/
#if !defined( posixconfigENABLE_TIMER_T ) || ( posixconfigENABLE_TIMER_T == 1 )
typedef void * timer_t;
#if !defined(posixconfigENABLE_TIMER_T) || (posixconfigENABLE_TIMER_T == 1)
typedef void *timer_t;
#endif

/**
* @brief Used for time in microseconds.
*
* Enabled/disabled by posixconfigENABLE_USECONDS_T.
*/
#if !defined( posixconfigENABLE_USECONDS_T ) || ( posixconfigENABLE_USECONDS_T == 1 )
typedef unsigned long useconds_t;
#if !defined(posixconfigENABLE_USECONDS_T) || (posixconfigENABLE_USECONDS_T == 1)
typedef unsigned long useconds_t;
#endif

/**
* @brief Used for file sizes.
*
* Enabled/disabled by posixconfigENABLE_OFF_T.
*/
#if !defined( posixconfigENABLE_OFF_T ) || ( posixconfigENABLE_OFF_T == 1 )
typedef long int off_t;
#if !defined(posixconfigENABLE_OFF_T) || (posixconfigENABLE_OFF_T == 1)
typedef long int off_t;
#endif

#if( posixconfigUSE_16_BIT_TICKS == 1 )
typedef uint16_t TickType_t;
#if (posixconfigUSE_16_BIT_TICKS == 1)
typedef uint16_t TickType_t;
#else
typedef size_t TickType_t;
typedef size_t TickType_t;
#endif
#define posixconfigMAX_DELAY (TickType_t)(~0)
#define posixconfigMAX_DELAY (TickType_t)(~0)
Loading