VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/solaris/alloc-r0drv-solaris.c@ 4072

Last change on this file since 4072 was 4071, checked in by vboxsync, 18 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1/* $Id: alloc-r0drv-solaris.c 4071 2007-08-07 17:07:59Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Memory Allocation, Ring-0 Driver, Solaris.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include "the-solaris-kernel.h"
23#include <malloc.h>
24
25#include <iprt/alloc.h>
26#include <iprt/assert.h>
27#include <iprt/types.h>
28#include "r0drv/alloc-r0drv.h"
29
30
31/**
32 * OS specific allocation function.
33 */
34PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
35{
36 Assert(cb != sizeof(void *));
37 PRTMEMHDR pHdr;
38 if (fFlags & RTMEMHDR_FLAG_ZEROED)
39 pHdr = (PRTMEMHDR)kmem_zalloc(cb + sizeof(*pHdr), KM_NOSLEEP);
40 else
41 pHdr = (PRTMEMHDR)kmem_alloc(cb + sizeof(*pHdr), KM_NOSLEEP);
42 if (pHdr)
43 {
44 pHdr->u32Magic = RTMEMHDR_MAGIC;
45 pHdr->fFlags = fFlags;
46 pHdr->cb = cb;
47 pHdr->u32Padding= 0;
48 }
49 else
50 printf("rmMemAlloc(%#x, %#x) failed\n", cb + sizeof(*pHdr), fFlags);
51 return pHdr;
52}
53
54
55/**
56 * OS specific free function.
57 */
58void rtMemFree(PRTMEMHDR pHdr)
59{
60 pHdr->u32Magic += 1;
61 kmem_free(pHdr, pHdr->cb + sizeof(*pHdr));
62}
63
64
65/**
66 * Allocates physical contiguous memory (below 4GB).
67 * The allocation is page aligned and the content is undefined.
68 *
69 * @returns Pointer to the memory block. This is page aligned.
70 * @param pPhys Where to store the physical address.
71 * @param cb The allocation size in bytes. This is always
72 * rounded up to PAGE_SIZE.
73 */
74RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb)
75{
76 /* Solaris currently supports allocating contiguous memory
77 * only for DMA drivers which requires passing the driver's
78 * device ID, and upper/lower DMA memory limits
79 * Currently thus disabled since RTMemContAlloc isn't really used
80 * anywhere significant yet (only in GuestAdditions which is not
81 * there for Solaris)
82 * ddi_umem_alloc doesn't allocate contiguous memory!
83 */
84 /**@todo Implement RTMemContAlloc on Solaris - there is no way around this. */
85 return NULL;
86}
87
88RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
89{
90 /** @todo implement RTMemContFree on solaris, see RTMemContAlloc() for details. */
91 NOREF(pv);
92 NOREF(cb);
93}
Note: See TracBrowser for help on using the repository browser.

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