phymod_sim.c (1359B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 */ 7 8 #include <phymod/phymod_sim.h> 9 10 int 11 phymod_sim_init(phymod_sim_t *pms, int num_ent, phymod_sim_entry_t *ent) 12 { 13 if (pms == NULL || pms->drv == NULL || pms->drv->init == NULL) { 14 return PHYMOD_E_INIT; 15 } 16 return pms->drv->init(&pms->data, num_ent, ent); 17 } 18 19 int 20 phymod_sim_reset(phymod_sim_t *pms) 21 { 22 if (pms == NULL || pms->drv == NULL || pms->drv->reset == NULL) { 23 return PHYMOD_E_INIT; 24 } 25 return pms->drv->reset(&pms->data); 26 } 27 28 int 29 phymod_sim_read(phymod_sim_t *pms, uint32_t addr, uint32_t *data) 30 { 31 if (pms == NULL || pms->drv == NULL || pms->drv->read == NULL) { 32 return PHYMOD_E_INIT; 33 } 34 return pms->drv->read(&pms->data, addr, data); 35 } 36 37 int 38 phymod_sim_write(phymod_sim_t *pms, uint32_t addr, uint32_t data) 39 { 40 if (pms == NULL || pms->drv == NULL || pms->drv->write == NULL) { 41 return PHYMOD_E_INIT; 42 } 43 return pms->drv->write(&pms->data, addr, data); 44 } 45 46 int 47 phymod_sim_event(phymod_sim_t *pms, phymod_sim_event_t event) 48 { 49 if (pms == NULL || pms->drv == NULL || pms->drv->event == NULL) { 50 return PHYMOD_E_INIT; 51 } 52 return pms->drv->event(&pms->data, event); 53 }