/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <door.h>
#include <unistd.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <synch.h>
#include <librcm_impl.h>
#include "librcm_event.h"
/*
* Lookup seq_num. We can not use the standard nvlist_lookup functions since
* the nvlist is not allocated with NV_UNIQUE_NAME or NV_UNIQUE_NAME_TYPE.
*/
static int
{
}
return (ENOENT);
}
/*
* Get event service from a named door.
*
* This is similar to sysevent_post_event(), except that it deals with
* the "return buffer problem":
* Typically, the door service places the return buffer on the stack
* when calling door_return(). This places an artificial limit on the
* size of the return buffer.
* This problem is solved by placing large buffers on the heap, referenced
* through door_info. When client detects a large buffer, it will make a
* second door_call() to free the buffer. The client and the server agrees
* on a size, which is defined as BUF_THRESHOLD.
*
* Returns -1 if message not delivered. With errno set to cause of error.
* Returns 0 for success with the results returned in posting buffer.
*/
int
{
/*
* Open the service door
*/
return (-1);
}
/*
* Make door call
* EAGAIN is returned when the door server is temporarily
* out of threads to service the door call. So retry.
*/
(void) sleep(1);
goto retry1;
}
*rlen = 0;
dprint("bad return from door call\n");
(void) close(service_door);
return (-1);
}
/*
* If requiring a buf free, make another door call. There is
* no need to call munmap() after this door call, though.
*/
(void) sleep(1);
goto retry2;
}
dprint("fail to free event buf in server\n");
}
}
}
(void) close(service_door);
return (error);
}
/*
* Export an event service door
*/
struct door_result {
void *data;
};
typedef struct door_cookie {
/*
* add result to cookie, this is only invoked if result size > BUF_THRESHOLD
*/
static void
{
/*
* Need a better way to handle memory here
*/
(void) sleep(1);
}
/*
* Attach current door result to the door cookie
*/
} else {
}
}
}
/*
* free a previous door result as described by number.
*/
static void
{
}
dprint("attempting to free nonexistent buf: %llu\n",
(unsigned long long)num);
return;
}
if (prev) {
} else {
}
}
/*ARGSUSED*/
static void
{
/*
* Special case for asking to free buffer
*/
}
/*
* door_func update args to point to return results.
* memory for results are dynamically allocated.
*/
/*
* If no results, just return
*/
dprint("null results returned from door_func().\n");
}
/* Determine the size of the packed nvlist */
alen = 0;
}
/*
* If the size of the packed nvlist would exceed the buffer threshold
* then get a sequence number and add it to the nvlist.
*/
if (nvl_size > BUF_THRESHOLD) {
}
/* Refill the args with a packed version of the nvlist */
}
/*
* Based on the size of the packed nvlist, either use the local buffer
* or add it to the results list.
*/
if (alen <= BUF_THRESHOLD) {
} else {
/*
* for long data, append results to end of queue in cook
* and set ndid, ask client to do another door_call
* to free the buffer.
*/
}
}
int
{
/* create an fs file */
return (-1);
}
/* allocate space for door cookie */
return (-1);
}
return (-1);
}
/*
* EBUSY error may occur if anyone references the door
* file while we are fattach'ing. Since librcm, in the
* the process context of a DR initiator program, may
* door_call etc.) while we are still fattach'ing,
* retry on EBUSY.
*/
goto retry;
}
(void) close(service_door);
return (-1);
}
return (service_door);
}
int
{
return (-1);
}
if (door_revoke(fd) != 0) {
return (-1);
}
/* wait for existing door calls to finish */
(void) sleep(1);
while (tmp) {
}
}
return (0);
}