astlpc.c (99b9d238bc163ffa82ecd0b704eb0489f4a86e32) | astlpc.c (400766f94322a00981b012e714734cab0ed52e68) |
---|---|
1/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 3#if HAVE_CONFIG_H 4#include "config.h" 5#endif 6 7#if HAVE_ENDIAN_H 8#include <endian.h> --- 22 unchanged lines hidden (view full) --- 31#include <unistd.h> 32#include <fcntl.h> 33#include <poll.h> 34#include <sys/ioctl.h> 35#include <sys/mman.h> 36#include <linux/aspeed-lpc-ctrl.h> 37 38/* kernel interface */ | 1/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 3#if HAVE_CONFIG_H 4#include "config.h" 5#endif 6 7#if HAVE_ENDIAN_H 8#include <endian.h> --- 22 unchanged lines hidden (view full) --- 31#include <unistd.h> 32#include <fcntl.h> 33#include <poll.h> 34#include <sys/ioctl.h> 35#include <sys/mman.h> 36#include <linux/aspeed-lpc-ctrl.h> 37 38/* kernel interface */ |
39static const char *kcs_path = "/dev/mctp0"; | |
40static const char *lpc_path = "/dev/aspeed-lpc-ctrl"; 41 42#endif 43 44enum mctp_astlpc_cmd { 45 cmd_initialise = 0x00, 46 cmd_tx_begin = 0x01, 47 cmd_rx_complete = 0x02, --- 1357 unchanged lines hidden (view full) --- 1405 astlpc->lpc_map = lpc_map_base + map.size - LPC_WIN_SIZE; 1406 } 1407 1408 close(fd); 1409 1410 return rc; 1411} 1412 | 39static const char *lpc_path = "/dev/aspeed-lpc-ctrl"; 40 41#endif 42 43enum mctp_astlpc_cmd { 44 cmd_initialise = 0x00, 45 cmd_tx_begin = 0x01, 46 cmd_rx_complete = 0x02, --- 1357 unchanged lines hidden (view full) --- 1404 astlpc->lpc_map = lpc_map_base + map.size - LPC_WIN_SIZE; 1405 } 1406 1407 close(fd); 1408 1409 return rc; 1410} 1411 |
1413static int mctp_astlpc_init_fileio_kcs(struct mctp_binding_astlpc *astlpc) | 1412static int mctp_astlpc_init_fileio_kcs(struct mctp_binding_astlpc *astlpc, 1413 const char *kcs_path) |
1414{ 1415 astlpc->kcs_fd = open(kcs_path, O_RDWR); 1416 if (astlpc->kcs_fd < 0) 1417 return -1; 1418 1419 return 0; 1420} 1421 --- 34 unchanged lines hidden (view full) --- 1456 release = astlpc->layout.rx.state == buffer_state_prepared || 1457 astlpc->layout.tx.state == buffer_state_prepared; 1458 1459 pollfd->events = release ? POLLOUT : POLLIN; 1460 1461 return 0; 1462} 1463 | 1414{ 1415 astlpc->kcs_fd = open(kcs_path, O_RDWR); 1416 if (astlpc->kcs_fd < 0) 1417 return -1; 1418 1419 return 0; 1420} 1421 --- 34 unchanged lines hidden (view full) --- 1456 release = astlpc->layout.rx.state == buffer_state_prepared || 1457 astlpc->layout.tx.state == buffer_state_prepared; 1458 1459 pollfd->events = release ? POLLOUT : POLLIN; 1460 1461 return 0; 1462} 1463 |
1464struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void) | 1464struct mctp_binding_astlpc *mctp_astlpc_init_fileio(const char *kcs_path) |
1465{ 1466 struct mctp_binding_astlpc *astlpc; 1467 int rc; 1468 1469 /* 1470 * If we're doing file IO then we're very likely not running 1471 * freestanding, so lets assume that we're on the BMC side. 1472 * --- 11 unchanged lines hidden (view full) --- 1484 astlpc->ops_data = astlpc; 1485 1486 rc = mctp_astlpc_init_fileio_lpc(astlpc); 1487 if (rc) { 1488 free(astlpc); 1489 return NULL; 1490 } 1491 | 1465{ 1466 struct mctp_binding_astlpc *astlpc; 1467 int rc; 1468 1469 /* 1470 * If we're doing file IO then we're very likely not running 1471 * freestanding, so lets assume that we're on the BMC side. 1472 * --- 11 unchanged lines hidden (view full) --- 1484 astlpc->ops_data = astlpc; 1485 1486 rc = mctp_astlpc_init_fileio_lpc(astlpc); 1487 if (rc) { 1488 free(astlpc); 1489 return NULL; 1490 } 1491 |
1492 rc = mctp_astlpc_init_fileio_kcs(astlpc); | 1492 rc = mctp_astlpc_init_fileio_kcs(astlpc, kcs_path); |
1493 if (rc) { 1494 free(astlpc); 1495 return NULL; 1496 } 1497 1498 return astlpc; 1499} 1500#else | 1493 if (rc) { 1494 free(astlpc); 1495 return NULL; 1496 } 1497 1498 return astlpc; 1499} 1500#else |
1501struct mctp_binding_astlpc *mctp_astlpc_init_fileio(void) | 1501struct mctp_binding_astlpc * 1502mctp_astlpc_init_fileio(const char *kcs_path __unused) |
1502{ 1503 mctp_prlog(MCTP_LOG_ERR, "%s: Missing support for file IO", __func__); 1504 return NULL; 1505} 1506 1507int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc __unused, 1508 struct pollfd *pollfd __unused) 1509{ 1510 mctp_prlog(MCTP_LOG_ERR, "%s: Missing support for file IO", __func__); 1511 return -1; 1512} 1513#endif | 1503{ 1504 mctp_prlog(MCTP_LOG_ERR, "%s: Missing support for file IO", __func__); 1505 return NULL; 1506} 1507 1508int mctp_astlpc_init_pollfd(struct mctp_binding_astlpc *astlpc __unused, 1509 struct pollfd *pollfd __unused) 1510{ 1511 mctp_prlog(MCTP_LOG_ERR, "%s: Missing support for file IO", __func__); 1512 return -1; 1513} 1514#endif |