/* // ************************************************************************* // * * // * c Copyright 2005 Hewlett-Packard Development Company, L.P. * // * * // * Confidential computer software. Valid license from HP and/or * // * its subsidiaries required for possession, use, or copying. * // * * // * Consistent with FAR 12.211 and 12.212, Commercial Computer Software, * // * Computer Software Documentation, and Technical Data for Commercial * // * Items are licensed to the U.S. Government under vendor's standard * // * commercial license. * // * * // * Neither HP nor any of its subsidiaries shall be liable for technical * // * or editorial errors or omissions contained herein. The information * // * in this document is provided "as is" without warranty of any kind and * // * is subject to change without notice. The warranties for HP products * // * are set forth in the express limited warranty statements accompanying * // * such products. Nothing herein should be construed as constituting an * // * additional warranty. * // * * // ************************************************************************* // // // FACILITY: // // Managed Object support routines // // // ABSTRACT: // // This module contains global definitions for the // Managed Object support routines. // // // AUTHOR: // // Barry Kierstein Hewlett Packard // // // X-1 BK Barry Kierstein 30-Sep-2005 // Initial version. // */ /* // Include files */ #ifndef MGT_DEBUG_SETTINGS #ifdef __VMS #ifdef __ALPHA #ifndef MGT_NATIVE_INT64 #define MGT_NATIVE_INT64 #endif #ifndef MGT_CALLS_64_BIT #define MGT_CALLS_64_BIT #endif #endif /* #ifdef __ALPHA */ #else /* #ifdef __VMS */ #ifndef MGT_NATIVE_INT64 #define MGT_NATIVE_INT64 #endif #ifndef MGT_CALLS_64_BIT #define MGT_CALLS_64_BIT #endif #endif /* #ifdef __VMS */ #endif /* #ifndef MGT_DEBUG_SETTINGS */ /* // Definitions */ #ifndef NULL #define NULL (void *)0 #endif #ifndef FALSE #define FALSE (0==1) #endif #ifndef TRUE #define TRUE (0==0) #endif #ifdef MGT_NATIVE_INT64 #ifdef MGT_DEBUG_SETTINGS #pragma message ("MGT_NATIVE_INT64 is set") #endif #define NUINT unsigned __int64 #define NINT __int64 #else #ifdef MGT_DEBUG_SETTINGS #pragma message ("MGT_NATIVE_INT64 is not set") #endif #define NUINT unsigned int #define NINT int #endif /* // //// Managed Object registration definitions and routines section // // This section defines the items needed for the various registration // routines needed to register a Managed Object with the system. */ /* // Function prototypes */ int MGT$Register_me (char *pMO_obj_name, /* MO object name */ int MO_minor_obj_num, /* MO object minor ver */ int MO_major_obj_num, /* MO object major ver */ int (*pMO$MGT_action)(), /* MO action routine */ int (**pRM$MGT_action)(), /* RM action routine */ int *MO_handle_return, /* RM/MO handles */ NINT MO_context /* MO context value */ ); /* // //// Integer compression definition and routine section // // This section defines the items needed for the integer-based // compression routines. It is basically a subset of the general // compression routines in another section. */ /* Error statuses */ /* These are less or equal to zero to enable */ /* positive numbers to be a number of bytes. */ #define MGT$ICOMP_STS_SUCCESS 0 /* Success */ #define MGT$ICOMP_STS_INV_PARAM -1 /* Invalid parameter */ #define MGT$ICOMP_STS_INV_BUFFER_ADDR -2 /* Invalid buffer address */ #define MGT$ICOMP_STS_AT_END_OF_BUFFER -3 /* Output buffer overflow */ #define MGT$ICOMP_STS_INV_BUFFER_CONTENTS -4 /* Contents invalid during get */ /* // Structure declarations */ typedef struct _MGT$ICompContext { NUINT tempBuffer[2]; NUINT *pInOutBuffer[2]; int readingBuffer[2]; int bufferLen[2]; int atEndOfBuffer[2]; int bytePos[2]; int origBytes[2]; int compBytes[2]; int bufferBytes[2]; int bufferUnitLength; /* Doesn't need a save context */ } MGT$ICompContext; /* // Macro definitions */ #define MGT$ICOMP_GET_COMP_BYTES(MGT$ICompContext) \ (MGT$ICompContext->compBytes[0]) #define MGT$ICOMP_GET_ORIG_BYTES(MGT$ICompContext) \ (MGT$ICompContext->origBytes[0]) #define MGT$ICOMP_GET_BUFFER_POS(MGT$ICompContext) \ ((char *)(MGT$ICompContext->pInOutBuffer[0])+ \ (MGT$ICompContext->bytePos[0]) \ ) #define MGT$ICOMP_GET_BUFFER_BYTES_USED(MGT$ICompContext) \ (MGT$ICompContext->bufferBytes[0]) #define MGT$ICOMP_SUCCESS(status) \ ((status == MGT$ICOMP_STS_SUCCESS) \ ) /* List all "success" statuses. Shouldn't */ /* be very many. */ /* // Functional prototypes */ /* MGT$ICompInitAddContext // // FUNCTIONAL DESCRIPTION: // // This routine initializes an integer compression // context. This is used when starting to compress // integers into an output buffer. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // Arg2 Output buffer address. This is assumed to be // on an NUINT/NINT boundary. // Arg3 Output buffer length. This will be rounded // down to the size of an integral number of Arg4. // Arg4 Size of the unit length for the buffer length. // This must be a multiple of the size of a NUINT. // // IMPLICIT INPUTS: // // OUTPUTS: // // Return MGT$ICOMP_STS_SUCCESS // MGT$ICOMP_STS_INV_PARAM Invalid bufferUnitLength // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // // */ int MGT$ICompInitAddContext (MGT$ICompContext *pMGT$ICompContext, void *pOutputBuffer, int outputBufferLen, int bufferUnitLength ); /* MGT$ICompInitGetContext // // FUNCTIONAL DESCRIPTION: // // This routine initializes an integer compression // context. This is used when retrieving integer // values from an input buffer. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // Arg2 Output buffer address. This is assumed to be // on an NUINT/NINT boundary. // Arg3 Output buffer length. This will be rounded // up to the size of an integral number of NUINTs/NINTs. // // IMPLICIT INPUTS: // // OUTPUTS: // // Return MGT$ICOMP_STS_SUCCESS // MGT$ICOMP_STS_INV_PARAM Invalid bufferUnitLength // MGT$ICOMP_STS_INV_BUFFER_ADDR Invalid pOutputBuffer address // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // // */ int MGT$ICompInitGetContext (MGT$ICompContext *pMGT$ICompContext, void *pOutputBuffer, int outputBufferLen, int bufferUnitLength ); /* MGT$ICompIAddValues // // FUNCTIONAL DESCRIPTION: // // This routine adds signed integer values to the output // buffer. This should be called after MGT$ICompInitAddContext. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // Arg2 Address of signed integer value(s) to add. // Adding multiple integers assumes that the // integers are in consecutive addresses // (e.g. an array or adjacent fields in a struct) // Arg3 Length of signed integer(s) // Arg4 Number of signed integer(s) to add // // IMPLICIT INPUTS: // // OUTPUTS: // // Return Successful completion Number of bytes used in the output buffer // Unsuccessful completion MGT$ICOMP_STS_INV_PARAM, invalid unit length parameter // MGT$ICOMP_STS_INV_BUFFER_ADDR, address not NINT aligned // MGT$ICOMP_STS_AT_END_OF_BUFFER, output buffer overflow // // Note: MGT$ICOMP_STS_AT_END_OF_BUFFER return status // This indicates that the output buffer is full and that it // is possible that the end of the output buffer might contain // a compressed integer that is incomplete. It is recommended // that the caller save a "last good known buffer position" that // makes sense (e.g. last compressed integer, last good "record" // of data, etc). // So that the caller doesn't have to check the status at every // call, once the buffer is full, the routine will safely keep // returning the buffer overflow status. // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // // */ int MGT$ICompIAddValues (MGT$ICompContext *pMGT$ICompContext, void *pValueAddr, int unitLen, int numUnits ); /* MGT$ICompUIAddValues // // FUNCTIONAL DESCRIPTION: // // This routine adds unsigned integer values to the output // buffer. This should be called after MGT$ICompInitAddContext. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // Arg2 Address of unsigned integer value(s) to add. // Adding multiple integers assumes that the // integers are in consecutive addresses // (e.g. an array or adjacent fields in a struct) // Arg3 Length of unsigned integer(s) // Arg4 Number of unsigned integer(s) to add // // IMPLICIT INPUTS: // // OUTPUTS: // // Return Successful completion Number of bytes used in the output buffer // Unsuccessful completion MGT$ICOMP_STS_INV_PARAM, invalid unit length parameter // MGT$ICOMP_STS_INV_BUFFER_ADDR, address not NUINT aligned // MGT$ICOMP_STS_AT_END_OF_BUFFER, output buffer overflow // // Note: MGT$ICOMP_STS_AT_END_OF_BUFFER return status // This indicates that the output buffer is full and that it // is possible that the end of the output buffer might contain // a compressed integer that is incomplete. It is recommended // that the caller save a "last good known buffer position" that // makes sense (e.g. last compressed integer, last good "record" // of data, etc). // So that the caller doesn't have to check the status at every // call, once the buffer is full, the routine will safely keep // returning the buffer overflow status. // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // // */ int MGT$ICompUIAddValues (MGT$ICompContext *pMGT$ICompContext, void *pValueAddr, int unitLen, int numUnits ); /* MGT$ICompIGetValues // // FUNCTIONAL DESCRIPTION: // // This routine retrieves signed integer values from the // input buffer. This should be called after MGT$ICompInitGetContext. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // Arg2 Address of signed integer value(s) for destination. // Retrieving multiple integers assumes that the // integers are in consecutive addresses // (e.g. an array or adjacent fields in a struct) // Arg3 Length of signed integer(s) // Arg4 Number of signed integer(s) for destination // // IMPLICIT INPUTS: // // OUTPUTS: // // Return MGT$ICOMP* return status // MGT$ICOMP_STS_SUCCESS // MGT$ICOMP_STS_INV_PARAM, invalid unit length parameter // MGT$ICOMP_STS_INV_BUFFER_ADDR, address not NUINT aligned // MGT$ICOMP_STS_AT_END_OF_BUFFER, at end of input buffer // MGT$ICOMP_STS_INV_BUFFER_CONTENTS, error interpreting buffer contents // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // // */ int MGT$ICompIGetValues (MGT$ICompContext *pMGT$ICompContext, void *pValueAddr, int unitLen, int numUnits ); /* MGT$ICompUIGetValues // // FUNCTIONAL DESCRIPTION: // // This routine retrieves unsigned integer values from the // input buffer. This should be called after MGT$ICompInitGetContext. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // Arg2 Address of unsigned integer value(s) for destination. // Retrieving multiple integers assumes that the // integers are in consecutive addresses // (e.g. an array or adjacent fields in a struct) // Arg3 Length of unsigned integer(s) // Arg4 Number of unsigned integer(s) for destination // // IMPLICIT INPUTS: // // OUTPUTS: // // Return MGT$ICOMP* return status // MGT$ICOMP_STS_SUCCESS // MGT$ICOMP_STS_INV_PARAM, invalid unit length parameter // MGT$ICOMP_STS_INV_BUFFER_ADDR, address not NUINT aligned // MGT$ICOMP_STS_AT_END_OF_BUFFER, at end of input buffer // MGT$ICOMP_STS_INV_BUFFER_CONTENTS, error interpreting buffer contents // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // // */ int MGT$ICompUIGetValues (MGT$ICompContext *pMGT$ICompContext, void *pValueAddr, int unitLen, int numUnits ); /* MGT$ICompSaveState // // FUNCTIONAL DESCRIPTION: // // This routine saves the current state of the context. // This is useful for recording a safe place to roll back // to if the next operations could overflow the output // buffer. Use in conjunction with MGT$ICompRestoreState. // This should be called after MGT$ICompInitAddContext/ // MGT$ICompInitGetContext and MGT$ICompUIAddValues/ // MGT$ICompIAddValues. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // // IMPLICIT INPUTS: // // OUTPUTS: // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // */ void MGT$ICompSaveState (MGT$ICompContext *pMGT$ICompContext ); /* MGT$ICompRestoreState // // FUNCTIONAL DESCRIPTION: // // This routine restores the previously saved state of the context. // This is useful for rolling back to a safe place if the // output buffer has overflowed. Use in conjunction with // MGT$ICompSaveState. // This should be called after MGT$ICompInitAddContext/ // MGT$ICompInitGetContext and MGT$ICompUIAddValues/ // MGT$ICompIAddValues. // // Note: When the context is initialized, the saved // context is set so that any further integer // compressions done will return the // MGT$ICOMP_STS_INV_BUFFER_ADDR status. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // // IMPLICIT INPUTS: // // OUTPUTS: // // IMPLICIT OUTPUTS: // // SIDE EFFECTS: // */ void MGT$ICompRestoreState (MGT$ICompContext *pMGT$ICompContext ); /* MGT$ICompFinishComp // // FUNCTIONAL DESCRIPTION: // // This routine does whatever is necessary to make sure // the output buffer has all the compressed data, and any // other needed cleanup or processing. This should be // called after MGT$ICompInitAddContext/MGT$ICompInitGetContext // and MGT$ICompUIAddValues/MGT$ICompIAddValues. // // ENVIRONMNET: // // Safe for kernel-mode, no C RTL included. // // INPUTS: // // Arg1 Integer compression context address // // IMPLICIT INPUTS: // // OUTPUTS: // // Return Number of bytes used in the output buffer // // IMPLICIT OUTPUTS: // // Output buffer position in the compression context // is updated to be the first quadword aligned address // after the last compressed byte. // // SIDE EFFECTS: // */ int MGT$ICompFinishComp (MGT$ICompContext *pMGT$ICompContext );