Updated `README.md` with instructions for building/using the kernel module.
[xeon-phi-kernel-module] / include / mic / micscif_va_gen.h
CommitLineData
800f879a
AT
1/*
2 * Copyright 2010-2017 Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * Disclaimer: The codes contained in these modules may be specific to
14 * the Intel Software Development Platform codenamed Knights Ferry,
15 * and the Intel product codenamed Knights Corner, and are not backward
16 * compatible with other Intel products. Additionally, Intel will NOT
17 * support the codes or instruction set in future products.
18 *
19 * Intel offers no warranty of any kind regarding the code. This code is
20 * licensed on an "AS IS" basis and Intel is not obligated to provide
21 * any support, assistance, installation, training, or other services
22 * of any kind. Intel is also not obligated to provide any updates,
23 * enhancements or extensions. Intel specifically disclaims any warranty
24 * of merchantability, non-infringement, fitness for any particular
25 * purpose, and any other warranty.
26 *
27 * Further, Intel disclaims all liability of any kind, including but
28 * not limited to liability for infringement of any proprietary rights,
29 * relating to the use of the code, even if Intel is notified of the
30 * possibility of such liability. Except as expressly stated in an Intel
31 * license agreement provided with this code and agreed upon with Intel,
32 * no license, express or implied, by estoppel or otherwise, to any
33 * intellectual property rights is granted herein.
34 */
35
36/* generate a virtual address for a given size */
37
38#ifndef MICSCIF_VA_GEN_H
39#define MICSCIF_VA_GEN_H
40
41#include "micscif_va_node.h"
42
43/*
44 * To avoid collisions with user applications trying to use
45 * MAP_FIXED with scif_register(), the following window address space
46 * allocation scheme is used.
47 *
48 * 1) (0) - (2 ^ 62 - 1))
49 * Window Address Space that can be claimed using MAP_FIXED.
50 * 2) (2 ^ 62) - (2 ^ 63) - 1)
51 * Window address space used for allocations by the SCIF driver
52 * when MAP_FIXED is not passed.
53 */
54#define VA_GEN_MIN 0x4000000000000000
55#define VA_GEN_RANGE 0x3f00000000000000
56
57#define INVALID_VA_GEN_ADDRESS 0xff00000000000000
58#define INVALID_VA_PAGE_INDEX 0xff00000000000
59
60struct va_gen_addr {
61 struct va_node_allocator allocator;
62 uint32_t hole_list;
63 uint32_t claims_list;
64 uint64_t base;
65};
66
67/*
68 * return a base for the range
69 * caller trusted to keep track of both base and range
70 */
71uint64_t va_gen_alloc(struct va_gen_addr *addr,
72 uint64_t num_bytes, uint32_t align_bytes);
73
74/* Claim ownership of memory region. Fails if already occupied */
75uint64_t va_gen_claim(struct va_gen_addr *addr,
76 uint64_t address, uint64_t num_bytes);
77
78/* release ownership of a base/range */
79void va_gen_free(struct va_gen_addr *addr,
80 uint64_t address, uint64_t num_bytes);
81
82int va_gen_init(struct va_gen_addr *addr, uint64_t base, uint64_t range);
83
84void va_gen_destroy(struct va_gen_addr *addr);
85
86#endif