Retire the synchronous character driver protocol
- change all sync char drivers into async drivers; - retire support for the sync protocol in libchardev; - remove async dev style, as this is now the default; - remove dev_status from VFS; - clean up now-unused protocol messages. Change-Id: I6aacff712292f6b29f2ccd51bc1e7d7003723e87
This commit is contained in:
@@ -20,11 +20,7 @@
|
||||
* |-------------+---------+---------+---------+---------+---------|
|
||||
* | DEV_IOCTL_S | device | proc nr |func code| | buf ptr |
|
||||
* |-------------+---------+---------+---------+---------+---------|
|
||||
* | DEV_STATUS | | | | | |
|
||||
* |-------------+---------+---------+---------+---------+---------|
|
||||
* | HARD_INT | | | | | |
|
||||
* |-------------+---------+---------+---------+---------+---------|
|
||||
* | SIG_STOP | | | | | |
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* The file contains one entry point:
|
||||
@@ -81,7 +77,6 @@ static void sef_cb_signal_handler(int signo);
|
||||
EXTERN int sef_cb_lu_prepare(int state);
|
||||
EXTERN int sef_cb_lu_state_isvalid(int state);
|
||||
EXTERN void sef_cb_lu_state_dump(int state);
|
||||
int is_status_msg_expected = FALSE;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -121,8 +116,10 @@ int main(void)
|
||||
case DEV_OPEN:
|
||||
/* open the special file ( = parameter) */
|
||||
r = msg_open(mess.DEVICE);
|
||||
repl_mess.m_type = DEV_REVIVE;
|
||||
repl_mess.m_type = DEV_OPEN_REPL;
|
||||
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
||||
repl_mess.REP_IO_GRANT =
|
||||
(cp_grant_id_t) mess.IO_GRANT;
|
||||
repl_mess.REP_STATUS = r;
|
||||
send(caller, &repl_mess);
|
||||
|
||||
@@ -133,6 +130,8 @@ int main(void)
|
||||
r = msg_close(mess.DEVICE);
|
||||
repl_mess.m_type = DEV_CLOSE_REPL;
|
||||
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
||||
repl_mess.REP_IO_GRANT =
|
||||
(cp_grant_id_t) mess.IO_GRANT;
|
||||
repl_mess.REP_STATUS = r;
|
||||
send(caller, &repl_mess);
|
||||
|
||||
@@ -146,7 +145,7 @@ int main(void)
|
||||
repl_mess.m_type = DEV_REVIVE;
|
||||
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
||||
repl_mess.REP_IO_GRANT =
|
||||
(unsigned)mess.IO_GRANT;
|
||||
(cp_grant_id_t) mess.IO_GRANT;
|
||||
repl_mess.REP_STATUS = r;
|
||||
send(caller, &repl_mess);
|
||||
}
|
||||
@@ -156,13 +155,13 @@ int main(void)
|
||||
msg_read(&mess); continue; /* don't reply */
|
||||
case DEV_WRITE_S:
|
||||
msg_write(&mess); continue; /* don't reply */
|
||||
case DEV_STATUS:
|
||||
msg_status(&mess);continue; /* don't reply */
|
||||
case DEV_REOPEN:
|
||||
/* reopen the special file ( = parameter) */
|
||||
r = msg_open(mess.DEVICE);
|
||||
repl_mess.m_type = DEV_REOPEN_REPL;
|
||||
repl_mess.REP_ENDPT = mess.USER_ENDPT;
|
||||
repl_mess.REP_IO_GRANT =
|
||||
(cp_grant_id_t) mess.IO_GRANT;
|
||||
repl_mess.REP_STATUS = r;
|
||||
send(caller, &repl_mess);
|
||||
continue;
|
||||
@@ -626,35 +625,6 @@ static void msg_hardware(void) {
|
||||
}
|
||||
|
||||
|
||||
static void msg_status(message *m_ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < drv.NrOfSubDevices; i++) {
|
||||
|
||||
if(sub_dev[i].ReadyToRevive)
|
||||
{
|
||||
m_ptr->m_type = DEV_REVIVE; /* build message */
|
||||
m_ptr->REP_ENDPT = sub_dev[i].ReviveProcNr;
|
||||
m_ptr->REP_IO_GRANT = sub_dev[i].ReviveGrant;
|
||||
m_ptr->REP_STATUS = sub_dev[i].ReviveStatus;
|
||||
send(m_ptr->m_source, m_ptr); /* send the message */
|
||||
|
||||
/* reset variables */
|
||||
sub_dev[i].ReadyToRevive = FALSE;
|
||||
sub_dev[i].RevivePending = 0;
|
||||
|
||||
is_status_msg_expected = TRUE;
|
||||
return; /* stop after one mess,
|
||||
file system will get back for other processes */
|
||||
}
|
||||
}
|
||||
m_ptr->m_type = DEV_NO_STATUS;
|
||||
m_ptr->REP_STATUS = 0;
|
||||
send(m_ptr->m_source, m_ptr); /* send DEV_NO_STATUS message */
|
||||
is_status_msg_expected = FALSE;
|
||||
}
|
||||
|
||||
/* handle interrupt for specified sub device; DmaMode == DEV_WRITE_S*/
|
||||
static void handle_int_write(int sub_dev_nr)
|
||||
{
|
||||
@@ -712,6 +682,7 @@ static void handle_int_write(int sub_dev_nr)
|
||||
static void handle_int_read(int sub_dev_nr)
|
||||
{
|
||||
sub_dev_t *sub_dev_ptr;
|
||||
message m;
|
||||
|
||||
sub_dev_ptr = &sub_dev[sub_dev_nr];
|
||||
|
||||
@@ -729,9 +700,14 @@ static void handle_int_read(int sub_dev_nr)
|
||||
printf("All buffers full, we have a problem.\n");
|
||||
drv_stop(sub_dev_nr); /* stop the sub device */
|
||||
sub_dev_ptr->DmaBusy = FALSE;
|
||||
sub_dev_ptr->ReviveStatus = 0; /* no data for user,
|
||||
this is a sad story */
|
||||
sub_dev_ptr->ReadyToRevive = TRUE; /* wake user up */
|
||||
sub_dev_ptr->ReviveStatus = 0; /* no data for user,
|
||||
* this is a sad story
|
||||
*/
|
||||
m.m_type = DEV_REVIVE;
|
||||
m.REP_ENDPT = sub_dev_ptr->ReviveProcNr;
|
||||
m.REP_IO_GRANT = sub_dev_ptr->ReviveGrant;
|
||||
m.REP_STATUS = sub_dev_ptr->ReviveStatus;
|
||||
send(sub_dev_ptr->SourceProcNr, &m);
|
||||
return;
|
||||
}
|
||||
else { /* dma full, still room in extra buf;
|
||||
@@ -790,9 +766,6 @@ static void data_from_user(sub_dev_t *subdev)
|
||||
|
||||
if (!subdev->RevivePending) return; /* no new data waiting to be copied */
|
||||
|
||||
if (subdev->RevivePending &&
|
||||
subdev->ReadyToRevive) return; /* we already got this data */
|
||||
|
||||
if (subdev->DmaLength < subdev->NrOfDmaFragments) { /* room in dma buf */
|
||||
|
||||
r = sys_safecopyfrom(subdev->SourceProcNr,
|
||||
@@ -835,7 +808,6 @@ static void data_from_user(sub_dev_t *subdev)
|
||||
}
|
||||
|
||||
subdev->ReviveStatus = subdev->FragSize;
|
||||
subdev->ReadyToRevive = TRUE;
|
||||
|
||||
m.m_type = DEV_REVIVE; /* build message */
|
||||
m.REP_ENDPT = subdev->ReviveProcNr;
|
||||
@@ -849,7 +821,6 @@ static void data_from_user(sub_dev_t *subdev)
|
||||
}
|
||||
|
||||
/* reset variables */
|
||||
subdev->ReadyToRevive = FALSE;
|
||||
subdev->RevivePending = 0;
|
||||
}
|
||||
|
||||
@@ -860,7 +831,6 @@ static void data_to_user(sub_dev_t *sub_dev_ptr)
|
||||
message m;
|
||||
|
||||
if (!sub_dev_ptr->RevivePending) return; /* nobody is wating for data */
|
||||
if (sub_dev_ptr->ReadyToRevive) return;/* we already filled user's buffer */
|
||||
if (sub_dev_ptr->BufLength == 0 && sub_dev_ptr->DmaLength == 0) return;
|
||||
/* no data for user */
|
||||
|
||||
@@ -896,7 +866,6 @@ static void data_to_user(sub_dev_t *sub_dev_ptr)
|
||||
}
|
||||
|
||||
sub_dev_ptr->ReviveStatus = sub_dev_ptr->FragSize;
|
||||
sub_dev_ptr->ReadyToRevive = TRUE;
|
||||
/* drv_status will send REVIVE mess to FS*/
|
||||
|
||||
m.m_type = DEV_REVIVE; /* build message */
|
||||
@@ -911,7 +880,6 @@ static void data_to_user(sub_dev_t *sub_dev_ptr)
|
||||
}
|
||||
|
||||
/* reset variables */
|
||||
sub_dev_ptr->ReadyToRevive = FALSE;
|
||||
sub_dev_ptr->RevivePending = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include <minix/audio_fw.h>
|
||||
|
||||
/* State management variables. */
|
||||
EXTERN int is_status_msg_expected;
|
||||
/*
|
||||
* - From audio_fw.h:
|
||||
* EXTERN drv_t drv;
|
||||
@@ -60,8 +58,7 @@ int sef_cb_lu_prepare(int state)
|
||||
break;
|
||||
|
||||
case SEF_LU_STATE_PROTOCOL_FREE:
|
||||
is_ready = (!is_read_pending && !is_write_pending
|
||||
&& !is_status_msg_expected);
|
||||
is_ready = (!is_read_pending && !is_write_pending);
|
||||
break;
|
||||
|
||||
/* Custom states. */
|
||||
@@ -95,8 +92,6 @@ void sef_cb_lu_state_dump(int state)
|
||||
load_state_info();
|
||||
|
||||
sef_lu_dprint("audio: live update state = %d\n", state);
|
||||
sef_lu_dprint("audio: is_status_msg_expected = %d\n",
|
||||
is_status_msg_expected);
|
||||
sef_lu_dprint("audio: is_read_pending = %d\n", is_read_pending);
|
||||
sef_lu_dprint("audio: is_write_pending = %d\n", is_write_pending);
|
||||
|
||||
@@ -105,8 +100,7 @@ void sef_cb_lu_state_dump(int state)
|
||||
sef_lu_dprint("audio: SEF_LU_STATE_REQUEST_FREE(%d) reached = %d\n",
|
||||
SEF_LU_STATE_REQUEST_FREE, (!is_read_pending && !is_write_pending));
|
||||
sef_lu_dprint("audio: SEF_LU_STATE_PROTOCOL_FREE(%d) reached = %d\n",
|
||||
SEF_LU_STATE_PROTOCOL_FREE, (!is_read_pending && !is_write_pending
|
||||
&& !is_status_msg_expected));
|
||||
SEF_LU_STATE_PROTOCOL_FREE, (!is_read_pending && !is_write_pending));
|
||||
sef_lu_dprint("audio: AUDIO_STATE_READ_REQUEST_FREE(%d) reached = %d\n",
|
||||
AUDIO_STATE_READ_REQUEST_FREE, (!is_read_pending));
|
||||
sef_lu_dprint("audio: AUDIO_STATE_WRITE_REQUEST_FREE(%d) reached = %d\n",
|
||||
|
||||
@@ -73,9 +73,9 @@ void *data;
|
||||
break;
|
||||
}
|
||||
|
||||
m.TTY_LINE = fd;
|
||||
m.TTY_REQUEST = request;
|
||||
m.ADDRESS = (char *) addr;
|
||||
m.VFS_IOCTL_FD = fd;
|
||||
m.VFS_IOCTL_REQ = request;
|
||||
m.VFS_IOCTL_ARG = (char *) addr;
|
||||
|
||||
r = _syscall(VFS_PROC_NR, IOCTL, &m);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* driver_receive: message receive interface for drivers
|
||||
*
|
||||
* Changes:
|
||||
* Oct 20, 2013 retire synchronous protocol (D.C. van Moolenbroek)
|
||||
* Oct 16, 2011 split character and block protocol (D.C. van Moolenbroek)
|
||||
* Aug 27, 2011 move common functions into driver.c (A. Welzel)
|
||||
* Jul 25, 2005 added SYS_SIG type for signals (Jorrit N. Herder)
|
||||
@@ -117,16 +118,19 @@ void chardriver_announce(void)
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* async_reply *
|
||||
* send_reply *
|
||||
*===========================================================================*/
|
||||
static void async_reply(message *mess, int r)
|
||||
static void send_reply(message *mess, int ipc_status, int r)
|
||||
{
|
||||
/* Send a reply using the asynchronous character device protocol. */
|
||||
/* Prepare and send a reply message. */
|
||||
message reply_mess;
|
||||
|
||||
/* Do not reply with ERESTART in this protocol. The only possible caller,
|
||||
* VFS, will find out through other means when we have restarted, and is not
|
||||
* (fully) ready to deal with ERESTART errors.
|
||||
if (r == EDONTREPLY)
|
||||
return;
|
||||
|
||||
/* Do not reply with ERESTART. The only possible caller, VFS, will find out
|
||||
* through other means when we have restarted, and is not (fully) ready to
|
||||
* deal with ERESTART errors.
|
||||
*/
|
||||
if (r == ERESTART)
|
||||
return;
|
||||
@@ -150,7 +154,7 @@ static void async_reply(message *mess, int r)
|
||||
case DEV_WRITE_S:
|
||||
case DEV_IOCTL_S:
|
||||
if (r == SUSPEND)
|
||||
printf("driver_task: reviving %d (%d) with SUSPEND\n",
|
||||
printf("chardriver_task: reviving %d (%d) with SUSPEND\n",
|
||||
mess->m_source, mess->USER_ENDPT);
|
||||
|
||||
reply_mess.m_type = DEV_REVIVE;
|
||||
@@ -170,60 +174,22 @@ static void async_reply(message *mess, int r)
|
||||
break;
|
||||
|
||||
default:
|
||||
reply_mess.m_type = TASK_REPLY;
|
||||
reply_mess.m_type = DEV_REVIVE;
|
||||
reply_mess.REP_ENDPT = mess->USER_ENDPT;
|
||||
/* Status is # of bytes transferred or error code. */
|
||||
reply_mess.REP_STATUS = r;
|
||||
break;
|
||||
}
|
||||
|
||||
r = asynsend(mess->m_source, &reply_mess);
|
||||
|
||||
if (r != OK)
|
||||
printf("asyn_reply: unable to asynsend reply to %d: %d\n",
|
||||
mess->m_source, r);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sync_reply *
|
||||
*===========================================================================*/
|
||||
static void sync_reply(message *m_ptr, int ipc_status, int reply)
|
||||
{
|
||||
/* Reply to a message sent to the driver. */
|
||||
endpoint_t caller_e, user_e;
|
||||
int r;
|
||||
|
||||
caller_e = m_ptr->m_source;
|
||||
user_e = m_ptr->USER_ENDPT;
|
||||
|
||||
m_ptr->m_type = TASK_REPLY;
|
||||
m_ptr->REP_ENDPT = user_e;
|
||||
m_ptr->REP_STATUS = reply;
|
||||
|
||||
/* If we would block sending the message, send it asynchronously. */
|
||||
if (IPC_STATUS_CALL(ipc_status) == SENDREC)
|
||||
r = sendnb(caller_e, m_ptr);
|
||||
r = sendnb(mess->m_source, &reply_mess);
|
||||
else
|
||||
r = asynsend(caller_e, m_ptr);
|
||||
r = asynsend3(mess->m_source, &reply_mess, AMF_NOREPLY);
|
||||
|
||||
if (r != OK)
|
||||
printf("driver_reply: unable to send reply to %d: %d\n", caller_e, r);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* send_reply *
|
||||
*===========================================================================*/
|
||||
static void send_reply(int type, message *m_ptr, int ipc_status, int reply)
|
||||
{
|
||||
/* Prepare and send a reply message. */
|
||||
|
||||
if (reply == EDONTREPLY)
|
||||
return;
|
||||
|
||||
if (type == CHARDRIVER_ASYNC)
|
||||
async_reply(m_ptr, reply);
|
||||
else
|
||||
sync_reply(m_ptr, ipc_status, reply);
|
||||
printf("send_reply: unable to send reply to %d: %d\n",
|
||||
mess->m_source, r);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -343,7 +309,7 @@ static int handle_request(struct chardriver *cdp, message *m_ptr)
|
||||
* requests on devices that have not previously been opened, signaling the
|
||||
* caller that something went wrong.
|
||||
*/
|
||||
if (IS_CDEV_MINOR_RQ(m_ptr->m_type) && !is_open_dev(m_ptr->DEVICE)) {
|
||||
if (IS_DEV_RQ(m_ptr->m_type) && !is_open_dev(m_ptr->DEVICE)) {
|
||||
/* Reply ERESTART to spurious requests for unopened devices. */
|
||||
if (m_ptr->m_type != DEV_OPEN)
|
||||
return ERESTART;
|
||||
@@ -380,8 +346,7 @@ static int handle_request(struct chardriver *cdp, message *m_ptr)
|
||||
/*===========================================================================*
|
||||
* chardriver_process *
|
||||
*===========================================================================*/
|
||||
void chardriver_process(struct chardriver *cdp, int driver_type,
|
||||
message *m_ptr, int ipc_status)
|
||||
void chardriver_process(struct chardriver *cdp, message *m_ptr, int ipc_status)
|
||||
{
|
||||
/* Handle the given received message. */
|
||||
int r;
|
||||
@@ -394,14 +359,14 @@ void chardriver_process(struct chardriver *cdp, int driver_type,
|
||||
} else {
|
||||
r = handle_request(cdp, m_ptr);
|
||||
|
||||
send_reply(driver_type, m_ptr, ipc_status, r);
|
||||
send_reply(m_ptr, ipc_status, r);
|
||||
}
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* chardriver_task *
|
||||
*===========================================================================*/
|
||||
void chardriver_task(struct chardriver *cdp, int driver_type)
|
||||
void chardriver_task(struct chardriver *cdp)
|
||||
{
|
||||
/* Main program of any device driver task. */
|
||||
int r, ipc_status;
|
||||
@@ -416,7 +381,7 @@ void chardriver_task(struct chardriver *cdp, int driver_type)
|
||||
if ((r = sef_receive_status(ANY, &mess, &ipc_status)) != OK)
|
||||
panic("driver_receive failed: %d", r);
|
||||
|
||||
chardriver_process(cdp, driver_type, &mess, ipc_status);
|
||||
chardriver_process(cdp, &mess, ipc_status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,19 +93,14 @@ _ddekit_minix_queue_msg (
|
||||
full = ddekit_sem_down_try(mq->msg_w_sem);
|
||||
|
||||
if (full) {
|
||||
/* Our message queue is full... inform the sender. */
|
||||
/* Our message queue is full... */
|
||||
int result;
|
||||
DDEBUG_MSG_WARN("Receive queue is full. Ommiting ingoing msg.\n");
|
||||
|
||||
m->m_type = TASK_REPLY;
|
||||
m->REP_STATUS = EAGAIN;
|
||||
result = asynsend(m->m_source, m);
|
||||
|
||||
if (result != 0) {
|
||||
ddekit_panic("unable to send reply to %d: %d\n",
|
||||
m->m_source, result);
|
||||
}
|
||||
DDEBUG_MSG_WARN("Receive queue is full. Dropping request.\n");
|
||||
|
||||
/* XXX should reply to the sender with EIO or so, but for that
|
||||
* we would need to look at the request and find a suitable
|
||||
* reply code..
|
||||
*/
|
||||
} else {
|
||||
/* queue the message */
|
||||
memcpy(&mq->messages[mq->msg_w_pos], m, sizeof(message));
|
||||
|
||||
@@ -76,7 +76,6 @@ SRCS+= \
|
||||
sys_vsafecopy.c \
|
||||
sys_vtimer.c \
|
||||
sys_vumap.c \
|
||||
send_taskreply.c \
|
||||
taskcall.c \
|
||||
tickdelay.c \
|
||||
timers.c \
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_taskreply *
|
||||
*===========================================================================*/
|
||||
int send_taskreply(endpoint_t who, endpoint_t endpoint, int status)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
|
||||
m.REP_ENDPT = endpoint;
|
||||
m.REP_STATUS = status;
|
||||
|
||||
return _sendcall(who, TASK_REPLY, &m);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user