VirtualBox

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

Last change on this file since 60009 was 59932, checked in by vboxsync, 9 years ago

bs3kit: Eliminate BS3_MSC64_FIXUP_HACK and the associated /TP (compile as C++) option as these aren't durable workarounds for the problem. Instead do quick COFF -> OMF conversion so we can better control what WLINK will do during link. This addresses a few other issues too, like dot-prefixed segment names and incorrect fixups (not using FLAT but, symbol segment as the reference frame).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: bs3-cmn-memory.h 59932 2016-03-04 16:01:18Z vboxsync $ */
2/** @file
3 * BS3Kit - Internal Memory Structures, Variables and Functions.
4 */
5
6/*
7 * Copyright (C) 2007-2015 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;
41extern BS3SLABCTLLOW BS3_DATA_NM(g_Bs3Mem4KLow);
42
43
44typedef union BS3SLABCTLUPPERTILED
45{
46 BS3SLABCTL Core;
47 uint32_t au32Alloc[(sizeof(BS3SLABCTL) + ((BS3_SEL_TILED_AREA_SIZE - _1M) / _4K / 8) ) / 4];
48} BS3SLABCTLUPPERTILED;
49extern BS3SLABCTLUPPERTILED BS3_DATA_NM(g_Bs3Mem4KUpperTiled);
50
51
52/** The number of chunk sizes used by the slab list arrays
53 * (g_aBs3LowSlabLists, g_aBs3UpperTiledSlabLists, more?). */
54#define BS3_MEM_SLAB_LIST_COUNT 6
55
56extern uint8_t const BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[12];
57extern uint16_t const BS3_DATA_NM(g_acbBs3SlabLists)[BS3_MEM_SLAB_LIST_COUNT];
58extern BS3SLABHEAD BS3_DATA_NM(g_aBs3LowSlabLists)[BS3_MEM_SLAB_LIST_COUNT];
59extern BS3SLABHEAD BS3_DATA_NM(g_aBs3UpperTiledSlabLists)[BS3_MEM_SLAB_LIST_COUNT];
60extern uint16_t const BS3_DATA_NM(g_cbBs3SlabCtlSizesforLists)[BS3_MEM_SLAB_LIST_COUNT];
61
62
63/**
64 * Translates a allocation request size to a slab list index.
65 *
66 * @returns Slab list index if small request, UINT8_MAX if large.
67 * @param cbRequest The number of bytes requested.
68 */
69DECLINLINE(uint8_t) bs3MemSizeToSlabListIndex(size_t cbRequest)
70{
71 if (cbRequest <= BS3_DATA_NM(g_acbBs3SlabLists)[BS3_MEM_SLAB_LIST_COUNT - 1])
72 {
73 unsigned idx = cbRequest ? ASMBitLastSetU16((uint16_t)(cbRequest - 1)) : 0;
74 return BS3_DATA_NM(g_aiBs3SlabListsByPowerOfTwo)[idx];
75 }
76 return UINT8_MAX;
77}
78
79
80RT_C_DECLS_END;
81
82#endif
83
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