3 * \brief Driver for booting the Xeon Phi Coprocessor card on a Barrelfish Host
7 * Copyright (c) 2014 ETH Zurich.
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.
17 #include <barrelfish/barrelfish.h>
22 #include <xeon_phi/xeon_phi_manager_client.h>
23 #include <xeon_phi/xeon_phi_messaging.h>
28 #include "messaging.h"
29 #include "sysmem_caps.h"
31 volatile uint32_t bootstrap_done = 0;
35 struct xeon_phi_messaging_cb msg_cb = {
36 .open_iface = messaging_send_open,
37 .spawn = messaging_send_spawn
44 debug_printf("Xeon Phi host module started.\n");
46 uint32_t vendor_id, device_id;
47 uint32_t bus = PCI_DONT_CARE, dev = PCI_DONT_CARE, fun = PCI_DONT_CARE;
50 uint32_t parsed = sscanf(argv[argc-1], "%x:%x:%x:%x:%x",
51 &vendor_id, &device_id,
54 debug_printf("WARNING: parsing cmdline argument failed. >"
55 "Switching back to unknown PCI address [0,0,0]");
60 if (vendor_id != 0x8086 || ((device_id & 0xFFF0) != 0x2250)) {
61 debug_printf("ERROR: Unexpected vendor / device ID"
62 "was: [%x, %x] expected: [%x, %x]",
63 vendor_id, (device_id & 0xFF00), 0x8086, 0x2500);
66 debug_printf("Initializing Xeon Phi with PCI address "
67 "[%u,%u,%u]\n", bus, dev, fun);
70 debug_printf("WARNING: Initializing Xeon Phi with unknown PCI address "
77 err = host_bootstrap();
78 if (err_is_fail(err)) {
79 USER_PANIC_ERR(err, "could not do the host bootstrap\n");
83 while (bootstrap_done == 0) {
84 messages_wait_and_handle_next();
90 err = service_init(&xphi);
91 if (err_is_fail(err)) {
92 USER_PANIC_ERR(err, "could not start the driver service\n");
97 err = xeon_phi_manager_client_register(xphi.iref, &xphi.id, &num, &irefs);
98 if (err_is_fail(err)) {
99 USER_PANIC_ERR(err, "could not register with the Xeon Phi manager\n");
102 xphi.state = XEON_PHI_STATE_NULL;
104 err = xeon_phi_init(&xphi, bus, dev, fun);
105 if (err_is_fail(err)) {
106 USER_PANIC_ERR(err, "could not do the card initialization\n");
109 err = xeon_phi_boot(&xphi, XEON_PHI_BOOTLOADER, XEON_PHI_MULTIBOOT);
110 if (err_is_fail(err)) {
111 USER_PANIC_ERR(err, "could not boot the card\n");
114 err = service_register(&xphi, irefs, num);
115 if (err_is_fail(err)) {
116 USER_PANIC_ERR(err, "could not register with the other drivers");
119 err = xeon_phi_messaging_service_init(&msg_cb);
120 if (err_is_fail(err)) {
121 USER_PANIC_ERR(err, "could not initialize the messaging service");
124 err = xeon_phi_messaging_service_start_phi(xphi.id);
125 if (err_is_fail(err)) {
126 USER_PANIC_ERR(err, "could not export the service");
129 service_start(&xphi);
131 debug_printf("Xeon Phi host module terminated.\n");