Turnstone Operating System
Loading...
Searching...
No Matches
task.h File Reference

cpu task definitons More...

#include <cpu/descriptor.h>
#include <cpu/interrupt.h>
#include <memory.h>
#include <memory/paging.h>
#include <list.h>
#include <buffer.h>
#include <utils.h>

Classes

struct  descriptor_tss_t
 64 bit tss descriptor More...
 
struct  tss_s
 tss descriptor values More...
 
struct  task_registers_t
 
struct  task_t
 

Macros

#define ___CPU_TASK_H   0
 
#define TASK_MAX_TICK_COUNT   10
 
#define TASK_IDLE_TASK_ID   1
 
#define TASK_KERNEL_TASK_ID   2
 
#define DESCRIPTOR_BUILD_TSS_SEG(tss, base, limit, DPL)
 initialize tss More...
 
#define task_init_tasking()   task_init_tasking_ext(NULL)
 
#define task_get_current_task_message_queue(queue_number)   task_get_message_queue(task_get_id(), queue_number)
 

Typedefs

typedef struct descriptor_tss_t descriptor_tss_t
 
typedef struct tss_s tss_t
 short hand for struct
 
typedef enum task_state_e task_state_t
 short hand for enum
 
typedef struct task_registers_t task_registers_t
 
typedef struct task_t task_t
 short hand for struct
 

Enumerations

enum  task_state_e {
  TASK_STATE_NULL , TASK_STATE_CREATED , TASK_STATE_STARTING , TASK_STATE_RUNNING ,
  TASK_STATE_SUSPENDED , TASK_STATE_ENDED
}
 task states More...
 

Functions

 _Static_assert (sizeof(task_registers_t)==0x290, "task_registers_t size must be 0x290")
 
 _Static_assert ((offsetof_field(task_registers_t, sse) % 0x10)==0x0, "task_registers_t sse offset must be aligned 0x10")
 
int8_t task_init_tasking_ext (memory_heap_t *heap)
 inits kernel tasking, configures tss and kernel task More...
 
void task_task_switch_set_parameters (boolean_t need_eoi, boolean_t need_sti)
 sets task switch parameters More...
 
void task_switch_task (void)
 switches current task to a new one.
 
void task_yield (void)
 yields task for waiting other tasks. More...
 
uint64_t task_get_id (void)
 returns current task's id More...
 
task_ttask_get_current_task (void)
 returns current task More...
 
void task_set_message_waiting (void)
 sets current task's message waiting flag
 
void task_clear_message_waiting (uint64_t task_id)
 clears current task's message waiting flag More...
 
void task_set_interruptible (void)
 sets current task's interruptible flag
 
void task_set_interrupt_received (uint64_t task_id)
 sets current task's interrupt received flag More...
 
void task_add_message_queue (list_t *queue)
 adds a queue to task More...
 
list_ttask_get_message_queue (uint64_t task_id, uint64_t queue_number)
 
uint64_t task_create_task (memory_heap_t *heap, uint64_t heap_size, uint64_t stack_size, void *entry_point, uint64_t args_cnt, void **args, const char_t *task_name)
 creates a task and apends it to wait queue More...
 
boolean_t task_idle_check_need_yield (void)
 idle task checks if there is any task neeeds to run. it speeds up task running
 
void task_current_task_sleep (uint64_t wake_tick)
 sleep for current task for ticks More...
 
void task_end_task (void)
 
void task_kill_task (uint64_t task_id, boolean_t force)
 
void task_print_all (void)
 
buffer_ttask_get_task_input_buffer (uint64_t tid)
 
buffer_ttask_get_task_output_buffer (uint64_t tid)
 
buffer_ttask_get_task_error_buffer (uint64_t tid)
 
buffer_ttask_get_input_buffer (void)
 dummy method for efi for getting input buffer. More...
 
buffer_ttask_get_output_buffer (void)
 dummy method for efi for getting output buffer. More...
 
buffer_ttask_get_error_buffer (void)
 dummy method for efi for getting error buffer. More...
 
int8_t task_set_input_buffer (buffer_t *buffer)
 
int8_t task_set_output_buffer (buffer_t *buffer)
 
int8_t task_set_error_buffer (buffer_t *buffer)
 
void task_set_vmcs_physical_address (uint64_t vmcs_physical_address)
 
uint64_t task_get_vmcs_physical_address (void)
 
void task_set_vm (void *vm)
 
void * task_get_vm (void)
 
void task_remove_task_after_fault (uint64_t task_id)
 
int8_t task_set_current_and_idle_task (void *entry_point, uint64_t stack_base, uint64_t stack_size)
 

Detailed Description

cpu task definitons

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ ___CPU_TASK_H

#define ___CPU_TASK_H   0

prevent duplicate header error macro

◆ DESCRIPTOR_BUILD_TSS_SEG

#define DESCRIPTOR_BUILD_TSS_SEG (   tss,
  base,
  limit,
  DPL 
)
Value:
{ \
tss->present = 1; \
tss->long_mode = 1; \
tss->dpl = DPL; \
tss->segment_limit1 = limit & 0xFFFF; \
tss->segment_limit2 = (limit >> 16) & 0xF; \
tss->base_address1 = base & 0xFFFFFF; \
tss->base_address2 = (base >> 24); \
}
#define SYSTEM_SEGMENT_TYPE_TSS_A
Definition: descriptor.h:146

initialize tss

Parameters
tssaddress of tss slot in gdt
basebase address of tss struct
limitlength of tss - 1
DPLprivilage level

◆ task_init_tasking

#define task_init_tasking ( )    task_init_tasking_ext(NULL)

inits tasking with default heap

◆ TASK_KERNEL_TASK_ID

#define TASK_KERNEL_TASK_ID   2

kernel task id

◆ TASK_MAX_TICK_COUNT

#define TASK_MAX_TICK_COUNT   10

maximum tick count of a task without yielding

Enumeration Type Documentation

◆ task_state_e

task states

Enumerator
TASK_STATE_NULL 

task state not known

TASK_STATE_CREATED 

task created but never runned

TASK_STATE_STARTING 

task is starting

TASK_STATE_RUNNING 

task is running

TASK_STATE_SUSPENDED 

task is at wait queue

TASK_STATE_ENDED 

task is ended

Function Documentation

◆ task_add_message_queue()

void task_add_message_queue ( list_t queue)

adds a queue to task

Parameters
[in]queuequeue which task will have. tasks consumes these queues

◆ task_clear_message_waiting()

void task_clear_message_waiting ( uint64_t  task_id)

clears current task's message waiting flag

Parameters
[in]task_idtask id

◆ task_create_task()

uint64_t task_create_task ( memory_heap_t heap,
uint64_t  heap_size,
uint64_t  stack_size,
void *  entry_point,
uint64_t  args_cnt,
void **  args,
const char_t task_name 
)

creates a task and apends it to wait queue

Parameters
[in]heapcreator heap
[in]heap_sizetask's heap size, heap allocated with frame allocator
[in]stack_sizetask's stack size, stack allocated with frame allocator
[in]entry_pointtask's entry point
[in]args_cntargument count
[in]argsargument list
[in]task_nametask's name

◆ task_current_task_sleep()

void task_current_task_sleep ( uint64_t  wake_tick)

sleep for current task for ticks

Parameters
[in]wake_ticktick count for sleep

◆ task_get_current_task()

task_t * task_get_current_task ( void  )

returns current task

Returns
current task

returns current task

this method is not required for efi however is required for linking.

Returns
NULL

◆ task_get_error_buffer()

buffer_t * task_get_error_buffer ( void  )

dummy method for efi for getting error buffer.

this method is not required for efi however is required for linking. NULL is returned.

Returns
NULL

◆ task_get_id()

uint64_t task_get_id ( void  )

returns current task's id

Returns
task id

returns current task's id

this method is not required for efi however is required for linking.

Returns
0

◆ task_get_input_buffer()

buffer_t * task_get_input_buffer ( void  )

dummy method for efi for getting input buffer.

this method is not required for efi however is required for linking. NULL is returned.

Returns
NULL

◆ task_get_output_buffer()

buffer_t * task_get_output_buffer ( void  )

dummy method for efi for getting output buffer.

this method is not required for efi however is required for linking. NULL is returned.

Returns
NULL

◆ task_init_tasking_ext()

int8_t task_init_tasking_ext ( memory_heap_t heap)

inits kernel tasking, configures tss and kernel task

Parameters
[in]heapthe heap of kernel task and tasking related variables.

◆ task_set_interrupt_received()

void task_set_interrupt_received ( uint64_t  task_id)

sets current task's interrupt received flag

Parameters
[in]task_idtask id

◆ task_task_switch_set_parameters()

void task_task_switch_set_parameters ( boolean_t  need_eoi,
boolean_t  need_sti 
)

sets task switch parameters

Parameters
[in]need_eoiif task switching needs notify local apic this field should be true
[in]need_stiif task switching needs enable interrupts this field should be true

◆ task_yield()

void task_yield ( void  )

yields task for waiting other tasks.

yields task for waiting other tasks.

this method is not required for efi however is required for linking.