1 /******************************************************************************
2 * Copyright (c) 2013 IBM Corporation
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
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
14 * libveth Forth wrapper
19 // : libveth-open ( mac-addr-str len reg-str len -- false | [ driver true ] )
20 PRIM(LIBVETH_X2d_OPEN)
22 int reg_len = TOS.u; POP;
23 char *reg = TOS.a; POP;
25 char *mac_addr = TOS.a;
27 net_driver_t *net_driver = libveth_open(mac_addr, len, reg, reg_len);
29 TOS.u = (unsigned long)net_driver; PUSH;
36 // : libveth-close ( driver -- )
37 PRIM(LIBVETH_X2d_CLOSE)
39 net_driver_t *driver = TOS.a; POP;
40 libveth_close(driver);
45 // : libveth-read ( addr len driver -- actual )
46 PRIM(LIBVETH_X2d_READ)
48 net_driver_t *driver = TOS.a; POP;
50 TOS.n = libveth_read(TOS.a, len, driver);
54 // : libveth-write ( addr len driver -- actual )
55 PRIM(LIBVETH_X2d_WRITE)
57 net_driver_t *driver = TOS.a; POP;
59 TOS.n = libveth_write(TOS.a, len, driver);