Remove mail IPC subsystsem
This commit is contained in:
12
etc/doc.txt
12
etc/doc.txt
@@ -75,20 +75,12 @@ OPTIONS:
|
|||||||
This app polls the USB controller device for bus events. For many controllers,
|
This app polls the USB controller device for bus events. For many controllers,
|
||||||
many instances of "usb" should be spawned.
|
many instances of "usb" should be spawned.
|
||||||
|
|
||||||
2.6 mailtest (mail subsystem testing app)
|
2.6 devices (device management utility)
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-r -recv (start in receiver mode; will print data to the debug console)
|
|
||||||
-s -send (run in sender mode)
|
|
||||||
-p -payload [string] (give payload when ran as a sender)
|
|
||||||
-pg -procgroup [int] (target process group)
|
|
||||||
|
|
||||||
2.7 devices (device management utility)
|
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-la -list-all (List all devices available to the system)
|
-la -list-all (List all devices available to the system)
|
||||||
|
|
||||||
2.8 volumes (volume managemnt utility)
|
2.7 volumes (volume managemnt utility)
|
||||||
-e -eject (Eject / remove a volume based on device key)
|
-e -eject (Eject / remove a volume based on device key)
|
||||||
-d -device [key] (Device key)
|
-d -device [key] (Device key)
|
||||||
-l -list (List all volumes)
|
-l -list (List all volumes)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef _STREAMS_H
|
#ifndef _STREAMS_H
|
||||||
#define _STREAMS_H
|
#define _STREAMS_H
|
||||||
|
|
||||||
#define STREAM_IN 1
|
#define STREAM_IN 0
|
||||||
#define STREAM_OUT 2
|
#define STREAM_OUT 1
|
||||||
|
|
||||||
#endif // _STREAMS_H
|
#endif // _STREAMS_H
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
#define SYS_VOLUME_CLOSE 15
|
#define SYS_VOLUME_CLOSE 15
|
||||||
#define SYS_READ_FILE 16
|
#define SYS_READ_FILE 16
|
||||||
#define SYS_DESCRIBE 17
|
#define SYS_DESCRIBE 17
|
||||||
#define SYS_MAIL_SEND 18
|
|
||||||
#define SYS_MAIL_RECEIVE 19
|
|
||||||
#define SYS_GET_PROCGROUP 20
|
#define SYS_GET_PROCGROUP 20
|
||||||
#define SYS_GET_EXEC_PID 21
|
#define SYS_GET_EXEC_PID 21
|
||||||
#define SYS_READ_DIR_ENTRY 22
|
#define SYS_READ_DIR_ENTRY 22
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
#include <libk/list.h>
|
|
||||||
#include <libk/minmax.h>
|
|
||||||
#include <libk/std.h>
|
|
||||||
#include <libk/string.h>
|
|
||||||
#include <mm/malloc.h>
|
|
||||||
#include <proc/mail.h>
|
|
||||||
#include <proc/proc.h>
|
|
||||||
#include <proc/resource.h>
|
|
||||||
#include <proc/suspension_q.h>
|
|
||||||
#include <sys/debug.h>
|
|
||||||
#include <sys/smp.h>
|
|
||||||
|
|
||||||
static void proc_mail_free_saved_buffer(void* udata) { free(udata); }
|
|
||||||
|
|
||||||
void proc_cleanup_resource_mail(struct proc_resource* resource, struct reschedule_ctx* rctx) {
|
|
||||||
struct proc_mail* mail = &resource->u.mail;
|
|
||||||
|
|
||||||
while (mail->send_sq.proc_list != NULL) {
|
|
||||||
struct list_node_link* node = mail->send_sq.proc_list;
|
|
||||||
struct proc_sq_entry* sq_entry = list_entry(node, struct proc_sq_entry, sq_link);
|
|
||||||
struct proc* suspended_proc = sq_entry->proc;
|
|
||||||
|
|
||||||
proc_sq_resume(suspended_proc, sq_entry, rctx, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void proc_mail_send(struct proc* proc, struct proc_mail* mail, struct reschedule_ctx* rctx,
|
|
||||||
void* data, size_t data_size) {
|
|
||||||
/* mail full */
|
|
||||||
if (mail->packets_count == PROC_MAIL_MAX) {
|
|
||||||
struct mail_saved_buffer* saved_buffer = malloc(sizeof(*saved_buffer));
|
|
||||||
saved_buffer->buffer = data;
|
|
||||||
saved_buffer->size = data_size;
|
|
||||||
|
|
||||||
proc_sq_suspend(proc, &mail->send_sq, rctx, saved_buffer, &proc_mail_free_saved_buffer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if receiver available, hand off directly */
|
|
||||||
struct list_node_link* node = mail->recv_sq.proc_list;
|
|
||||||
|
|
||||||
if (node != NULL) {
|
|
||||||
struct proc_sq_entry* sq_entry = list_entry(node, struct proc_sq_entry, sq_link);
|
|
||||||
struct proc* resumed_proc = sq_entry->proc;
|
|
||||||
|
|
||||||
struct mail_saved_buffer* saved_buffer = sq_entry->udata;
|
|
||||||
|
|
||||||
size_t copy_size = min(data_size, saved_buffer->size);
|
|
||||||
memcpy(saved_buffer->buffer, data, copy_size);
|
|
||||||
|
|
||||||
proc_sq_resume(resumed_proc, sq_entry, rctx, copy_size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mail is empty and nobody is waiting */
|
|
||||||
void* mesg = malloc(data_size);
|
|
||||||
if (mesg != NULL) {
|
|
||||||
memcpy(mesg, data, data_size);
|
|
||||||
|
|
||||||
struct mail_packet* packet = malloc(sizeof(*packet));
|
|
||||||
|
|
||||||
if (packet == NULL) {
|
|
||||||
free(mesg);
|
|
||||||
} else {
|
|
||||||
memset(packet, 0, sizeof(*packet));
|
|
||||||
packet->packet_buffer = mesg;
|
|
||||||
packet->packet_size = data_size;
|
|
||||||
|
|
||||||
list_append(mail->packets, &packet->packets_link);
|
|
||||||
mail->packets_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void proc_mail_receive(struct proc* proc, struct proc_mail* mail, struct reschedule_ctx* rctx,
|
|
||||||
void* recv_buffer, size_t recv_size) {
|
|
||||||
/* consume mesg if available */
|
|
||||||
if (mail->packets_count > 0) {
|
|
||||||
struct mail_packet* packet = list_entry(mail->packets, struct mail_packet, packets_link);
|
|
||||||
list_remove(mail->packets, &packet->packets_link);
|
|
||||||
mail->packets_count--;
|
|
||||||
|
|
||||||
size_t copy_size = min(recv_size, packet->packet_size);
|
|
||||||
memcpy(recv_buffer, packet->packet_buffer, copy_size);
|
|
||||||
free(packet->packet_buffer);
|
|
||||||
free(packet);
|
|
||||||
|
|
||||||
struct list_node_link* node = mail->send_sq.proc_list;
|
|
||||||
|
|
||||||
if (node != NULL) {
|
|
||||||
struct proc_sq_entry* sq_entry = list_entry(node, struct proc_sq_entry, sq_link);
|
|
||||||
struct proc* resumed_proc = sq_entry->proc;
|
|
||||||
|
|
||||||
proc_sq_resume(resumed_proc, sq_entry, rctx, copy_size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct mail_saved_buffer* saved_buffer = malloc(sizeof(*saved_buffer));
|
|
||||||
saved_buffer->buffer = recv_buffer;
|
|
||||||
saved_buffer->size = recv_size;
|
|
||||||
|
|
||||||
/* nothing to receive */
|
|
||||||
proc_sq_suspend(proc, &mail->recv_sq, rctx, saved_buffer, &proc_mail_free_saved_buffer);
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#ifndef _KERNEL_PROC_MAIL_H
|
|
||||||
#define _KERNEL_PROC_MAIL_H
|
|
||||||
|
|
||||||
#include <libk/list.h>
|
|
||||||
#include <libk/ringbuffer.h>
|
|
||||||
#include <libk/std.h>
|
|
||||||
#include <proc/suspension_q.h>
|
|
||||||
|
|
||||||
#define PROC_MAIL_MAX 1024
|
|
||||||
|
|
||||||
struct proc;
|
|
||||||
struct proc_resource;
|
|
||||||
struct cpu;
|
|
||||||
struct reschedule_ctx;
|
|
||||||
|
|
||||||
struct mail_saved_buffer {
|
|
||||||
void* buffer;
|
|
||||||
size_t size;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mail_packet {
|
|
||||||
void* packet_buffer;
|
|
||||||
size_t packet_size;
|
|
||||||
struct list_node_link packets_link;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct proc_mail {
|
|
||||||
struct proc_resource* resource;
|
|
||||||
|
|
||||||
struct proc_suspension_q send_sq;
|
|
||||||
struct proc_suspension_q recv_sq;
|
|
||||||
|
|
||||||
struct list_node_link* packets;
|
|
||||||
size_t packets_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
void proc_cleanup_resource_mail(struct proc_resource* resource, struct reschedule_ctx* rctx);
|
|
||||||
|
|
||||||
void proc_mail_send(struct proc* proc, struct proc_mail* mail, struct reschedule_ctx* rctx,
|
|
||||||
void* data, size_t data_size);
|
|
||||||
|
|
||||||
void proc_mail_receive(struct proc* proc, struct proc_mail* mail, struct reschedule_ctx* rctx,
|
|
||||||
void* recv_buffer, size_t recv_size);
|
|
||||||
|
|
||||||
#endif // _KERNEL_PROC_MAIL_H
|
|
||||||
@@ -162,12 +162,6 @@ struct procgroup* procgroup_create(void) {
|
|||||||
MM_PG_PRESENT | MM_PG_USER, &procgroup->paddr_cmdline);
|
MM_PG_PRESENT | MM_PG_USER, &procgroup->paddr_cmdline);
|
||||||
memset((void*)((uintptr_t)hhdm->offset + procgroup->paddr_cmdline), 0, PROCGROUP_CMDLINE_MAX);
|
memset((void*)((uintptr_t)hhdm->offset + procgroup->paddr_cmdline), 0, PROCGROUP_CMDLINE_MAX);
|
||||||
|
|
||||||
if (proc_create_resource_mail(procgroup) == NULL) {
|
|
||||||
id_alloc_fini(&procgroup->rid_alloc);
|
|
||||||
free(procgroup);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proc_create_resource_stream(procgroup) == NULL) {
|
if (proc_create_resource_stream(procgroup) == NULL) {
|
||||||
id_alloc_fini(&procgroup->rid_alloc);
|
id_alloc_fini(&procgroup->rid_alloc);
|
||||||
free(procgroup);
|
free(procgroup);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <libk/string.h>
|
#include <libk/string.h>
|
||||||
#include <mm/malloc.h>
|
#include <mm/malloc.h>
|
||||||
#include <mm/pmm.h>
|
#include <mm/pmm.h>
|
||||||
#include <proc/mail.h>
|
|
||||||
#include <proc/mutex.h>
|
#include <proc/mutex.h>
|
||||||
#include <proc/proc.h>
|
#include <proc/proc.h>
|
||||||
#include <proc/procgroup.h>
|
#include <proc/procgroup.h>
|
||||||
@@ -51,32 +50,6 @@ struct proc_resource* proc_create_resource_mutex(struct procgroup* procgroup) {
|
|||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct proc_resource* proc_create_resource_mail(struct procgroup* procgroup) {
|
|
||||||
struct proc_resource* resource;
|
|
||||||
|
|
||||||
resource = malloc(sizeof(*resource));
|
|
||||||
if (resource == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
memset(resource, 0, sizeof(*resource));
|
|
||||||
|
|
||||||
resource->rid = id_alloc(&procgroup->rid_alloc);
|
|
||||||
|
|
||||||
if (resource->rid < 0) {
|
|
||||||
free(resource);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
resource->ops.cleanup = &proc_cleanup_resource_mail;
|
|
||||||
resource->u.mail.resource = resource;
|
|
||||||
resource->type = PR_MAIL;
|
|
||||||
|
|
||||||
rbtree_insert(struct proc_resource, &procgroup->resource_tree, &resource->resource_tree_link,
|
|
||||||
resource_tree_link, rid);
|
|
||||||
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct proc_resource* proc_create_resource_stream(struct procgroup* procgroup) {
|
struct proc_resource* proc_create_resource_stream(struct procgroup* procgroup) {
|
||||||
struct proc_resource* resource;
|
struct proc_resource* resource;
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,12 @@
|
|||||||
#include <libk/list.h>
|
#include <libk/list.h>
|
||||||
#include <libk/rbtree.h>
|
#include <libk/rbtree.h>
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
#include <proc/mail.h>
|
|
||||||
#include <proc/mutex.h>
|
#include <proc/mutex.h>
|
||||||
#include <proc/stream.h>
|
#include <proc/stream.h>
|
||||||
#include <sync/spin_lock.h>
|
#include <sync/spin_lock.h>
|
||||||
|
|
||||||
#define PR_MUTEX 0
|
#define PR_MUTEX 0
|
||||||
#define PR_MAIL 1
|
#define PR_STREAM 1
|
||||||
#define PR_STREAM 2
|
|
||||||
|
|
||||||
struct proc;
|
struct proc;
|
||||||
struct procgroup;
|
struct procgroup;
|
||||||
@@ -24,7 +22,6 @@ struct proc_resource {
|
|||||||
struct rb_node_link resource_tree_link;
|
struct rb_node_link resource_tree_link;
|
||||||
union {
|
union {
|
||||||
struct proc_mutex mutex;
|
struct proc_mutex mutex;
|
||||||
struct proc_mail mail;
|
|
||||||
struct proc_stream stream;
|
struct proc_stream stream;
|
||||||
} u;
|
} u;
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ c += proc/proc.c \
|
|||||||
proc/mutex.c \
|
proc/mutex.c \
|
||||||
proc/procgroup.c \
|
proc/procgroup.c \
|
||||||
proc/suspension_q.c \
|
proc/suspension_q.c \
|
||||||
proc/mail.c \
|
|
||||||
proc/stream.c
|
proc/stream.c
|
||||||
|
|
||||||
o += proc/proc.o \
|
o += proc/proc.o \
|
||||||
@@ -11,5 +10,4 @@ o += proc/proc.o \
|
|||||||
proc/mutex.o \
|
proc/mutex.o \
|
||||||
proc/procgroup.o \
|
proc/procgroup.o \
|
||||||
proc/suspension_q.o \
|
proc/suspension_q.o \
|
||||||
proc/mail.o \
|
|
||||||
proc/stream.o
|
proc/stream.o
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <limine/requests.h>
|
#include <limine/requests.h>
|
||||||
#include <mm/pmm.h>
|
#include <mm/pmm.h>
|
||||||
#include <path_defs.h>
|
#include <path_defs.h>
|
||||||
#include <proc/mail.h>
|
|
||||||
#include <proc/mutex.h>
|
#include <proc/mutex.h>
|
||||||
#include <proc/proc.h>
|
#include <proc/proc.h>
|
||||||
#include <proc/procgroup.h>
|
#include <proc/procgroup.h>
|
||||||
@@ -184,56 +183,6 @@ DEFINE_SYSCALL(sys_mutex_unlock) {
|
|||||||
return SYSRESULT(ST_OK);
|
return SYSRESULT(ST_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* int mail_send (int pgid, void* mesg, size_t mesg_size) */
|
|
||||||
DEFINE_SYSCALL(sys_mail_send) {
|
|
||||||
int pgid = (int)a1;
|
|
||||||
uintptr_t uvaddr_mesg = a2;
|
|
||||||
size_t mesg_size = (size_t)a3;
|
|
||||||
|
|
||||||
struct procgroup* procgroup = proc->procgroup;
|
|
||||||
|
|
||||||
void* mesg = sys_get_user_buffer(procgroup, uvaddr_mesg, mesg_size);
|
|
||||||
|
|
||||||
if (mesg == NULL)
|
|
||||||
return SYSRESULT(-ST_BAD_ADDRESS_SPACE);
|
|
||||||
|
|
||||||
struct procgroup* procgroup1 = procgroup_find(pgid);
|
|
||||||
|
|
||||||
if (procgroup1 == NULL)
|
|
||||||
return SYSRESULT(-ST_NOT_FOUND);
|
|
||||||
|
|
||||||
struct proc_resource* mail_resource = proc_find_resource(procgroup1, 0);
|
|
||||||
|
|
||||||
if (mail_resource == NULL)
|
|
||||||
return SYSRESULT(-ST_NOT_FOUND);
|
|
||||||
|
|
||||||
proc_mail_send(proc, &mail_resource->u.mail, rctx, mesg, mesg_size);
|
|
||||||
|
|
||||||
return SYSRESULT(ST_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* int mail_receive (void* recv_mesg, size_t mesg_size) */
|
|
||||||
DEFINE_SYSCALL(sys_mail_receive) {
|
|
||||||
uintptr_t uvaddr_mesg = a1;
|
|
||||||
size_t mesg_size = (size_t)a2;
|
|
||||||
|
|
||||||
struct procgroup* procgroup = proc->procgroup;
|
|
||||||
|
|
||||||
void* mesg = sys_get_user_buffer(procgroup, uvaddr_mesg, mesg_size);
|
|
||||||
|
|
||||||
if (mesg == NULL)
|
|
||||||
return SYSRESULT(-ST_BAD_ADDRESS_SPACE);
|
|
||||||
|
|
||||||
struct proc_resource* mail_resource = proc_find_resource(procgroup, 0);
|
|
||||||
|
|
||||||
if (mail_resource == NULL)
|
|
||||||
return SYSRESULT(-ST_NOT_FOUND);
|
|
||||||
|
|
||||||
proc_mail_receive(proc, &mail_resource->u.mail, rctx, mesg, mesg_size);
|
|
||||||
|
|
||||||
return SYSRESULT(ST_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4) */
|
/* int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4) */
|
||||||
DEFINE_SYSCALL(sys_device_do) {
|
DEFINE_SYSCALL(sys_device_do) {
|
||||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||||
@@ -912,8 +861,6 @@ static syscall_handler_func_t handler_table[] = {
|
|||||||
[SYS_VOLUME_CLOSE] = &sys_volume_close,
|
[SYS_VOLUME_CLOSE] = &sys_volume_close,
|
||||||
[SYS_READ_FILE] = &sys_read_file,
|
[SYS_READ_FILE] = &sys_read_file,
|
||||||
[SYS_DESCRIBE] = &sys_describe,
|
[SYS_DESCRIBE] = &sys_describe,
|
||||||
[SYS_MAIL_SEND] = &sys_mail_send,
|
|
||||||
[SYS_MAIL_RECEIVE] = &sys_mail_receive,
|
|
||||||
[SYS_GET_PROCGROUP] = &sys_get_procgroup,
|
[SYS_GET_PROCGROUP] = &sys_get_procgroup,
|
||||||
[SYS_GET_EXEC_PID] = &sys_get_exec_pid,
|
[SYS_GET_EXEC_PID] = &sys_get_exec_pid,
|
||||||
[SYS_READ_DIR_ENTRY] = &sys_read_dir_entry,
|
[SYS_READ_DIR_ENTRY] = &sys_read_dir_entry,
|
||||||
|
|||||||
@@ -55,14 +55,6 @@ int describe(const char* path, struct desc* desc) {
|
|||||||
return (int)do_syscall(SYS_DESCRIBE, path, desc);
|
return (int)do_syscall(SYS_DESCRIBE, path, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mail_send(int pgid, void* mesg, size_t mesg_size) {
|
|
||||||
return (int)do_syscall(SYS_MAIL_SEND, pgid, mesg, mesg_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mail_receive(void* mesg, size_t mesg_size) {
|
|
||||||
return (int)do_syscall(SYS_MAIL_RECEIVE, mesg, mesg_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_procgroup(int pid) { return (int)do_syscall(SYS_GET_PROCGROUP, pid); }
|
int get_procgroup(int pid) { return (int)do_syscall(SYS_GET_PROCGROUP, pid); }
|
||||||
|
|
||||||
int get_exec_pid(void) { return (int)do_syscall(SYS_GET_EXEC_PID, 0); }
|
int get_exec_pid(void) { return (int)do_syscall(SYS_GET_EXEC_PID, 0); }
|
||||||
|
|||||||
@@ -61,12 +61,6 @@ int read_file(const char* path, size_t off, uint8_t* buffer, size_t size);
|
|||||||
/* describe a file */
|
/* describe a file */
|
||||||
int describe(const char* path, struct desc* desc);
|
int describe(const char* path, struct desc* desc);
|
||||||
|
|
||||||
/* send a message to a procgroup's mail */
|
|
||||||
int mail_send(int pgid, void* mesg, size_t mesg_size);
|
|
||||||
|
|
||||||
/* receive a message from mail */
|
|
||||||
int mail_receive(void* mesg, size_t mesg_size);
|
|
||||||
|
|
||||||
/* get procgroup id of a perticular process */
|
/* get procgroup id of a perticular process */
|
||||||
int get_procgroup(int pid);
|
int get_procgroup(int pid);
|
||||||
|
|
||||||
|
|||||||
6
mailtest/.gitignore
vendored
6
mailtest/.gitignore
vendored
@@ -1,6 +0,0 @@
|
|||||||
*.o
|
|
||||||
*.json
|
|
||||||
docs/
|
|
||||||
.cache/
|
|
||||||
*.map
|
|
||||||
mailtest
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
include ../make/user.mk
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
app := mailtest
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#include <cmdline_parser.h>
|
|
||||||
#include <debugconsole.h>
|
|
||||||
#include <process.h>
|
|
||||||
#include <status.h>
|
|
||||||
#include <strconv.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <system.h>
|
|
||||||
|
|
||||||
static bool cmdline_send = false;
|
|
||||||
static bool cmdline_recv = false;
|
|
||||||
static char cmdline_payload[CMDLINE_OPT_VALUE_MAX];
|
|
||||||
static uint64_t cmdline_pg;
|
|
||||||
|
|
||||||
static struct cmdline_opt cmdline_opts[] = {
|
|
||||||
CMDLINE_OPT("s", "send", CMDLINE_OPT_VALUE_BOOL, false, &cmdline_send),
|
|
||||||
CMDLINE_OPT("r", "recv", CMDLINE_OPT_VALUE_BOOL, false, &cmdline_recv),
|
|
||||||
CMDLINE_OPT("p", "payload", CMDLINE_OPT_VALUE_STRING, false, (char*)cmdline_payload),
|
|
||||||
CMDLINE_OPT("pg", "procgroup", CMDLINE_OPT_VALUE_INT, false, &cmdline_pg),
|
|
||||||
CMDLINE_END(),
|
|
||||||
};
|
|
||||||
|
|
||||||
void app_main(void) {
|
|
||||||
if (cmdline_parse(get_cmdline(), cmdline_opts) < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cmdline_recv) {
|
|
||||||
char recv_buffer[1024];
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
debug_printf("Waiting...\n");
|
|
||||||
memset(recv_buffer, 0, sizeof(recv_buffer));
|
|
||||||
mail_receive(recv_buffer, sizeof(recv_buffer));
|
|
||||||
|
|
||||||
debug_printf("Recv: %s\n", recv_buffer);
|
|
||||||
}
|
|
||||||
} else if (cmdline_send) {
|
|
||||||
debug_printf("sending [%s] to PG %d\n", cmdline_payload, (int)cmdline_pg);
|
|
||||||
|
|
||||||
mail_send((int)cmdline_pg, cmdline_payload, strlen(cmdline_payload));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
c += mailtest.c
|
|
||||||
|
|
||||||
o += mailtest.o
|
|
||||||
@@ -4,7 +4,6 @@ apps := \
|
|||||||
ce \
|
ce \
|
||||||
sdutil \
|
sdutil \
|
||||||
usb \
|
usb \
|
||||||
mailtest \
|
|
||||||
devices \
|
devices \
|
||||||
volumes
|
volumes
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user