⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailbox.h

📁 Bycore是一个嵌入式操作系统内核。Bycore包括内存管理、任务管理、中断管理、任务互斥、同步与通信管理等功能。Bycore全部由C语言完成
💻 H
字号:
/** *  mailbox.h - Related routines and structs of mailbox. * *  Copyright (C) 2008  ZhangHu *  All rights reserved. *  E-MAIL: anmnmnly@gmail.com * *  This program is free software: you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation, either version 3 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program.  If not, see <http://www.gnu.org/licenses/>. */#ifndef __MAILBOX_H__#define __MAILBOX_H__#include "include/types.h"#define MAILBOX_OK 0x00             /* Operation is ok */#define MAILBOX_NOT_EXIST 0x01      /* Mailbox does not existence */#define MAILBOX_NOT_FOUND_MSG 0x02  /* It does not find message */#define MAILBOX_FULL 0x04           /* mailbox is full*/#define MAILBOX_EMPTY 0x08          /* mailbox is emptyt *//* struct message - It describes the style of message */typedef struct message {    uword_t key_id;     /* Message ID that identify a message */    uword_t send_id;    /* ID of sending task */    uword_t rev_id;     /* ID of receiving task */    void *pmsg;         /* Pointer to the address of message */} msg_t;/* mailbox - It is prototype of mailbox */typedef struct mailbox {    uword_t size;       /* The size of mailbox */    uword_t used;       /* The number of used space of mailbox */    msg_t *start;       /* Pointer to the start address of mailbox */    msg_t *end;         /* Pointer to the end address of mailbox */    msg_t *pos;         /* current write-read postion of mailbox */} mail_t;/* Created a new mailbox */mail_t *mboxInit(uword_t Size);/* Sending a message to a mailbox */uword_t mboxSend(mail_t *pMail,/* Pointer to the mailbox. */                 uword_t Key,  /* Serial number of message. */                 uword_t RevID,/* ID of Receiving task. */                 void *pMsg,   /* Pointer to the message. */                 uword_t *err);/* return reasons about 'mboxSend' *//* Retrieve message from mailbox */void *mboxRev(mail_t *pMail,   /* Pointer to the mailbox. */              uword_t Key,     /* Serial number of message. */              uword_t SendID,  /* ID of sending task. */              uword_t *err);   /* return reasons about 'mboxSend' *//* Clear a mailbox */void mboxClear(mail_t *pMail);/* Delete a mailbox */void mboxDel(mail_t *pMail);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -