huangcm
2025-09-01 53d8e046ac1bf2ebe94f671983e3d3be059df91a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
*********************************************************************************************************
*                                                AR100 SYSTEM
*                                     AR100 Software System Develop Kits
*
*
*                                    (c) Copyright 2018-2024, Luojie China
*                                             All Rights Reserved
*
* File    : msgmanager.h
* By      : LuoJie
* Version : v1.0
* Date    : 2018-06-05 16:34
* Descript: .
* Update  :auther      ver     notes
*          Luojie      1.0     Create this file.
*********************************************************************************************************
*/
#ifndef __MSGMANAGER_H__
#define __MSGMANAGER_H__
 
#include "ibase.h"
#include "list.h"
#include "hwmsgbox.h"
 
#define MSGBLOCK_SIZE 11
 
#define MSGPOOL_START   0x419f8000
#define MSGPOOL_END     0x419f8900
#define MSGID_TABLE     0x419f8900
#define MSGID_END       0x419f9000
 
#define MSG_STATE_ALLOCKED    0x10
#define MSG_STATE_SENDING    0x11
#define MSG_STATE_RECEIVED    0x13
#define MSG_STATE_RESOLVE    0x14
#define MSG_STATE_RESOLVE_FINISH    0x15
#define MSG_STATE_FEEDBACK        0x16
#define MSG_STATE_STORAGE        0x17
#define MSG_STATE_FREE        0x18
 
#define MESSAGE_ATTR_ASYN        0
#define MESSAGE_ATTR_SYN        1
#define MESSAGE_ATTR_QUERY        2
 
#define MSGID_TABLE_COUNT    8
#define MSGID_SYN        99
#define MSGID_ASYN        0
 
#define RET_ATTR_ASYN        0x1000
#define RET_ATTR_SYN        0x1000
#define RET_ATTR_QUERY        0x2000
 
struct msgblock {
   struct list_head list;
   u32 paras[MSGBLOCK_SIZE];
};
 
typedef union {
   u32 word;
   struct {
       u8 result;
       u8 type;
       u8 attr;
       u8 state;
   }bytes;
}msg_status_t;
 
struct msgblock_head {
   struct list_head list;
   struct list_head wait_list;
   u32    state;
   u32    type;
   u32    attr;
   u32    result;
//    msg_status_t    status;
   u32    length;
   s32    msgid;
   s32    ref;
};
 
#define _ALIGN(addr,size)    (((addr)+((size)-1))/size)
#define BLOB_ALIGN(len)    _ALIGN(len, MSGBLOCK_SIZE * 4)
 
int msgmanager_init(void);
s32 get_free_msgid(void);
s32 free_msgid(s32 msgid);
struct msgblock_head *allock_msg(u32 block_num);
s32 free_msg(struct msgblock_head *head);
s32 resolve_msg(u32 msgaddr);
s32 resolve_feedback(u32 msgaddr);
void get_paras_form_msg(struct list_head *head, void **para,u32 len);
void set_paras_to_msg(struct list_head *head, void *para,u32 len);
u32 get_block_length_from_paras(u32 paras_size);
 
msgbox_device *request_msgbox(void);
 
#endif