Files
chipsec-chipsec/source/tool/chipsec/utilcmd/mem_cmd.py
T
CHIPSEC ac2ca7264f 1. We have support for uefi variables on Windows and Linux but not
UEFI shell.
2.       Decompression of images in SPI flash parsing is only supported in
Windows.
3.	UEFI - Support for IA32 and i586 (Quark)
4.	Added capability to use modules from an arbitrary path with the -I
/ --import command line option
5.	Module functionality encapsulated in class inheriting BaseModule
6.	Fixed  loading platform specific configuration
7.	Fixed issue with modules which run on multiple logical CPUs
hanging on Bay Trail (Windows/Linux). The issue still exist when running
from UEFI shell
8.	Added template for a module - module_template.py
9.	Added options to flush log files
10.	Added ability to define custom platforms
Driver changes:
1.	Windows - Added IOCTL_ALLOC_PHYSMEM to allocate physical memory
buffer
2.	Linux - Fix wrpci defect
2014-05-29 21:57:40 +01:00

110 lines
3.2 KiB
Python

#!/usr/local/bin/python
#CHIPSEC: Platform Security Assessment Framework
#Copyright (c) 2010-2014, Intel Corporation
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; Version 2.
#
#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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#Contact information:
#chipsec@intel.com
#
#
# usage as a standalone utility:
#
## \addtogroup standalone
#chipsec_util mem
#-------
#~~~
#chipsec_util mem <phys_addr_hi> <phys_addr_lo> <length> [value]
#''
# Examples:
#''
# chipsec_util mem 0x0 0x41E 0x20
# chipsec_util mem 0x0 0xA0000 4 0x9090CCCC
# chipsec_util mem 0x0 0xFED40000 0x4
#~~~
__version__ = '1.0'
import os
import sys
import time
import chipsec_util
from chipsec_util import chipsec_util_commands, _cs
from chipsec.logger import *
from chipsec.file import *
#from chipsec.hal.physmem import Memory
#_cs = cs()
usage = "chipsec_util mem <phys_addr_hi> <phys_addr_lo> <length> [value]\n" + \
"Examples:\n" + \
" chipsec_util mem 0x0 0x41E 0x20\n" + \
" chipsec_util mem 0x0 0xA0000 4 0x9090CCCC\n" + \
" chipsec_util mem 0x0 0xFED40000 0x4\n" + \
" chipsec_util mem allocate 0x1000\n\n"
chipsec_util.global_usage += usage
# ###################################################################
#
# Physical Memory
#
# ###################################################################
def mem(argv):
phys_address_hi = 0
phys_address_lo = 0
phys_address = 0
size = 0x100
op = argv[2]
t = time.time()
if 'allocate' == op and 4 == len(argv):
size = int(argv[3],16)
(va, pa) = _cs.mem.alloc_physical_mem( size )
logger().log( '[CHIPSEC] Allocated %X bytes of physical memory: VA = 0x%016X, PA = 0x%016X' % (size, va, pa) )
return
if 4 > len(argv):
print usage
return
else:
phys_address_hi = int(argv[2],16)
phys_address_lo = int(argv[3],16)
phys_address = ((phys_address_hi<<32) | phys_address_lo)
if 6 == len(argv):
value = int(argv[5],16)
logger().log( '[CHIPSEC] Writing: PA = 0x%016X <- 0x%08X' % (phys_address, value) )
_cs.mem.write_physical_mem_dword( phys_address, value )
else:
if 5 == len(argv): size = int(argv[4],16)
out_buf = _cs.mem.read_physical_mem( phys_address, size )
logger().log( '[CHIPSEC] Reading: PA = 0x%016X, len = 0x%X, output:' % (phys_address, len(out_buf)) )
print_buffer( out_buf )
logger().log( "[CHIPSEC] (mem) time elapsed %.3f" % (time.time()-t) )
chipsec_util_commands['mem'] = {'func' : mem, 'start_driver' : True }