Skip to content

Commit

Permalink
Merge pull request #90 from VisorFolks/fr-cc-posix
Browse files Browse the repository at this point in the history
Add initial POSIX support to kernel

- Not Tested on target
  • Loading branch information
akashkollipara authored Jan 14, 2022
2 parents b0cbaed + 6ea7566 commit 92dff9f
Show file tree
Hide file tree
Showing 32 changed files with 3,176 additions and 79 deletions.
74 changes: 0 additions & 74 deletions .github/workflows/github_ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ For details about the framework, follow the README.md in each folder.

Host system requirements:
* Linux Machine (WSL/Dedicated machine)
* make utility and cppcheck installed; run
* make utility and cppcheck installed; run
```sh
$ sudo apt install build-essential cppcheck -y
```
Expand Down
10 changes: 10 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sonar.organization=cyancore
sonar.projectKey=VisorFolks_cyancore
sonar.sources=src
sonar.cfamily.build-wrapper-output=toolchain/bw-output
sonar.verbose=false
sonar.host.url=https://sonarcloud.io
sonar.verbose=true
sonar.cfamily.threads=8
sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=toolchain/bw-output/cfamily_cache
35 changes: 33 additions & 2 deletions src/include/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,65 @@

typedef enum status
{
success = 0x0000,
success = 0x0000,
/* Generic error */
error_generic = -0x0001,
error_func_inval = -0x0002,
error_func_inval_arg = -0x0003,
error_overflow = -0x0004,
/* Driver related error */
error_driver = -0x0100,
error_driver_init_done = -0x0101,
error_driver_init_failed = -0x0102,
error_driver_busy = -0x0103,
error_driver_data = -0x0104,
/* Device related error */
error_device = -0x0200,
error_device_id_inval = -0x0201,
error_device_inval = -0x0202,
error_device_busy = -0x0203,
/* Machine Call related error */
error_mcall = -0x0300,
error_mcall_code_inval = -0x0301,
/* hcall related error */
error_hcall = -0x0400,
/* Syscall related error */
error_scall = -0x0500,
error_scall_code_inval = -0x0501,
/* Memory related error */
error_memory = -0x0600,
error_memory_low = -0x0601,
/* File related error */
error_file = -0x0700,
error_file_desc = -0x0701,
error_file_exist = -0x0702,
error_file_not_found = -0x0703,
error_file_no_space = -0x0704,
error_file_long_name = -0x0705,
/* String related error */
error_string = -0x0800,
/* Math related error */
error_math = -0x0900,
error_math_inval_arg = -0x0901,
error_math_large_val = -0x0902,
/* Access related error */
error_access = -0x0a00,
/* System related error */
error_system = -0x0b00,
error_system_irq_link_fail = -0x0b01,
error_system_irq_unlink_fail = -0x0b02,
error_network = -0x0c00,
/* Network related error */
error_net = -0x0c00,
error_net_con_timeout = -0x0c001,
/* User space related error */
error_user = -0x0d00,
/* IO related error */
error_io = -0x0e00,
/* OS related error */
error_os = -0x0f00,
error_os_task_overfow = -0x0f01,
error_os_deadlock = -0x0f02,
/* Mesg related error */
error_mesg = -0x1000,
error_mesg_long = -0x1001,
} status_t;
95 changes: 95 additions & 0 deletions src/include/supervisor_call.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
*
* File Name : supervisor_call.h
* Description : This file consists of supervisor call IDs and prototypes
* Primary Author : Pranjal Chanda [[email protected]]
* Organisation : Cyancore Core-Team
*/

#pragma once
#define _SUPER_CALL_H_

#include <stdint.h>
#include <status.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_init,
scall_id_pthread_barrier_wait,
scall_id_pthread_create,
scall_id_pthread_cond_broadcast,
scall_id_pthread_cond_destroy,
scall_id_pthread_cond_init,
scall_id_pthread_cond_signal,
scall_id_pthread_cond_timedwait,
scall_id_pthread_equal,
scall_id_pthread_exit,
scall_id_pthread_getschedparam,
scall_id_pthread_join,
scall_id_pthread_mutex_destroy,
scall_id_pthread_mutex_init,
scall_id_pthread_mutex_timedlock,
scall_id_pthread_mutex_unlock,
scall_id_pthread_mutexattr_destroy,
scall_id_pthread_mutexattr_gettype,
scall_id_pthread_mutexattr_init,
scall_id_pthread_mutexattr_settype,
scall_id_pthread_self,
scall_id_pthread_setschedparam,
scall_id_pthread_delay_ticks,
/* mqueue related */
scall_id_mq_close,
scall_id_mq_setattr,
scall_id_mq_getattr,
scall_id_mq_open,
scall_id_mq_receive,
scall_id_mq_send,
scall_id_mq_unlink,
/* semaphore related */
scall_id_sem_init,
scall_id_sem_destroy,
scall_id_sem_getvalue,
scall_id_sem_post,
scall_id_sem_wait,
/* scheduler related */
scall_id_sched_get_max_priority,
scall_id_sched_get_min_priority,
scall_id_sched_yield,

} scall_id_t;

typedef struct sret
{
uintptr_t p;
size_t size;
status_t status;
} sret_t;

typedef struct scall
{
scall_id_t id;
sret_t (*callback)(unsigned int a0, unsigned int a1, unsigned int a2);
} scall_t;

#define INCLUDE_SCALL(_name, _id , _callback) \
const scall_t _name _SECTION(".scall") = \
{ \
.id = _id, \
.callback = _callback \
}
16 changes: 16 additions & 0 deletions src/include/visor/supervisor/workers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
*
* File Name : worker.h
* Description : This file consists of supervisor-workers
* and related prototypes
* Primary Author : Pranjal Chanda [[email protected]]
* Organisation : Cyancore Core-Team
*/

#pragma once

#include <supervisor_call.h>

void super_call(scall_id_t id, unsigned int a0, unsigned int a1, unsigned int a2, sret_t *ret);
1 change: 1 addition & 0 deletions src/lib/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LIB_DIR := $(GET_PATH)
# Mandatory libraries
include $(LIB_DIR)/libresource/build.mk
include $(LIB_DIR)/libc/build.mk
include $(LIB_DIR)/libposix/build.mk
#==================================================

include $(LIB_DIR)/libnmath/build.mk
2 changes: 1 addition & 1 deletion src/lib/libc/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int vprintf(const char *fmt, va_list args)
break;
case 'c':
str = va_arg(args, char *);
ret += console_putc((int)str);
ret += console_putc((int)str[0]);
break;
case 's':
str = va_arg(args, char *);
Expand Down
22 changes: 22 additions & 0 deletions src/lib/libposix/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# CYANCORE LICENSE
# Copyrights (C) 2019, Cyancore Team
#
# File Name : build.mk
# Descrption : This script accumulates sources and builds
# library
# Primary Author : Pranjal Chanda [[email protected]]
# Organisation : Cyancore Core-Team
#

POSIX_PATH := $(GET_PATH)
LIB_OBJS :=

LIB := libposix.a
LIB_INCLUDE += $(POSIX_PATH)/include/
DEP_LIBS_ARG += -lposix

include $(POSIX_PATH)/src/build.mk

DIR := $(POSIX_PATH)
include mk/lib.mk
47 changes: 47 additions & 0 deletions src/lib/libposix/include/cc_posix_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* CYANCORE LICENSE
* Copyrights (C) 2019, Cyancore Team
*
* File Name : cc_posix_config.h
* Description : POSIX user config
* Primary Author : Pranjal Chanda [[email protected]]
* Organisation : Cyancore Core-Team
*/

#pragma once

#ifndef posixconfigTICK_RATE_HZ
#define posixconfigTICK_RATE_HZ (1000)
#endif

/*******************
* MQUEUE configs
*******************/

/**
* @brief MQUEUE max name length in bytes
*/
#ifndef posixconfigMQ_NAME_LEN_MAX
#define posixconfigMQ_NAME_LEN_MAX (16)
#endif

/**
* @brief MQUEUE max munber of queues allowed
*/
#ifndef posixconfigMQ_MAX_QUEUE
#define posixconfigMQ_MAX_QUEUE (5)
#endif

/**
* @brief MQUEUE Maximum number of messages in an mq at one time
*/
#ifndef posixconfigMQ_MAX_MESSAGES
#define posixconfigMQ_MAX_MESSAGES (10)
#endif

/**
* @brief MQUEUE Maximum size (in bytes) of each message
*/
#ifndef posixconfigMQ_MAX_SIZE
#define posixconfigMQ_MAX_SIZE (128)
#endif
Loading

0 comments on commit 92dff9f

Please sign in to comment.