1/** 2 * \file 3 * \brief Driver for booting the Xeon Phi Coprocessor card on a Barrelfish Host 4 */ 5 6/* 7 * Copyright (c) 2014 ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14#ifndef XEON_PHI_SMPT_H 15#define XEON_PHI_SMPT_H 16 17#include <dev/xeon_phi/xeon_phi_smpt_dev.h> 18 19 20struct smpt_info { 21 xeon_phi_smpt_t smpt_register; 22 xeon_phi_smpt_entry_t entries[xeon_phi_smpt_system_page_num]; 23 lpaddr_t offsets[xeon_phi_smpt_system_page_num]; 24 uint8_t smpt_enabled; 25}; 26 27/** 28 * \brief Sets an entry in the system memory pagetable to a give address 29 * 30 * \param phi reference to the card structure 31 * \param slot pagetable entry to set 32 * \param address host address to set 33 * \param snooping enable snooping = 1, disable snooping = 0 34 * 35 * \return SYS_ERR_OK on success 36 */ 37void smpt_set_address(struct xeon_phi *phi, 38 uint8_t slot, 39 lpaddr_t address, 40 uint8_t snooping); 41 42/** 43 * \brief Sets an entry in the system memory pagetable 44 * 45 * \param phi reference to the card structure 46 * \param entry the entry to set 47 * \param e the information about the new entry to set 48 */ 49static inline void smpt_set_entry(struct xeon_phi *phi, 50 uint8_t slot, 51 xeon_phi_smpt_entry_t e) 52{ 53 assert(slot < xeon_phi_smpt_system_page_num); 54 55 xeon_phi_smpt_entry_wr(&phi->smpt->smpt_register, slot, e); 56 phi->smpt->entries[slot] = e; 57} 58 59/** 60 * \brief clears an entry in the system memory page table 61 * 62 * \param phi reference to the card 63 * \param entry entry number to clear 64 * 65 * \return SYS_ERR_OK on success 66 */ 67static inline void smpt_clear_entry(struct xeon_phi *phi, uint8_t slot) 68{ 69 assert(slot < xeon_phi_smpt_system_page_num); 70 71 xeon_phi_smpt_entry_wr(&phi->smpt->smpt_register, slot, 0x0); 72 phi->smpt->entries[slot] = 0x0; 73} 74 75/** 76 * \brief Resets the system memory page tables 77 */ 78void smpt_reset(struct xeon_phi *phi); 79 80/** 81 * \brief initializes the system memory page tables with a 82 * 1:1 mapping 83 * 84 * \return SYS_ERR_OK on success 85 */ 86errval_t smpt_init(struct xeon_phi *phi); 87 88/** 89 * \brief sets the entry of the SMPT for the Xeon Phi with given id 90 * 91 * \param phi the local Xeon Phi 92 * \param id ID of the other Xeon Phi 93 * \param addr the physical (host)address 94 * 95 * \returns 1 on SUCCESS 96 * 0 on attempt to set the own SMPT entry 97 */ 98uint8_t smpt_set_coprocessor_address(struct xeon_phi *phi, 99 uint8_t id, 100 lpaddr_t addr); 101 102/** 103 * \brief calculates the ID of the Xeon Phi based on the physical address 104 * 105 * \param phi the local Xeon Phi 106 * \param addr physical address to lookup 107 * 108 * \returns the ID of the Xeon Phi this memory address belogngs to 109 */ 110uint8_t smtp_get_xeon_phi_id_from_addr(struct xeon_phi *phi, 111 lpaddr_t addr); 112 113/** 114 * \brief calculates the base address of the Xeon Phi GDDR 115 * 116 * This function will return 0 if the ID is the local card. 117 * 118 * \param phi the local xeon phi 119 * \param id the xeon phi id of the other card 120 * 121 * \returns base address of GDDR (0 if local) 122 */ 123lpaddr_t smpt_get_coprocessor_address(struct xeon_phi *phi, 124 uint8_t id); 125 126 127/** 128 * \brief sets the offset into the system memory page where the card is mapped 129 * 130 * \param phi the local xeon phi 131 * \param id ID of the card 132 * \param offset the offest into the page 133 */ 134void smpt_set_coprocessor_offset(struct xeon_phi *phi, 135 uint8_t id, 136 lpaddr_t offset); 137#endif /* XEON_PHI_SMPT_H */ 138