2 * Copyright (c) 2014 ETH Zurich.
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
13 #include <xeon_phi/xeon_phi.h>
18 * Common setting values
21 /// the name of the Xeon Phi bootloader image
22 #define XEON_PHI_BOOTLOADER "/weever"
24 /// the name of the Xeon Phi multiboot image containint the modules
25 #define XEON_PHI_MULTIBOOT "/xeon_phi_multiboot"
27 /// if we use MSIX interrupts or legacy interrupts
28 #define XEON_PHI_MSIX_ENABLED 1
30 /// the number of MSIX interrupts we use
31 #define XEON_PHI_MSIX_NUM 1
33 #define XEON_PHI_APERTURE_INIT_SIZE (1024*1024*1024)
36 * This defines are used to reference the MMIO registers on the host side.
38 * The Mackerel Specifications use the SBOX or DBOX baseaddress as their
39 * register base. however the SBOX or DBOX have a certain offset into the
42 #define XEON_PHI_HOST_DBOX_OFFSET 0x00000000
43 #define XEON_PHI_HOST_SBOX_OFFSET 0x00010000
45 #define XEON_PHI_MMIO_TO_SBOX(phi) \
46 ((mackerel_addr_t)((lvaddr_t)(phi->mmio.vbase)+XEON_PHI_HOST_SBOX_OFFSET))
47 #define XEON_PHI_MMIO_TO_DBOX(phi) \
48 ((mackerel_addr_t)((lvaddr_t)(phi->mmio.vbase)+XEON_PHI_HOST_DBOX_OFFSET))
51 * --------------------------------------------------------------------------
52 * Xeon Phi Management structure
55 /// represents the state of the Xeon Phi
56 typedef enum xeon_phi_state
58 XEON_PHI_STATE_NULL, ///< The card has not yet been initialized
59 XEON_PHI_STATE_PCI_OK, ///< The card has been registered with PCI
60 XEON_PHI_STATE_RESET, ///< The card has been reset
61 XEON_PHI_STATE_READY, ///< The card is ready to load the os
62 XEON_PHI_STATE_BOOTING, ///< The card is in the booting state
63 XEON_PHI_STATE_ONLINE ///< the card has booted and is online
66 typedef enum xnode_state {
68 XNODE_STATE_REGISTERING,
73 /// represents the memory ranges occupied by the Xeon Phi card
76 lvaddr_t vbase; ///< virtual address of the mbar if mapped
77 lpaddr_t pbase; ///< physical address of the mbar
78 size_t length; ///< length of the mapped area
79 struct capref cap; ///< capability of the mbar
80 uint8_t bits; ///< size of the capability in bits
85 struct xeon_phi_binding *binding;
89 struct xeon_phi *local;
94 xeon_phi_state_t state;
95 struct mbar mmio; ///< pointer to the MMIO address range
96 struct mbar apt; ///< pointer to the aperture address range
98 lvaddr_t os_offset; ///< offset of the OS image into the aperture
99 uint32_t os_size; ///< the size of the OS image
100 char *cmdline; ///< pointer to the bootloader cmdline
101 uint32_t cmdlen; ///< the length of the cmd line
103 uint8_t id; ///< card id for identifying the card
105 uint32_t apicid; ///< APIC id used for sending the boot interrupt
108 struct xnode topology[XEON_PHI_NUM_MAX];
112 struct smpt_info *smpt; ///< pointer to the SMPT information struct
113 struct irq_info *irq; ///< pointer to the IRQ information struct
114 struct dma_info *dma; ///< pointer to the DMA information struct
115 struct msg_info *msg;
119 * \brief starts the serial receive thread
121 * \param phi pointer to the card information
123 errval_t xeon_phi_serial_start_recv_thread(struct xeon_phi *phi);
126 * \brief initializes the serial receiver
128 * \param phi pointer to the card information
130 errval_t xeon_phi_serial_init(struct xeon_phi *phi);
133 * \brief checks if there is a message waiting on the serial and reads
134 * it into the buffer.
136 * \return 0: There was no message
137 * 1: There was a message waiting and it porocessed.
139 uint32_t xeon_phi_serial_handle_recv(void);
142 * \brief boots the card with the given loader and multiboot image
144 * \param phi pointer to the card information
145 * \param xloader_img pointer to the card bootloader image
146 * \param multiboot_img pointer to the card multiboot image
148 errval_t xeon_phi_boot(struct xeon_phi *phi,
150 char *multiboot_img);
153 * \brief performs a soft reset of the card
155 * \param phi pointer to the card information
157 errval_t xeon_phi_reset(struct xeon_phi *phi);
160 * \brief initializes the coprocessor card
162 * \param phi pointer to the information structure
164 errval_t xeon_phi_init(struct xeon_phi *phi, uint32_t bus, uint32_t dev, uint32_t fun);
167 * \brief Bootstraps the host driver to get the multiboot images of the
168 * xeon phi loader and the xeon phi multiboot image
170 errval_t host_bootstrap(void);
174 * \brief maps the aperture memory range of the Xeon Phi into the drivers
175 * vspace to be able to load the coprocessor OS onto the card
177 * \param phi pointer to the Xeon Phi structure holding aperture information
178 * \param range how much bytes to map
180 * \returns SYS_ERR_OK on success
182 errval_t xeon_phi_map_aperture(struct xeon_phi *phi,
186 * \brief unmaps the previously mapped aperture range when the programming
189 * \param phi pointer to the Xeon Phi structure holiding mapping information
191 * \return SYS_ERR_OK on success
193 errval_t xeon_phi_unmap_aperture(struct xeon_phi *phi);
196 #endif /* XEON_PHI_H_ */