1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-17 18:43:50 +01:00

changed msg to msg_t

This commit is contained in:
Stephan Zeisberg 2011-03-08 10:54:40 +01:00
parent d96783a66e
commit 6a96de0d2f
22 changed files with 55 additions and 55 deletions

View File

@ -35,7 +35,7 @@ typedef struct msg {
char *ptr; ///< pointer content field char *ptr; ///< pointer content field
uint32_t value; ///< value content field uint32_t value; ///< value content field
} content; } content;
} msg; } msg_t;
/** /**
@ -54,7 +54,7 @@ typedef struct msg {
* @return 0 if receiver is not waiting and block == false * @return 0 if receiver is not waiting and block == false
* @return -1 on error (invalid PID) * @return -1 on error (invalid PID)
*/ */
int msg_send(msg* m, unsigned int target_pid, bool block); int msg_send(msg_t* m, unsigned int target_pid, bool block);
/** /**
@ -68,7 +68,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block);
* @return 1 if sending was successfull * @return 1 if sending was successfull
* @return 0 if receiver is not waiting and block == false * @return 0 if receiver is not waiting and block == false
*/ */
int msg_send_int(msg* m, unsigned int target_pid); int msg_send_int(msg_t* m, unsigned int target_pid);
/** /**
@ -79,7 +79,7 @@ int msg_send_int(msg* m, unsigned int target_pid);
* *
* @return 1 Function always succeeds or blocks forever. * @return 1 Function always succeeds or blocks forever.
*/ */
int msg_receive(msg* m); int msg_receive(msg_t* m);
/** /**
* @brief Send a message, block until reply received. * @brief Send a message, block until reply received.
@ -90,7 +90,7 @@ int msg_receive(msg* m);
* @param target pid the pid of the target process * @param target pid the pid of the target process
* @return 1 if successful * @return 1 if successful
*/ */
int msg_send_receive(msg *m, msg *reply, unsigned int target_pid); int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid);
/** /**
* @brief Replies to a message. * @brief Replies to a message.
@ -103,7 +103,7 @@ int msg_send_receive(msg *m, msg *reply, unsigned int target_pid);
* @return 1 if succcessful * @return 1 if succcessful
* qreturn 0 on error * qreturn 0 on error
*/ */
int msg_reply(msg *m, msg *reply); int msg_reply(msg_t *m, msg_t *reply);
/** /**
* @brief Initialize the current thread's message queue. * @brief Initialize the current thread's message queue.
@ -111,7 +111,7 @@ int msg_reply(msg *m, msg *reply);
* @param array Pointer to preallocated array of msg objects * @param array Pointer to preallocated array of msg objects
* @param num Number of msg objects in array. MUST BE POWER OF TWO! * @param num Number of msg objects in array. MUST BE POWER OF TWO!
*/ */
int msg_init_queue(msg* array, int num); int msg_init_queue(msg_t* array, int num);
/** @} */ /** @} */
#endif /* __MSG_H */ #endif /* __MSG_H */

View File

@ -48,7 +48,7 @@ typedef struct tcb {
queue_node_t msg_waiters; queue_node_t msg_waiters;
cib_t msg_queue; cib_t msg_queue;
msg* msg_array; msg_t* msg_array;
const char* name; const char* name;
char* stack_start; char* stack_start;

View File

@ -27,7 +27,7 @@
//#define ENABLE_DEBUG //#define ENABLE_DEBUG
#include "debug.h" #include "debug.h"
static int queue_msg(tcb *target, msg *m) { static int queue_msg(tcb *target, msg_t *m) {
int n = cib_put(&(target->msg_queue)); int n = cib_put(&(target->msg_queue));
if (n != -1) { if (n != -1) {
@ -38,7 +38,7 @@ static int queue_msg(tcb *target, msg *m) {
return 0; return 0;
} }
int msg_send(msg* m, unsigned int target_pid, bool block) { int msg_send(msg_t* m, unsigned int target_pid, bool block) {
if (inISR()) { if (inISR()) {
return msg_send_int(m, target_pid); return msg_send_int(m, target_pid);
} }
@ -90,7 +90,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
} else { } else {
DEBUG("%s: direct msg copy.\n", active_thread->name); DEBUG("%s: direct msg copy.\n", active_thread->name);
/* copy msg to target */ /* copy msg to target */
msg* target_message = (msg*)target->wait_data; msg_t* target_message = (msg_t*)target->wait_data;
*target_message = *m; *target_message = *m;
sched_set_status(target, STATUS_PENDING); sched_set_status(target, STATUS_PENDING);
} }
@ -101,7 +101,7 @@ int msg_send(msg* m, unsigned int target_pid, bool block) {
return 1; return 1;
} }
int msg_send_int(msg* m, unsigned int target_pid) { int msg_send_int(msg_t* m, unsigned int target_pid) {
tcb *target = (tcb*)sched_threads[target_pid]; tcb *target = (tcb*)sched_threads[target_pid];
if (target->status == STATUS_RECEIVE_BLOCKED) { if (target->status == STATUS_RECEIVE_BLOCKED) {
@ -110,7 +110,7 @@ int msg_send_int(msg* m, unsigned int target_pid) {
m->sender_pid = target_pid; m->sender_pid = target_pid;
/* copy msg to target */ /* copy msg to target */
msg* target_message = (msg*)target->wait_data; msg_t* target_message = (msg_t*)target->wait_data;
*target_message = *m; *target_message = *m;
sched_set_status(target, STATUS_PENDING); sched_set_status(target, STATUS_PENDING);
@ -122,7 +122,7 @@ int msg_send_int(msg* m, unsigned int target_pid) {
} }
} }
int msg_send_receive(msg *m, msg *reply, unsigned int target_pid) { int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid) {
dINT(); dINT();
tcb *me = (tcb*) sched_threads[thread_pid]; tcb *me = (tcb*) sched_threads[thread_pid];
sched_set_status(me, STATUS_REPLY_BLOCKED); sched_set_status(me, STATUS_REPLY_BLOCKED);
@ -134,7 +134,7 @@ int msg_send_receive(msg *m, msg *reply, unsigned int target_pid) {
return 1; return 1;
} }
int msg_reply(msg *m, msg *reply) { int msg_reply(msg_t *m, msg_t *reply) {
int state = disableIRQ(); int state = disableIRQ();
tcb *target = (tcb*)sched_threads[m->sender_pid]; tcb *target = (tcb*)sched_threads[m->sender_pid];
@ -146,7 +146,7 @@ int msg_reply(msg *m, msg *reply) {
DEBUG("%s: msg_reply(): direct msg copy.\n", active_thread->name); DEBUG("%s: msg_reply(): direct msg copy.\n", active_thread->name);
/* copy msg to target */ /* copy msg to target */
msg* target_message = (msg*)target->wait_data; msg_t* target_message = (msg_t*)target->wait_data;
*target_message = *reply; *target_message = *reply;
sched_set_status(target, STATUS_PENDING); sched_set_status(target, STATUS_PENDING);
restoreIRQ(state); restoreIRQ(state);
@ -155,20 +155,20 @@ int msg_reply(msg *m, msg *reply) {
return 1; return 1;
} }
int msg_reply_int(msg *m, msg *reply) { int msg_reply_int(msg_t *m, msg_t *reply) {
tcb *target = (tcb*)sched_threads[m->sender_pid]; tcb *target = (tcb*)sched_threads[m->sender_pid];
if (target->status != STATUS_REPLY_BLOCKED) { if (target->status != STATUS_REPLY_BLOCKED) {
DEBUG("%s: msg_reply_int(): target \"%s\" not waiting for reply.", active_thread->name, target->name); DEBUG("%s: msg_reply_int(): target \"%s\" not waiting for reply.", active_thread->name, target->name);
return -1; return -1;
} }
msg* target_message = (msg*)target->wait_data; msg_t* target_message = (msg_t*)target->wait_data;
*target_message = *reply; *target_message = *reply;
sched_set_status(target, STATUS_PENDING); sched_set_status(target, STATUS_PENDING);
sched_context_switch_request = 1; sched_context_switch_request = 1;
return 1; return 1;
} }
int msg_receive(msg* m) { int msg_receive(msg_t* m) {
dINT(); dINT();
DEBUG("%s: msg_receive.\n", active_thread->name); DEBUG("%s: msg_receive.\n", active_thread->name);
@ -212,7 +212,7 @@ int msg_receive(msg* m) {
} }
/* copy msg */ /* copy msg */
msg* sender_msg = (msg*)sender->wait_data; msg_t* sender_msg = (msg_t*)sender->wait_data;
*m = *sender_msg; *m = *sender_msg;
/* remove sender from queue */ /* remove sender from queue */
@ -224,7 +224,7 @@ int msg_receive(msg* m) {
} }
} }
int msg_init_queue(msg* array, int num) { int msg_init_queue(msg_t* array, int num) {
/* make sure brainfuck condition is met */ /* make sure brainfuck condition is met */
if (num && (num & (num - 1)) == 0) { if (num && (num & (num - 1)) == 0) {
tcb *me = (tcb*)active_thread; tcb *me = (tcb*)active_thread;

View File

@ -187,7 +187,7 @@ interrupt(RTC_VECTOR) __attribute__ ((naked)) rtc_isr(void) {
RTCYEARH = (time_to_set.tm_year + 1900) >> 0x08; RTCYEARH = (time_to_set.tm_year + 1900) >> 0x08;
} }
if (rtc_second_pid) { if (rtc_second_pid) {
msg m; msg_t m;
m.type = RTC_SECOND; m.type = RTC_SECOND;
msg_send_int(&m, rtc_second_pid); msg_send_int(&m, rtc_second_pid);
} }

View File

@ -624,7 +624,7 @@ int cc1100_set_packet_handler(protocol_t protocol, packet_handler_t handler)
static void cc1100_event_handler_function(void) static void cc1100_event_handler_function(void)
{ {
msg m; msg_t m;
while (1) while (1)
{ {
if (cc1100_watch_dog_period != 0) { if (cc1100_watch_dog_period != 0) {
@ -685,7 +685,7 @@ static void cc1100_event_handler_function(void)
void cc1100_phy_rx_handler(void) void cc1100_phy_rx_handler(void)
{ {
msg m; msg_t m;
m.type = MSG_POLL; m.type = MSG_POLL;
bool dup = false; bool dup = false;
bool res = false; bool res = false;

View File

@ -51,7 +51,7 @@ void cc110x_rx_handler(void) {
/* notify transceiver thread if any */ /* notify transceiver thread if any */
if (transceiver_pid) { if (transceiver_pid) {
msg m; msg_t m;
m.type = (uint16_t) RCV_PKT_CC1100; m.type = (uint16_t) RCV_PKT_CC1100;
m.content.value = rx_buffer_next; m.content.value = rx_buffer_next;
msg_send_int(&m, transceiver_pid); msg_send_int(&m, transceiver_pid);

View File

@ -22,9 +22,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
uint8_t snd_buffer[SEND_SIZE]; uint8_t snd_buffer[SEND_SIZE];
msg msg_q[RCV_BUFFER_SIZE]; msg_t msg_q[RCV_BUFFER_SIZE];
static msg mesg; static msg_t mesg;
static transceiver_command_t tcmd; static transceiver_command_t tcmd;
static radio_packet_t p; static radio_packet_t p;
@ -48,7 +48,7 @@ void send(radio_address_t dst, uint8_t len, uint8_t *data) {
void radio(void) { void radio(void) {
msg m; msg_t m;
radio_packet_t *p; radio_packet_t *p;
msg_init_queue(msg_q, RCV_BUFFER_SIZE); msg_init_queue(msg_q, RCV_BUFFER_SIZE);

View File

@ -27,9 +27,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
uint8_t snd_buffer[SEND_SIZE]; uint8_t snd_buffer[SEND_SIZE];
msg msg_q[RCV_BUFFER_SIZE]; msg_t msg_q[RCV_BUFFER_SIZE];
static msg mesg; static msg_t mesg;
static transceiver_command_t tcmd; static transceiver_command_t tcmd;
static radio_packet_t p; static radio_packet_t p;
@ -52,7 +52,7 @@ void send(radio_address_t dst, uint8_t len, uint8_t *data) {
} }
void radio(void) { void radio(void) {
msg m; msg_t m;
radio_packet_t *p; radio_packet_t *p;
msg_init_queue(msg_q, RCV_BUFFER_SIZE); msg_init_queue(msg_q, RCV_BUFFER_SIZE);

View File

@ -25,9 +25,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH]; uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH];
msg msg_q[RCV_BUFFER_SIZE]; msg_t msg_q[RCV_BUFFER_SIZE];
static msg mesg; static msg_t mesg;
static transceiver_command_t tcmd; static transceiver_command_t tcmd;
static radio_packet_t p; static radio_packet_t p;
@ -98,7 +98,7 @@ void print_buffer(char *unused) {
} }
void radio(void) { void radio(void) {
msg m; msg_t m;
radio_packet_t *p; radio_packet_t *p;
uint8_t i; uint8_t i;

View File

@ -5,7 +5,7 @@
void second_thread(void) { void second_thread(void) {
printf("second_thread starting.\n"); printf("second_thread starting.\n");
msg m; msg_t m;
while(1) { while(1) {
msg_receive(&m); msg_receive(&m);
@ -21,7 +21,7 @@ int main(void)
{ {
printf("Hello world!\n"); printf("Hello world!\n");
msg m; msg_t m;
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong"); int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");

View File

@ -5,7 +5,7 @@
void second_thread(void) { void second_thread(void) {
printf("second_thread starting.\n"); printf("second_thread starting.\n");
msg m; msg_t m;
int i = 1; int i = 1;
while(1) { while(1) {
msg_receive(&m); msg_receive(&m);
@ -21,7 +21,7 @@ int main(void)
{ {
printf("Hello world!\n"); printf("Hello world!\n");
msg m; msg_t m;
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong"); int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");

View File

@ -25,9 +25,9 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH]; uint8_t snd_buffer[SND_BUFFER_SIZE][CC1100_MAX_DATA_LENGTH];
msg msg_q[RCV_BUFFER_SIZE]; msg_t msg_q[RCV_BUFFER_SIZE];
static msg mesg; static msg_t mesg;
static transceiver_command_t tcmd; static transceiver_command_t tcmd;
static radio_packet_t p; static radio_packet_t p;
@ -121,7 +121,7 @@ void set_delay(char *delay) {
} }
void radio(void) { void radio(void) {
msg m; msg_t m;
radio_packet_t *p; radio_packet_t *p;
uint8_t i; uint8_t i;

View File

@ -14,7 +14,7 @@ void wakeup_thread(void){
} }
void msg_thread(void){ void msg_thread(void){
msg m; msg_t m;
msg_receive(&m); msg_receive(&m);
printf("%s\n",(char*)m.content.ptr); printf("%s\n",(char*)m.content.ptr);
} }

View File

@ -13,7 +13,7 @@
static char alarm_stack[KERNEL_CONF_STACKSIZE_DEFAULT]; static char alarm_stack[KERNEL_CONF_STACKSIZE_DEFAULT];
static void alarm_thread(void) { static void alarm_thread(void) {
msg m; msg_t m;
struct tm time; struct tm time;

View File

@ -15,7 +15,7 @@ void time_print(struct tm *time) {
static char clock_stack[KERNEL_CONF_STACKSIZE_DEFAULT]; static char clock_stack[KERNEL_CONF_STACKSIZE_DEFAULT];
static void clock_thread(void) { static void clock_thread(void) {
msg m; msg_t m;
int active = 0; int active = 0;
rtc_second_pid = thread_getpid(); rtc_second_pid = thread_getpid();

View File

@ -21,7 +21,7 @@ int apps[NUM_APPS];
int button_thread = 0; int button_thread = 0;
void button_star(void) { void button_star(void) {
msg m; msg_t m;
if (button_thread) { if (button_thread) {
m.type = MSG_BUTTON_STAR; m.type = MSG_BUTTON_STAR;
@ -40,7 +40,7 @@ int main(void)
int active_app = 0; int active_app = 0;
msg m; msg_t m;
//buzzer_beep(15, 5000); //buzzer_beep(15, 5000);

View File

@ -17,7 +17,7 @@ static int min(int a, int b) {
} }
void chardev_loop(ringbuffer *rb) { void chardev_loop(ringbuffer *rb) {
msg m; msg_t m;
int pid = thread_getpid(); int pid = thread_getpid();

View File

@ -4,7 +4,7 @@
static int _posix_fileop(int pid, int op, int flags) { static int _posix_fileop(int pid, int op, int flags) {
msg m; msg_t m;
m.type = op; m.type = op;
m.content.value = flags; m.content.value = flags;
msg_send_receive(&m, &m, pid); msg_send_receive(&m, &m, pid);
@ -16,7 +16,7 @@ static int _posix_fileop_data(int pid, int op, char* buffer, int nbytes) {
r.nbytes = nbytes; r.nbytes = nbytes;
r.buffer = buffer; r.buffer = buffer;
msg m; msg_t m;
m.type = op; m.type = op;
m.content.ptr = (char*) &r; m.content.ptr = (char*) &r;

View File

@ -8,7 +8,7 @@
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH #define TEXT_SIZE CC1100_MAX_DATA_LENGTH
char text_msg[TEXT_SIZE]; char text_msg[TEXT_SIZE];
msg mesg; msg_t mesg;
transceiver_command_t tcmd; transceiver_command_t tcmd;
void _cc110x_ng_get_set_address_handler(char *addr) { void _cc110x_ng_get_set_address_handler(char *addr) {

View File

@ -235,7 +235,7 @@ static void swtimer_action(swtimer_t *swtimer) {
} }
case SWTIMER_MSG: case SWTIMER_MSG:
{ {
msg m; msg_t m;
m.content.value = swtimer->action.msg.value; m.content.value = swtimer->action.msg.value;
int result = msg_send_int(&m, swtimer->action.msg.target_pid); int result = msg_send_int(&m, swtimer->action.msg.target_pid);
if (result < 0) { if (result < 0) {

View File

@ -34,7 +34,7 @@ radio_packet_t transceiver_buffer[TRANSCEIVER_BUFFER_SIZE];
uint8_t data_buffer[TRANSCEIVER_BUFFER_SIZE * PAYLOAD_SIZE]; uint8_t data_buffer[TRANSCEIVER_BUFFER_SIZE * PAYLOAD_SIZE];
/* message buffer */ /* message buffer */
msg msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE]; msg_t msg_buffer[TRANSCEIVER_MSG_BUFFER_SIZE];
uint32_t response; ///< response bytes for messages to upper layer threads uint32_t response; ///< response bytes for messages to upper layer threads
@ -116,7 +116,7 @@ uint8_t transceiver_register(transceiver_type_t t, int pid) {
* loop * loop
*/ */
void run(void) { void run(void) {
msg m; msg_t m;
transceiver_command_t *cmd; transceiver_command_t *cmd;
msg_init_queue(msg_buffer, TRANSCEIVER_MSG_BUFFER_SIZE); msg_init_queue(msg_buffer, TRANSCEIVER_MSG_BUFFER_SIZE);
@ -180,7 +180,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
uint8_t i = 0; uint8_t i = 0;
transceiver_type_t t; transceiver_type_t t;
rx_buffer_pos = pos; rx_buffer_pos = pos;
msg m; msg_t m;
DEBUG("Packet received\n"); DEBUG("Packet received\n");
switch (type) { switch (type) {

View File

@ -33,7 +33,7 @@ void uart0_handle_incoming(int c) {
} }
void uart0_notify_thread(void) { void uart0_notify_thread(void) {
msg m; msg_t m;
m.type = 0; m.type = 0;
msg_send_int(&m, uart0_handler_pid); msg_send_int(&m, uart0_handler_pid);
} }