📄 kapi.h
字号:
#ifndef CYGONCE_KERNEL_KAPI_H#define CYGONCE_KERNEL_KAPI_H/*==========================================================================//// kapi.h//// Native API for Kernel////==========================================================================//####COPYRIGHTBEGIN####//// -------------------------------------------// The contents of this file are subject to the Cygnus eCos Public License// Version 1.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://sourceware.cygnus.com/ecos// // Software distributed under the License is distributed on an "AS IS"// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the// License for the specific language governing rights and limitations under// the License.// // The Original Code is eCos - Embedded Cygnus Operating System, released// September 30, 1998.// // The Initial Developer of the Original Code is Cygnus. Portions created// by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved.// -------------------------------------------////####COPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): nickg, dsm// Contributors: nickg// Date: 1998-03-02// Purpose: Native API for Kernel// Description: This file describes the native API for using the kernel.// It is essentially a set of C wrappers for the C++ class// member functions.// Usage: #include <cyg/kernel/kapi.h>////####DESCRIPTIONEND####////========================================================================*/#include <pkgconf/kernel.h>#ifdef CYGFUN_KERNEL_API_C#include <cyg/infra/cyg_type.h>/*---------------------------------------------------------------------------*/#ifdef __cplusplusextern "C" {#endif/*---------------------------------------------------------------------------*//* The following are derived types, they may have different *//* definitions from these depending on configuration. */typedef CYG_ADDRWORD cyg_addrword_t; /* May hold pointer or word */typedef cyg_addrword_t cyg_handle_t; /* Object handle */typedef cyg_uint32 cyg_priority_t; /* type for priorities */typedef cyg_int32 cyg_code_t; /* type for various codes */typedef cyg_uint32 cyg_vector_t; /* Interrupt vector id */typedef cyg_uint64 cyg_tick_count_t;typedef int cyg_bool_t;/* Exception handler function definition */typedef void cyg_exception_handler_t( cyg_addrword_t data, cyg_code_t exception_number, cyg_addrword_t info);/*---------------------------------------------------------------------------*/struct cyg_thread;typedef struct cyg_thread cyg_thread;struct cyg_interrupt;typedef struct cyg_interrupt cyg_interrupt;struct cyg_counter;typedef struct cyg_counter cyg_counter;struct cyg_clock;typedef struct cyg_clock cyg_clock;struct cyg_alarm;typedef struct cyg_alarm cyg_alarm;struct cyg_mbox;typedef struct cyg_mbox cyg_mbox;struct cyg_mempool_var;typedef struct cyg_mempool_var cyg_mempool_var;struct cyg_mempool_fix;typedef struct cyg_mempool_fix cyg_mempool_fix;struct cyg_sem_t;typedef struct cyg_sem_t cyg_sem_t;struct cyg_flag_t;typedef struct cyg_flag_t cyg_flag_t;struct cyg_mutex_t;typedef struct cyg_mutex_t cyg_mutex_t;struct cyg_cond_t;typedef struct cyg_cond_t cyg_cond_t;/*---------------------------------------------------------------------------*//* Scheduler operations *//* Starts scheduler with created threads. Never returns. */void cyg_scheduler_start(void) __attribute__ ((noreturn));/* Lock and unlock the scheduler. When the scheduler is *//* locked thread preemption is disabled. */void cyg_scheduler_lock(void);void cyg_scheduler_unlock(void); /*---------------------------------------------------------------------------*//* Thread operations */typedef void cyg_thread_entry_t(cyg_addrword_t);void cyg_thread_create( cyg_addrword_t sched_info, /* scheduling info (eg pri) */ cyg_thread_entry_t *entry, /* entry point function */ cyg_addrword_t entry_data, /* entry data */ char *name, /* optional thread name */ void *stack_base, /* stack base, NULL = alloc */ cyg_ucount32 stack_size, /* stack size, 0 = default */ cyg_handle_t *handle, /* returned thread handle */ cyg_thread *thread /* put thread here */); void cyg_thread_exit(void);void cyg_thread_delete(cyg_handle_t thread);void cyg_thread_suspend(cyg_handle_t thread);void cyg_thread_resume(cyg_handle_t thread);void cyg_thread_kill(cyg_handle_t thread);void cyg_thread_release(cyg_handle_t thread); void cyg_thread_yield(void);cyg_handle_t cyg_thread_self(void);/* Priority manipulation */void cyg_thread_set_priority(cyg_handle_t thread, cyg_priority_t priority );cyg_priority_t cyg_thread_get_priority(cyg_handle_t thread); /* Deadline scheduling control (optional) */void cyg_thread_deadline_wait( cyg_tick_count_t start_time, /* abs earliest start time */ cyg_tick_count_t run_time, /* worst case execution time */ cyg_tick_count_t deadline /* absolute deadline */); void cyg_thread_delay(cyg_tick_count_t delay);/*---------------------------------------------------------------------------*//* Per-thread Data */#ifdef CYGVAR_KERNEL_THREADS_DATAcyg_ucount32 cyg_thread_new_data_index(void);void cyg_thread_free_data_index(cyg_ucount32 index);CYG_ADDRWORD cyg_thread_get_data(cyg_ucount32 index);CYG_ADDRWORD *cyg_thread_get_data_ptr(cyg_ucount32 index);void cyg_thread_set_data(cyg_ucount32 index, CYG_ADDRWORD data);#endif /*---------------------------------------------------------------------------*//* Exception handling. *//* Replace current exception handler, this may apply to either the *//* current thread, or to a global exception handler. The exception *//* number may be ignored, or used to specify a particular handler. */void cyg_exception_set_handler( cyg_code_t exception_number, cyg_exception_handler_t *new_handler, cyg_addrword_t new_data, cyg_exception_handler_t **old_handler, cyg_addrword_t *old_data);/* Clear exception hander to default value */void cyg_exception_clear_handler( cyg_code_t exception_number); /* Invoke exception handler */void cyg_exception_call_handler( cyg_handle_t thread, cyg_code_t exception_number, cyg_addrword_t exception_info);/*---------------------------------------------------------------------------*//* Interrupt handling */typedef void cyg_VSR_t(void);typedef cyg_uint32 cyg_ISR_t(cyg_vector_t vector, cyg_addrword_t data);typedef void cyg_DSR_t( cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data);enum cyg_ISR_results{ CYG_ISR_HANDLED = 1, /* Interrupt was handled */ CYG_ISR_CALL_DSR = 2 /* Schedule DSR */};void cyg_interrupt_create( cyg_vector_t vector, /* Vector to attach to */ cyg_priority_t priority, /* Queue priority */ cyg_addrword_t data, /* Data pointer */ cyg_ISR_t *isr, /* Interrupt Service Routine */ cyg_DSR_t *dsr, /* Deferred Service Routine */ cyg_handle_t *handle, /* returned handle */ cyg_interrupt *intr /* put interrupt here */);void cyg_interrupt_delete( cyg_handle_t interrupt );void cyg_interrupt_attach( cyg_handle_t interrupt );void cyg_interrupt_detach( cyg_handle_t interrupt ); /* VSR manipulation */void cyg_interrupt_get_vsr( cyg_vector_t vector, /* vector to get */ cyg_VSR_t **vsr /* vsr got */);void cyg_interrupt_set_vsr( cyg_vector_t vector, /* vector to set */ cyg_VSR_t *vsr /* vsr to set */);/* CPU level interrupt mask */void cyg_interrupt_disable(void);void cyg_interrupt_enable(void);/* Interrupt controller access */void cyg_interrupt_mask(cyg_vector_t vector);void cyg_interrupt_unmask(cyg_vector_t vector);void cyg_interrupt_acknowledge(cyg_vector_t vector);void cyg_interrupt_configure( cyg_vector_t vector, /* vector to configure */ cyg_bool_t level, /* level or edge triggered */ cyg_bool_t up /* rising/faling edge, high/low level*/);/*---------------------------------------------------------------------------*//* Counters, Clocks and Alarms */void cyg_counter_create( cyg_handle_t *handle, /* returned counter handle */ cyg_counter *counter /* put counter here */);void cyg_counter_delete(cyg_handle_t counter);/* Return current value of counter */cyg_tick_count_t cyg_counter_current_value(cyg_handle_t counter);/* Set new current value */void cyg_counter_set_value( cyg_handle_t counter, cyg_tick_count_t new_value);/* Advance counter by one tick */void cyg_counter_tick(cyg_handle_t counter);typedef struct { cyg_uint32 dividend; cyg_uint32 divisor;} cyg_resolution_t;/* Create a clock object */void cyg_clock_create( cyg_resolution_t resolution, /* Initial resolution */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -