📄 pcitcl.c
字号:
/* * Copyright (c) 2002 Picture Elements, Inc. * Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */#ident "$Id: pcitcl.c,v 1.3 2003/05/27 23:59:57 steve Exp $"# include <tcl.h># include <pcisim.h># include <stdlib.h>static int pci_reset(ClientData cd, Tcl_Interp*interp, int argc, char*argv[]){ unsigned active, recovery; if (argc != 3) { Tcl_SetResult(interp, "Usage: pci_reset <active> <recovery>", TCL_STATIC); return TCL_ERROR; } active = strtoul(argv[1],0,0); recovery = strtoul(argv[2],0,0); pcisim_reset(active, recovery); return TCL_OK;}static int pci_wait(ClientData cd, Tcl_Interp*interp, int argc, char*argv[]){ unsigned clks, enabl, res; char buf[64]; if (argc < 2) { Tcl_SetResult(interp, "Usage: pci_wait <clks> [<irq enable>]", TCL_STATIC); return TCL_ERROR; } clks = strtoul(argv[1],0,0); enabl= (argc > 2)? strtoul(argv[2],0,0) : 0; res = pcisim_wait(clks, enabl); sprintf(buf, "0x%x", res); Tcl_ResetResult(interp); Tcl_AppendElement(interp, buf); return TCL_OK;}static int pci_pokecl(ClientData cd, Tcl_Interp*interp, int argc, char*argv[]){ unsigned long addr, data; if (argc != 3) { Tcl_SetResult(interp, "Usage: pci_pokecl <addr> <data>", TCL_STATIC); return TCL_ERROR; } addr = strtoul(argv[1],0,0); data = strtoul(argv[2],0,0); pcisim_config_write(addr, data); return TCL_OK;}static int pci_peekcl(ClientData cd, Tcl_Interp*interp, int argc, char*argv[]){ int idx; Tcl_ResetResult(interp); for (idx = 1 ; idx < argc ; idx += 1) { unsigned long addr, data; char buf[64]; addr = strtoul(argv[idx],0,0); data = pcisim_config_read(addr); sprintf(buf, "0x%lx", data); Tcl_AppendElement(interp, buf); } return TCL_OK;}static int pci_pokeml(ClientData cd, Tcl_Interp*interp, int argc, char*argv[]){ unsigned long addr, data; int be = 0; if (argc != 3) { Tcl_SetResult(interp, "Usage: pci_pokeml <addr> <data>", TCL_STATIC); return TCL_ERROR; } addr = strtoul(argv[1],0,0); data = strtoul(argv[2],0,0); if (argc > 3) be = strtoul(argv[3],0,0); pcisim_writel_x(addr, data, be); return TCL_OK;}static int pci_peekml(ClientData cd, Tcl_Interp*interp, int argc, char*argv[]){ int idx; Tcl_ResetResult(interp); for (idx = 1 ; idx < argc ; idx += 1) { unsigned long addr, data; char buf[64]; addr = strtoul(argv[idx],0,0); data = pcisim_readl(addr); sprintf(buf, "0x%lx", data); Tcl_AppendElement(interp, buf); } return TCL_OK;}static void Pcitcl_Exit(ClientData xx){ pcisim_end_simulation();}int Pcitcl_Init(Tcl_Interp* interp){ pcisim_init(); Tcl_CreateExitHandler(Pcitcl_Exit, 0); Tcl_CreateCommand(interp, "pci_reset", pci_reset, 0, 0); Tcl_CreateCommand(interp, "pci_wait", pci_wait, 0, 0); Tcl_CreateCommand(interp, "pci_pokecl", pci_pokecl, 0, 0); Tcl_CreateCommand(interp, "pci_peekcl", pci_peekcl, 0, 0); Tcl_CreateCommand(interp, "pci_pokeml", pci_pokeml, 0, 0); Tcl_CreateCommand(interp, "pci_peekml", pci_peekml, 0, 0); Tcl_PkgProvide(interp, "pcitcl", "0.0"); return TCL_OK;}/* * $Log: pcitcl.c,v $ * Revision 1.3 2003/05/27 23:59:57 steve * Support explicit byte lane controls on write. * * Revision 1.2 2002/10/16 16:58:54 steve * License updates. * * Revision 1.1 2002/08/31 00:37:24 steve * Add the pcitcl.so tcl extension. * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -