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>
21 #include <xeon_phi/xeon_phi_manager_client.h>
22 #include <xeon_phi/xeon_phi_messaging.h>
27 #include "messaging.h"
28 #include "sysmem_caps.h"
30 volatile uint32_t bootstrap_done = 0;
34 struct xeon_phi_messaging_cb msg_cb = {
35 .open_iface = messaging_send_open,
36 .spawn = messaging_send_spawn
43 debug_printf("Xeon Phi host module started.\n");
45 uint32_t vendor_id, device_id;
46 uint32_t bus = PCI_DONT_CARE, dev = PCI_DONT_CARE, fun = PCI_DONT_CARE;
49 uint32_t parsed = sscanf(argv[argc-1], "%x:%x:%x:%x:%x",
50 &vendor_id, &device_id,
53 debug_printf("WARNING: parsing cmdline argument failed. >"
54 "Switching back to unknown PCI address [0,0,0]");
59 if (vendor_id != 0x8086 || ((device_id & 0xFFF0) != 0x2250)) {
60 debug_printf("ERROR: Unexpected vendor / device ID"
61 "was: [%x, %x] expected: [%x, %x]",
62 vendor_id, (device_id & 0xFF00), 0x8086, 0x2500);
65 debug_printf("WARNING: Initializing Xeon Phi with PCI address "
66 "[%u,%u,%u]\n", bus, dev, fun);
69 debug_printf("WARNING: Initializing Xeon Phi with unknown PCI address "
76 err = host_bootstrap();
77 if (err_is_fail(err)) {
78 USER_PANIC_ERR(err, "could not do the host bootstrap\n");
82 while (bootstrap_done == 0) {
83 messages_wait_and_handle_next();
86 err = service_init(&xphi);
87 if (err_is_fail(err)) {
88 USER_PANIC_ERR(err, "could not start the driver service\n");
93 err = xeon_phi_manager_client_register(xphi.iref, &xphi.id, &num, &irefs);
94 if (err_is_fail(err)) {
95 USER_PANIC_ERR(err, "could not register with the Xeon Phi manager\n");
98 xphi.state = XEON_PHI_STATE_NULL;
100 err = xeon_phi_init(&xphi, bus, dev, fun);
101 if (err_is_fail(err)) {
102 USER_PANIC_ERR(err, "could not do the card initialization\n");
105 err = xeon_phi_boot(&xphi, XEON_PHI_BOOTLOADER, XEON_PHI_MULTIBOOT);
106 if (err_is_fail(err)) {
107 USER_PANIC_ERR(err, "could not boot the card\n");
110 err = service_register(&xphi, irefs, num);
111 if (err_is_fail(err)) {
112 USER_PANIC_ERR(err, "could not register with the other drivers");
115 err = xeon_phi_messaging_service_init(&msg_cb);
116 if (err_is_fail(err)) {
117 USER_PANIC_ERR(err, "could not initialize the messaging service");
120 err = xeon_phi_messaging_service_start_phi(xphi.id);
121 if (err_is_fail(err)) {
122 USER_PANIC_ERR(err, "could not export the service");
125 service_start(&xphi);
127 debug_printf("Xeon Phi host module terminated.\n");