1/****************************************************************************** 2 * Copyright (c) 2013 IBM Corporation 3 * All rights reserved. 4 * This program and the accompanying materials 5 * are made available under the terms of the BSD License 6 * which accompanies this distribution, and is available at 7 * http://www.opensource.org/licenses/bsd-license.php 8 * 9 * Contributors: 10 * IBM Corporation - initial implementation 11 *****************************************************************************/ 12 13/* 14 * libbcm Forth wrapper 15 */ 16 17#include <bcm57xx.h> 18 19// : bcm57xx-open ( -- false | [ driver true ] ) 20PRIM(BCM57XX_X2d_OPEN) 21{ 22 net_driver_t *net_driver = bcm57xx_open(); 23 if (net_driver) { 24 PUSH; 25 TOS.u = (unsigned long)net_driver; PUSH; 26 TOS.n = -1; 27 } else { 28 PUSH; 29 TOS.n = 0; 30 } 31} 32MIRP 33 34// : bcm57xx-close ( driver -- ) 35PRIM(BCM57XX_X2d_CLOSE) 36{ 37 net_driver_t *driver = TOS.a; POP; 38 bcm57xx_close(driver); 39} 40MIRP 41 42 43// : bcm57xx-read ( addr len -- actual ) 44PRIM(BCM57XX_X2d_READ) 45{ 46 int len = TOS.u; POP; 47 TOS.n = bcm57xx_read(TOS.a, len); 48} 49MIRP 50 51// : bcm57xx-write ( addr len -- actual ) 52PRIM(BCM57XX_X2d_WRITE) 53{ 54 int len = TOS.u; POP; 55 TOS.n = bcm57xx_write(TOS.a, len); 56} 57MIRP 58