VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-cmn-memory.h@ 66112

Last change on this file since 66112 was 62484, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: bs3-cmn-memory.h 62484 2016-07-22 18:35:33Z vboxsync $ */
2/** @file
3 * BS3Kit - Internal Memory Structures, Variables and Functions.
4 */
5
6/*
7 * Copyright (C) 2007-2016 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 ___bs3_cmn_memory_h
28#define ___bs3_cmn_memory_h
29
30#include "bs3kit.h"
31#include <iprt/asm.h>
32
33RT_C_DECLS_BEGIN;
34
35
36typedef union BS3SLABCTLLOW
37{
38 BS3SLABCTL Core;
39 uint32_t au32Alloc[(sizeof(BS3SLABCTL) + (0xA0000 / _4K / 8) ) / 4];
40} BS3SLABCTLLOW;
41#ifndef DOXYGEN_RUNNING
42# define g_Bs3Mem4KLow BS3_DATA_NM(g_Bs3Mem4KLow)
43#endif
44extern BS3SLABCTLLOW g_Bs3Mem4KLow;
45
46
47typedef union BS3SLABCTLUPPERTILED
48{
49 BS3SLABCTL Core;
50 uint32_t au32Alloc[(sizeof(BS3SLABCTL) + ((BS3_SEL_TILED_AREA_SIZE - _1M) / _4K / 8) ) / 4];
51} BS3SLABCTLUPPERTILED;
52#ifndef DOXYGEN_RUNNING
53# define g_Bs3Mem4KUpperTiled BS3_DATA_NM(g_Bs3Mem4KUpperTiled)
54#endif
55extern BS3SLABCTLUPPERTILED g_Bs3Mem4KUpperTiled;
56
57
58/** The number of chunk sizes used by the slab list arrays
59 * (g_aBs3LowSlabLists, g_aBs3UpperTiledSlabLists, more?). */
60#define BS3_MEM_SLAB_LIST_COUNT 6
61
62#ifndef DOXYGEN_RUNNING
63# define g_aiBs3SlabListsByPowerOfTwo BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)
64# define g_acbBs3SlabLists BS3_DATA_NM(g_acbBs3SlabLists)
65# define g_aBs3LowSlabLists BS3_DATA_NM(g_aBs3LowSlabLists)
66# define g_aBs3UpperTiledSlabLists BS3_DATA_NM(g_aBs3UpperTiledSlabLists)
67# define g_cbBs3SlabCtlSizesforLists BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)
68#endif
69extern uint8_t const g_aiBs3SlabListsByPowerOfTwo[12];
70extern uint16_t const g_acbBs3SlabLists[BS3_MEM_SLAB_LIST_COUNT];
71extern BS3SLABHEAD g_aBs3LowSlabLists[BS3_MEM_SLAB_LIST_COUNT];
72extern BS3SLABHEAD g_aBs3UpperTiledSlabLists[BS3_MEM_SLAB_LIST_COUNT];
73extern uint16_t const g_cbBs3SlabCtlSizesforLists[BS3_MEM_SLAB_LIST_COUNT];
74
75
76/**
77 * Translates a allocation request size to a slab list index.
78 *
79 * @returns Slab list index if small request, UINT8_MAX if large.
80 * @param cbRequest The number of bytes requested.
81 */
82DECLINLINE(uint8_t) bs3MemSizeToSlabListIndex(size_t cbRequest)
83{
84 if (cbRequest <= g_acbBs3SlabLists[BS3_MEM_SLAB_LIST_COUNT - 1])
85 {
86 unsigned idx = cbRequest ? ASMBitLastSetU16((uint16_t)(cbRequest - 1)) : 0;
87 return g_aiBs3SlabListsByPowerOfTwo[idx];
88 }
89 return UINT8_MAX;
90}
91
92
93RT_C_DECLS_END;
94
95#endif
96
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