Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/726
-gerrit
commit 1e073bf8e1fe234169f0700af6d738b46d9d1246
Author: Stefan Reinauer <reinauer(a)chromium.org>
Date: Tue Oct 4 16:21:17 2011 -0700
Fix typos in src/console/Kconfig
- cash -> Cache
- make the new size of the cbmem console buffer the default
Change-Id: Ia906077257e93622ad56bc54a42f8184ade78b29
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
src/console/Kconfig | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/console/Kconfig b/src/console/Kconfig
index fefbe2e..2cfc4db 100644
--- a/src/console/Kconfig
+++ b/src/console/Kconfig
@@ -201,7 +201,7 @@ config CONSOLE_CBMEM
config CONSOLE_CBMEM_BUFFER_SIZE
depends on CONSOLE_CBMEM
hex "Room allocated for console output in CBMEM"
- default 0xae00
+ default 0x10000
help
Space allocated for console output storage in CBMEM. The default
value (almost 45K or 0xaeoo bytes) is large enough to accommodate
@@ -209,7 +209,7 @@ config CONSOLE_CBMEM_BUFFER_SIZE
config CONSOLE_CAR_BUFFER_SIZE
depends on CONSOLE_CBMEM
- hex "Room allocated for console output in cash as RAM"
+ hex "Room allocated for console output in Cache as RAM"
default 0xc00
help
Console is used before RAM is initialized. This is the room reserved
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/725
-gerrit
commit 1121a0d8314e5d6021c92fa0dd3fccd6d8a0197c
Author: Vadim Bendebury <vbendeb(a)chromium.org>
Date: Tue Oct 4 10:44:16 2011 -0700
Increase CBMEM to accommodate larger console.
This change adds 128K to the memory amount set aside for CBMEM in
case the CBMEM console is enabled (to keep the CBMEM 128K byte
aligned). The console buffer size is being set to 64K, which is
enough to accommodate the most verbose coreboot console and
u-boot console.
Change-Id: If583013dfb210de5028d69577675095c6fe2f3ab
Signed-off-by: Vadim Bendebury <vbendeb(a)chromium.org>
---
src/include/cbmem.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index a19ec5a..6a48dd2 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -21,7 +21,12 @@
#define _CBMEM_H_
/* Reserve 128k for ACPI and other tables */
+#if CONFIG_CONSOLE_CBMEM
+#define HIGH_MEMORY_DEF_SIZE ( 256 * 1024 )
+#else
#define HIGH_MEMORY_DEF_SIZE ( 128 * 1024 )
+#endif
+
#ifndef __PRE_RAM__
extern uint64_t high_tables_base, high_tables_size;
#endif
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/723
-gerrit
commit 9c591059993e49c5bbb841e8bcf47f2ff3987191
Author: Vadim Bendebury <vbendeb(a)chromium.org>
Date: Fri Sep 30 14:21:03 2011 -0700
Introduce utility for parsing CBMEM contents.
This is a python script which is supposed to run on a target
which is controlled by coreboot. The script examines top of
memory looking for the CBMEM signature at addresses aligned at
128K boundary. Once the script finds the CBMEM, it iterates
through the CBMEM table of contents and parses two entries: the
timestamps and the console log.
This submission is just a template to build upon to create a
utility for displaying CBMEM information while running Linux on
the target.
BUG=chrome-os-partner:4200
TEST=manual
See test description of d81e6b8c8d41f2d6 for test procedure.
Change-Id: Id863a8598eaadc2d20d728f9186843e65cbe6f37
Signed-off-by: Vadim Bendebury <vbendeb(a)chromium.org>
Reviewed-on: https://gerrit-int.chromium.org/5942
Tested-by: Vadim Bendebury <vbendeb(a)google.com>
Reviewed-by: Stefan Reinauer <reinauer(a)google.com>
---
util/cbmem/cbmem.py | 204 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 204 insertions(+), 0 deletions(-)
diff --git a/util/cbmem/cbmem.py b/util/cbmem/cbmem.py
new file mode 100755
index 0000000..3e8476d
--- /dev/null
+++ b/util/cbmem/cbmem.py
@@ -0,0 +1,204 @@
+#!/usr/bin/python
+#
+# cbmem.py - Linux space CBMEM contents parser
+#
+# Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
+#
+# 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 of the License
+#
+# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+'''
+Parse and display CBMEM contents.
+
+This module is meant to run on systems with coreboot based firmware.
+
+When started, it determines the amount of DRAM installed on the system, and
+then scans the top area of DRAM (right above the available memory size)
+looking for the CBMEM base signature at locations aligned at 0x20000
+boundaries.
+
+Once it finds the CBMEM signature, the utility parses the contents, reporting
+the section IDs/sizes and also reporting the contents of the tiemstamp and
+console sections.
+'''
+
+import mmap
+import re
+import struct
+import sys
+import time
+
+# These definitions follow src/include/cbmem.h
+CBMEM_MAGIC = 0x434f5245
+CBMEM_MAX_ENTRIES = 16
+
+CBMEM_ENTRY_FORMAT = '@LLQQ'
+CONSOLE_HEADER_FORMAT = '@LL'
+TIMESTAMP_HEADER_FORMAT = '@QLL'
+TIMESTAMP_ENTRY_FORMAT = '@LQ'
+
+mf_fileno = 0 # File number of the file providing access to memory.
+
+def align_up(base, alignment):
+ '''Increment to the alignment boundary.
+
+ Return the next integer larger than 'base' and divisible by 'alignment'.
+ '''
+
+ return base + alignment - base % alignment
+
+def normalize_timer(value, freq):
+ '''Convert timer reading into microseconds.
+
+ Get the free running clock counter value, divide it by the clock frequency
+ and multiply by 1 million to get reading in microseconds.
+
+ Then convert the value into an ASCII string with groups of three digits
+ separated by commas.
+
+ Inputs:
+ value: int, the clock reading
+ freq: float, the clock frequency
+
+ Returns:
+ A string presenting 'value' in microseconds.
+ '''
+
+ result = []
+ value = int(value * 1000000.0 / freq)
+ svalue = '%d' % value
+ vlength = len(svalue)
+ remainder = vlength % 3
+ if remainder:
+ result.append(svalue[0:remainder])
+ while remainder < vlength:
+ result.append(svalue[remainder:remainder+3])
+ remainder = remainder + 3
+ return ','.join(result)
+
+def get_cpu_freq():
+ '''Retrieve CPU frequency from sysfs.
+
+ Use /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq as the source.
+ '''
+ freq_str = open('/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq'
+ ).read()
+ # Convert reading into Hertz
+ return float(freq_str) * 1000.0
+
+def get_mem_size():
+ '''Retrieve amount of memory available to the CPU from /proc/meminfo.'''
+ mult = {
+ 'kB': 1024
+ }
+ meminfo = open('/proc/meminfo').read()
+ m = re.search('MemTotal:.*\n', meminfo)
+ mem_string = re.search('MemTotal:.*\n', meminfo).group(0)
+ (_, size, mult_name) = mem_string.split()
+ return int(size) * mult[mult_name]
+
+def parse_mem_at(addr, format):
+ '''Read and parse a memory location.
+
+ This function reads memory at the passed in address, parses it according
+ to the passed in format specification and returns a list of values.
+
+ The first value in the list is the size of data matching the format
+ expression, and the rest of the elements of the list are the actual values
+ retrieved using the format.
+ '''
+
+ size = struct.calcsize(format)
+ delta = addr % 4096 # mmap requires the offset to be page size aligned.
+ mm = mmap.mmap(mf_fileno, size + delta,
+ mmap.MAP_PRIVATE, offset=(addr - delta))
+ buf = mm.read(size + delta)
+ mm.close()
+ rv = [size,] + list(struct.unpack(format, buf[delta:size + delta + 1]))
+ return rv
+
+def dprint(text):
+ '''Debug print function.
+
+ Edit it to get the debug output.
+ '''
+
+ if False:
+ print text
+
+def process_timers(base):
+ '''Scan the array of timestamps found in CBMEM at address base.
+
+ For each timestamp print the timer ID and the value in microseconds.
+ '''
+
+ (step, base_time, max_entr, entr) = parse_mem_at(
+ base, TIMESTAMP_HEADER_FORMAT)
+
+ print('\ntime base %d, total entries %d' % (base_time, entr))
+ clock_freq = get_cpu_freq()
+ base = base + step
+ for i in range(entr):
+ (step, timer_id, timer_value) = parse_mem_at(
+ base, TIMESTAMP_ENTRY_FORMAT)
+ print '%d:%s ' % (timer_id, normalize_timer(timer_value, clock_freq)),
+ base = base + step
+ print
+
+def process_console(base):
+ '''Dump the console log buffer contents found at address base.'''
+
+ (step, size, cursor) = parse_mem_at(base, CONSOLE_HEADER_FORMAT)
+ print 'cursor at %d\n' % cursor
+
+ cons_string_format = '%ds' % min(cursor, size)
+ (_, cons_text) = parse_mem_at(base + step, cons_string_format)
+ print cons_text
+ print '\n'
+
+mem_alignment = 1024 * 1024 * 1024 # 1 GBytes
+table_alignment = 128 * 1024
+
+mem_size = get_mem_size()
+
+# start at memory address aligned at 128K.
+offset = align_up(mem_size, table_alignment)
+
+dprint('mem_size %x offset %x' %(mem_size, offset))
+mf = open("/dev/mem")
+mf_fileno = mf.fileno()
+
+while offset % mem_alignment: # do not cross the 1G boundary while searching
+ (step, magic, mid, base, size) = parse_mem_at(offset, CBMEM_ENTRY_FORMAT)
+ if magic == CBMEM_MAGIC:
+ offset = offset + step
+ break
+ offset += table_alignment
+else:
+ print 'Did not find the CBMEM'
+ sys.exit(0)
+
+for i in (range(1, CBMEM_MAX_ENTRIES)):
+ (_, magic, mid, base, size) = parse_mem_at(offset, CBMEM_ENTRY_FORMAT)
+ if mid == 0:
+ break
+
+ print '%x, %x, %x' % (mid, base, size)
+ if mid == 0x54494d45:
+ process_timers(base)
+ if mid == 0x434f4e53:
+ process_console(base)
+
+ offset = offset + step
+
+mf.close()