Changeset 18191 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Mar 24, 2009 2:39:36 PM (16 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r18169 r18191 136 136 static void supdrvLdrFree(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage); 137 137 static int supdrvIOCtl_CallServiceModule(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPCALLSERVICE pReq); 138 static int supdrvIOCtl_LoggerSettings(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLOGGERSETTINGS pReq); 138 139 static SUPGIPMODE supdrvGipDeterminTscMode(PSUPDRVDEVEXT pDevExt); 139 140 #ifdef RT_OS_WINDOWS … … 1514 1515 } 1515 1516 1517 case SUP_CTL_CODE_NO_SIZE(SUP_IOCTL_LOGGER_SETTINGS(0)): 1518 { 1519 /* validate */ 1520 PSUPLOGGERSETTINGS pReq = (PSUPLOGGERSETTINGS)pReqHdr; 1521 uint32_t cbStrTab; 1522 REQ_CHECK_SIZE_OUT(SUP_IOCTL_LOGGER_SETTINGS, SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT); 1523 REQ_CHECK_EXPR(SUP_IOCTL_LOGGER_SETTINGS, pReq->Hdr.cbIn >= SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(1)); 1524 cbStrTab = pReq->Hdr.cbIn - SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(0); 1525 REQ_CHECK_EXPR(SUP_IOCTL_LOGGER_SETTINGS, pReq->u.In.offGroups < cbStrTab); 1526 REQ_CHECK_EXPR(SUP_IOCTL_LOGGER_SETTINGS, pReq->u.In.offFlags < cbStrTab); 1527 REQ_CHECK_EXPR(SUP_IOCTL_LOGGER_SETTINGS, pReq->u.In.offDestination < cbStrTab); 1528 REQ_CHECK_EXPR_FMT(pReq->u.In.szStrings[cbStrTab - 1] == '\0', 1529 ("SUP_IOCTL_LOGGER_SETTINGS: cbIn=%#x cbStrTab=%#x LastChar=%d\n", 1530 pReq->Hdr.cbIn, cbStrTab, pReq->u.In.szStrings[cbStrTab - 1])); 1531 REQ_CHECK_EXPR(SUP_IOCTL_LOGGER_SETTINGS, pReq->u.In.fWhich <= SUPLOGGERSETTINGS_WHICH_RELEASE); 1532 REQ_CHECK_EXPR(SUP_IOCTL_LOGGER_SETTINGS, pReq->u.In.fWhat <= SUPLOGGERSETTINGS_WHAT_DESTROY); 1533 1534 /* execute */ 1535 pReq->Hdr.rc = supdrvIOCtl_LoggerSettings(pDevExt, pSession, pReq); 1536 return 0; 1537 } 1538 1516 1539 default: 1517 1540 Log(("Unknown IOCTL %#lx\n", (long)uIOCtl)); … … 4035 4058 4036 4059 /** 4060 * Implements the logger settings request. 4061 * 4062 * @returns VBox status code. 4063 * @param pDevExt The device extension. 4064 * @param pSession The caller's session. 4065 * @param pReq The request. 4066 */ 4067 static int supdrvIOCtl_LoggerSettings(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPLOGGERSETTINGS pReq) 4068 { 4069 const char *pszGroup = &pReq->u.In.szStrings[pReq->u.In.offGroups]; 4070 const char *pszFlags = &pReq->u.In.szStrings[pReq->u.In.offFlags]; 4071 const char *pszDest = &pReq->u.In.szStrings[pReq->u.In.offDestination]; 4072 PRTLOGGER pLogger = NULL; 4073 int rc; 4074 4075 /* 4076 * Some further validation. 4077 */ 4078 switch (pReq->u.In.fWhat) 4079 { 4080 case SUPLOGGERSETTINGS_WHAT_SETTINGS: 4081 case SUPLOGGERSETTINGS_WHAT_CREATE: 4082 break; 4083 4084 case SUPLOGGERSETTINGS_WHAT_DESTROY: 4085 if (*pszGroup || *pszFlags || *pszDest) 4086 return VERR_INVALID_PARAMETER; 4087 if (pReq->u.In.fWhich == SUPLOGGERSETTINGS_WHICH_RELEASE) 4088 return VERR_ACCESS_DENIED; 4089 break; 4090 4091 default: 4092 return VERR_INTERNAL_ERROR; 4093 } 4094 4095 /* 4096 * Get the logger. 4097 */ 4098 switch (pReq->u.In.fWhich) 4099 { 4100 case SUPLOGGERSETTINGS_WHICH_DEBUG: 4101 pLogger = RTLogGetDefaultInstance(); 4102 break; 4103 4104 case SUPLOGGERSETTINGS_WHICH_RELEASE: 4105 pLogger = RTLogRelDefaultInstance(); 4106 break; 4107 4108 default: 4109 return VERR_INTERNAL_ERROR; 4110 } 4111 4112 /* 4113 * Do the job. 4114 */ 4115 switch (pReq->u.In.fWhat) 4116 { 4117 case SUPLOGGERSETTINGS_WHAT_SETTINGS: 4118 if (pLogger) 4119 { 4120 rc = RTLogFlags(pLogger, pszFlags); 4121 if (RT_SUCCESS(rc)) 4122 rc = RTLogGroupSettings(pLogger, pszGroup); 4123 NOREF(pszDest); 4124 } 4125 else 4126 rc = VERR_NOT_FOUND; 4127 break; 4128 4129 case SUPLOGGERSETTINGS_WHAT_CREATE: 4130 { 4131 if (pLogger) 4132 rc = VERR_ALREADY_EXISTS; 4133 else 4134 { 4135 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 4136 4137 rc = RTLogCreate(&pLogger, 4138 0 /* fFlags */, 4139 pszGroup, 4140 pReq->u.In.fWhich == SUPLOGGERSETTINGS_WHICH_DEBUG 4141 ? "VBOX_LOG" 4142 : "VBOX_RELEASE_LOG", 4143 RT_ELEMENTS(s_apszGroups), 4144 s_apszGroups, 4145 RTLOGDEST_STDOUT | RTLOGDEST_DEBUGGER, 4146 NULL); 4147 if (RT_SUCCESS(rc)) 4148 { 4149 rc = RTLogFlags(pLogger, pszFlags); 4150 NOREF(pszDest); 4151 if (RT_SUCCESS(rc)) 4152 { 4153 switch (pReq->u.In.fWhich) 4154 { 4155 case SUPLOGGERSETTINGS_WHICH_DEBUG: 4156 pLogger = RTLogSetDefaultInstance(pLogger); 4157 break; 4158 case SUPLOGGERSETTINGS_WHICH_RELEASE: 4159 pLogger = RTLogRelSetDefaultInstance(pLogger); 4160 break; 4161 } 4162 } 4163 RTLogDestroy(pLogger); 4164 } 4165 } 4166 break; 4167 } 4168 4169 case SUPLOGGERSETTINGS_WHAT_DESTROY: 4170 switch (pReq->u.In.fWhich) 4171 { 4172 case SUPLOGGERSETTINGS_WHICH_DEBUG: 4173 pLogger = RTLogSetDefaultInstance(NULL); 4174 break; 4175 case SUPLOGGERSETTINGS_WHICH_RELEASE: 4176 pLogger = RTLogRelSetDefaultInstance(NULL); 4177 break; 4178 } 4179 rc = RTLogDestroy(pLogger); 4180 break; 4181 4182 default: 4183 { 4184 rc = VERR_INTERNAL_ERROR; 4185 break; 4186 } 4187 } 4188 4189 return rc; 4190 } 4191 4192 4193 /** 4037 4194 * Gets the paging mode of the current CPU. 4038 4195 * -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r15838 r18191 904 904 * @{ 905 905 */ 906 #define SUP_IOCTL_PAGE_ALLOC_EX SUP_CTL_CODE_BIG(23)907 #define SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOCEX, u.Out.aPages[cPages])908 #define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOCEX, u.In))909 #define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages)906 #define SUP_IOCTL_PAGE_ALLOC_EX SUP_CTL_CODE_BIG(23) 907 #define SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOCEX, u.Out.aPages[cPages]) 908 #define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOCEX, u.In)) 909 #define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) 910 910 typedef struct SUPPAGEALLOCEX 911 911 { … … 952 952 * @{ 953 953 */ 954 #define SUP_IOCTL_PAGE_MAP_KERNEL SUP_CTL_CODE_SIZE(24, SUP_IOCTL_PAGE_MAP_KERNEL_SIZE)955 #define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE sizeof(SUPPAGEMAPKERNEL)956 #define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_IN sizeof(SUPPAGEMAPKERNEL)957 #define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_OUT sizeof(SUPPAGEMAPKERNEL)954 #define SUP_IOCTL_PAGE_MAP_KERNEL SUP_CTL_CODE_SIZE(24, SUP_IOCTL_PAGE_MAP_KERNEL_SIZE) 955 #define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE sizeof(SUPPAGEMAPKERNEL) 956 #define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_IN sizeof(SUPPAGEMAPKERNEL) 957 #define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_OUT sizeof(SUPPAGEMAPKERNEL) 958 958 typedef struct SUPPAGEMAPKERNEL 959 959 { … … 983 983 984 984 985 /** @name SUP_IOCTL_LOGGER_SETTINGS 986 * Changes the ring-0 release or debug logger settings. 987 * @{ 988 */ 989 #define SUP_IOCTL_LOGGER_SETTINGS(cbStrTab) SUP_CTL_CODE_SIZE(25, SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab)) 990 #define SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab]) 991 #define SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab]) 992 #define SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT sizeof(SUPREQHDR) 993 typedef struct SUPLOGGERSETTINGS 994 { 995 /** The header. */ 996 SUPREQHDR Hdr; 997 union 998 { 999 struct 1000 { 1001 /** Which logger. */ 1002 uint32_t fWhich; 1003 /** What to do with it. */ 1004 uint32_t fWhat; 1005 /** Offset of the flags setting string. */ 1006 uint32_t offFlags; 1007 /** Offset of the groups setting string. */ 1008 uint32_t offGroups; 1009 /** Offset of the destination setting string. */ 1010 uint32_t offDestination; 1011 /** The string table. */ 1012 char szStrings[1]; 1013 } In; 1014 } u; 1015 } SUPLOGGERSETTINGS, *PSUPLOGGERSETTINGS; 1016 1017 /** Debug logger. */ 1018 #define SUPLOGGERSETTINGS_WHICH_DEBUG 0 1019 /** Release logger. */ 1020 #define SUPLOGGERSETTINGS_WHICH_RELEASE 1 1021 1022 /** Change the settings. */ 1023 #define SUPLOGGERSETTINGS_WHAT_SETTINGS 0 1024 /** Create the logger instance. */ 1025 #define SUPLOGGERSETTINGS_WHAT_CREATE 1 1026 /** Destroy the logger instance. */ 1027 #define SUPLOGGERSETTINGS_WHAT_DESTROY 2 1028 1029 /** @} */ 1030 1031 985 1032 #pragma pack() /* paranoia */ 986 1033 -
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r18169 r18191 734 734 735 735 736 /** 737 * Worker for the SUPR3Logger* APIs. 738 * 739 * @returns VBox status code. 740 * @param enmWhich Which logger. 741 * @param fWhat What to do with the logger. 742 * @param pszFlags The flags settings. 743 * @param pszGroups The groups settings. 744 * @param pszDest The destionation specificier. 745 */ 746 static int supR3LoggerSettings(SUPLOGGER enmWhich, uint32_t fWhat, const char *pszFlags, const char *pszGroups, const char *pszDest) 747 { 748 size_t const cchFlags = pszFlags ? strlen(pszFlags) : 0; 749 size_t const cchGroups = pszGroups ? strlen(pszGroups) : 0; 750 size_t const cchDest = pszDest ? strlen(pszDest) : 0; 751 size_t const cbStrTab = cchFlags + !!cchFlags 752 + cchGroups + !!cchGroups 753 + cchDest + !!cchDest 754 + (!cchFlags && !cchGroups && !cchDest); 755 756 PSUPLOGGERSETTINGS pReq = (PSUPLOGGERSETTINGS)alloca(SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab)); 757 pReq->Hdr.u32Cookie = g_u32Cookie; 758 pReq->Hdr.u32SessionCookie = g_u32SessionCookie; 759 pReq->Hdr.cbIn = SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(cbStrTab); 760 pReq->Hdr.cbOut = SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT; 761 pReq->Hdr.fFlags= SUPREQHDR_FLAGS_DEFAULT; 762 pReq->Hdr.rc = VERR_INTERNAL_ERROR; 763 switch (enmWhich) 764 { 765 case SUPLOGGER_DEBUG: pReq->u.In.fWhich = SUPLOGGERSETTINGS_WHICH_DEBUG; break; 766 case SUPLOGGER_RELEASE: pReq->u.In.fWhich = SUPLOGGERSETTINGS_WHICH_RELEASE; break; 767 default: 768 return VERR_INVALID_PARAMETER; 769 } 770 pReq->u.In.fWhat = fWhat; 771 772 uint32_t off = 0; 773 if (cchFlags) 774 { 775 pReq->u.In.offFlags = off; 776 memcpy(&pReq->u.In.szStrings[off], pszFlags, cchFlags + 1); 777 off += cchFlags + 1; 778 } 779 else 780 pReq->u.In.offFlags = cbStrTab - 1; 781 782 if (cchGroups) 783 { 784 pReq->u.In.offGroups = off; 785 memcpy(&pReq->u.In.szStrings[off], pszGroups, cchGroups + 1); 786 off += cchGroups + 1; 787 } 788 else 789 pReq->u.In.offGroups = cbStrTab - 1; 790 791 if (cchDest) 792 { 793 pReq->u.In.offDestination = off; 794 memcpy(&pReq->u.In.szStrings[off], pszDest, cchDest + 1); 795 off += cchDest + 1; 796 } 797 else 798 pReq->u.In.offDestination = cbStrTab - 1; 799 800 if (!off) 801 { 802 pReq->u.In.szStrings[0] = '\0'; 803 off++; 804 } 805 Assert(off == cbStrTab); 806 Assert(pReq->u.In.szStrings[cbStrTab - 1] == '\0'); 807 808 809 int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_LOGGER_SETTINGS(cbStrTab), pReq, SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab)); 810 if (RT_SUCCESS(rc)) 811 rc = pReq->Hdr.rc; 812 return rc; 813 } 814 815 816 SUPR3DECL(int) SUPR3LoggerSettings(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest) 817 { 818 return supR3LoggerSettings(enmWhich, SUPLOGGERSETTINGS_WHAT_SETTINGS, pszFlags, pszGroups, pszDest); 819 } 820 821 822 SUPR3DECL(int) SUPR3LoggerCreate(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest) 823 { 824 return supR3LoggerSettings(enmWhich, SUPLOGGERSETTINGS_WHAT_CREATE, pszFlags, pszGroups, pszDest); 825 } 826 827 828 SUPR3DECL(int) SUPR3LoggerDestroy(SUPLOGGER enmWhich) 829 { 830 return supR3LoggerSettings(enmWhich, SUPLOGGERSETTINGS_WHAT_DESTROY, NULL, NULL, NULL); 831 } 832 833 736 834 SUPR3DECL(int) SUPPageAlloc(size_t cPages, void **ppvPages) 737 835 { -
trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk
r14515 r18191 34 34 PROGRAMS += \ 35 35 SUPInstall \ 36 SUPUninstall 36 SUPUninstall \ 37 SUPLoggerCtl 37 38 ifdef VBOX_WITH_TESTCASES 38 39 PROGRAMS += \ … … 54 55 SUPUninstall_SOURCES = SUPUninstall.cpp 55 56 SUPUninstall_LIBS = $(LIB_RUNTIME) 57 58 SUPLoggerCtl_TEMPLATE = VBOXR3EXE 59 SUPLoggerCtl_SOURCES = SUPLoggerCtl.cpp 60 SUPLoggerCtl_LIBS = $(LIB_RUNTIME) 56 61 57 62 tstInt_TEMPLATE = VBOXR3EXE
Note:
See TracChangeset
for help on using the changeset viewer.