hrtimers.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1997, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
/*
* This file contains the code that manages the hardware clocks and
* timers. We must provide UNIX with a HZ resolution clock and give
* the user an interface to the timers through system calls.
*/
static int hrt_bsd_cancel(int clock);
static int hrt_checkclock(register int clock);
/*
* Argument vectors for the various flavors of hrtsys().
*/
#define HRTCNTL 0
#define HRTALARM 1
#define HRTSLEEP 2
#define HRTCANCEL 3
struct hrtsysa {
int opcode;
};
struct hrtcntla {
int opcode;
int cmd;
int clk;
};
struct hrtalarma {
int opcode;
int cmds;
};
/*
* Hrtcntl (time control) system call.
*/
/*ARGSUSED1*/
int
{
register int error = 0;
case HRT_TOFD: /* Get the time of day */
break;
}
break;
}
break;
break;
default:
break;
}
return (error);
}
/*
* Hrtalarm (start one or more alarms) system call.
*/
int
{
int cnt;
int error = 0;
int cmd;
/*
* Return EINVAL for negative and zero counts.
*/
return (EINVAL);
alarm_cnt = 0;
/* Loop through and process each command. */
return (EFAULT);
/*
* If we try to post a Berkley Timer remove
* previous timers.
*/
/* See what kind of command we have. */
switch (cmd) {
case HRT_BSD: /* one-shot timer */
{
break;
case CLK_STD:
which = ITIMER_REAL;
break;
case CLK_USERVIRT:
break;
case CLK_PROCVIRT:
which = ITIMER_PROF;
break;
default:
goto bad;
}
break;
}
case HRT_BSD_REP:
{
case CLK_STD:
which = ITIMER_REAL;
break;
case CLK_USERVIRT:
break;
case CLK_PROCVIRT:
which = ITIMER_PROF;
break;
default:
goto bad;
}
break;
}
case HRT_BSD_PEND:
{
case CLK_STD:
which = ITIMER_REAL;
break;
case CLK_USERVIRT:
break;
case CLK_PROCVIRT:
which = ITIMER_PROF;
break;
default:
goto bad;
}
}
break;
case HRT_BSD_CANCEL:
break;
break;
default :
break;
}
bad:
if (error) {
} else {
cp->hrtc_error = 0;
alarm_cnt++;
}
return (error);
}
}
return (0);
}
/*
* Cancel BSD timers
*/
static int
hrt_bsd_cancel(int clock)
{
switch (clock) {
case CLK_STD:
which = ITIMER_REAL;
break;
case CLK_USERVIRT:
break;
case CLK_PROCVIRT:
which = ITIMER_PROF;
break;
default:
return (EINVAL);
}
return (0);
}
/*
* Return 0 if "res" is a legal resolution. Otherwise,
* return an error code, ERANGE.
*/
static int
{
return (ERANGE);
return (0);
}
/*
* Return 0 if "clock" is a valid clock. Otherwise,
* return an error code, EINVAL.
*/
static int
hrt_checkclock(register int clock)
{
switch (clock)
case CLK_STD:
case CLK_USERVIRT:
case CLK_PROCVIRT:
return (0);
return (EINVAL);
}
/*
* Set the current time of day in a specified resolution into
* a hrtimes_t structure.
*/
void
{
gethrestime(&ts);
}
}
/*
* System entry point for hrtcntl, hrtalarm
* system calls.
*/
int
{
register int error;
case HRTCNTL:
break;
case HRTALARM:
break;
default:
break;
}
return (error);
}