VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/req.h@ 39545

Last change on this file since 39545 was 39545, checked in by vboxsync, 13 years ago

laptop -> workstation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: req.h 39545 2011-12-07 10:27:29Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTReq header.
4 */
5
6/*
7 * Copyright (C) 2006-2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___internal_req_h
28#define ___internal_req_h
29
30#include <iprt/types.h>
31
32
33RT_C_DECLS_BEGIN
34
35/**
36 * Request state.
37 */
38typedef enum RTREQSTATE
39{
40 /** The state is invalid. */
41 RTREQSTATE_INVALID = 0,
42 /** The request have been allocated and is in the process of being filed. */
43 RTREQSTATE_ALLOCATED,
44 /** The request is queued by the requester. */
45 RTREQSTATE_QUEUED,
46 /** The request is begin processed. */
47 RTREQSTATE_PROCESSING,
48 /** The request is completed, the requester is begin notified. */
49 RTREQSTATE_COMPLETED,
50 /** The request packet is in the free chain. (The requester */
51 RTREQSTATE_FREE
52} RTREQSTATE;
53
54
55/**
56 * RT Request packet.
57 *
58 * This is used to request an action in the queue handler thread.
59 */
60struct RTREQ
61{
62 /** Magic number (RTREQ_MAGIC). */
63 uint32_t u32Magic;
64 /** Set if the event semaphore is clear. */
65 volatile bool fEventSemClear;
66 /** Set if pool, clear if queue. */
67 volatile bool fPoolOrQueue;
68 /** IPRT status code for the completed request. */
69 volatile int32_t iStatusX;
70 /** Request state. */
71 volatile RTREQSTATE enmState;
72
73 /** Pointer to the next request in the chain. */
74 struct RTREQ * volatile pNext;
75
76 union
77 {
78 /** Pointer to the pool this packet belongs to. */
79 RTREQPOOL hPool;
80 /** Pointer to the queue this packet belongs to. */
81 RTREQQUEUE hQueue;
82 } uOwner;
83
84 /** Timestamp take when the request was submitted to a pool. Not used
85 * for queued request. */
86 uint64_t uSubmitNanoTs;
87 /** Requester completion event sem. */
88 RTSEMEVENT EventSem;
89 /** Request pushback event sem. Allocated lazily. */
90 RTSEMEVENTMULTI hPushBackEvt;
91 /** Flags, RTREQ_FLAGS_*. */
92 uint32_t fFlags;
93 /** Request type. */
94 RTREQTYPE enmType;
95 /** Request specific data. */
96 union RTREQ_U
97 {
98 /** RTREQTYPE_INTERNAL. */
99 struct
100 {
101 /** Pointer to the function to be called. */
102 PFNRT pfn;
103 /** Number of arguments. */
104 uint32_t cArgs;
105 /** Array of arguments. */
106 uintptr_t aArgs[64];
107 } Internal;
108 } u;
109};
110
111/** Internal request representation. */
112typedef RTREQ RTREQINT;
113/** Pointer to an internal request representation. */
114typedef RTREQINT *PRTREQINT;
115
116/**
117 * Internal queue instance.
118 */
119typedef struct RTREQQUEUEINT
120{
121 /** Magic value (RTREQQUEUE_MAGIC). */
122 uint32_t u32Magic;
123 /** Set if busy (pending or processing requests). */
124 bool volatile fBusy;
125 /** Head of the request queue. Atomic. */
126 volatile PRTREQ pReqs;
127 /** The last index used during alloc/free. */
128 volatile uint32_t iReqFree;
129 /** Number of free request packets. */
130 volatile uint32_t cReqFree;
131 /** Array of pointers to lists of free request packets. Atomic. */
132 volatile PRTREQ apReqFree[9];
133 /** Requester event sem.
134 * The request can use this event semaphore to wait/poll for new requests.
135 */
136 RTSEMEVENT EventSem;
137} RTREQQUEUEINT;
138
139/** Pointer to an internal queue instance. */
140typedef RTREQQUEUEINT *PRTREQQUEUEINT;
141
142
143
144DECLHIDDEN(int) rtReqProcessOne(PRTREQ pReq);
145
146RT_C_DECLS_END
147
148#endif
149
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette