mirror of
https://github.com/ipxe/ipxe
synced 2026-01-31 03:30:54 +03:00
[Contribs] Add README, license text, and invert error code dictionaries.
This commit is contained in:
committed by
Michael Brown
parent
ce298a9628
commit
fbf9295cbb
32
contrib/errcode/README
Normal file
32
contrib/errcode/README
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
Error Code Lookup for gPXE
|
||||||
|
==========================
|
||||||
|
This program looks up gPXE error codes so you can locate the line of source
|
||||||
|
code which produced the error.
|
||||||
|
|
||||||
|
Setup
|
||||||
|
-----
|
||||||
|
You must run:
|
||||||
|
./build_errcodedb.py >errcodedb.py
|
||||||
|
|
||||||
|
This extracts error code definitions from the gPXE source code and produces a
|
||||||
|
"database" which is used by the main program.
|
||||||
|
|
||||||
|
Once you have done this errcode.py and errcodedb.py are the only files you
|
||||||
|
need. They are now independent of the gPXE source code and can be moved
|
||||||
|
anywhere.
|
||||||
|
|
||||||
|
[OPTIONAL]
|
||||||
|
A PHP script is provided as a web interface. First edit errcode.php to point
|
||||||
|
$ERRCODE_PATH to the errcode.py script. Then move errcode.php to a location
|
||||||
|
visible from your web server.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
Looking up error codes on the command-line:
|
||||||
|
./errcode.py 0x12345678
|
||||||
|
|
||||||
|
Further information
|
||||||
|
-------------------
|
||||||
|
See http://etherboot.org/.
|
||||||
|
|
||||||
|
Released under the GPL and written by Stefan Hajnoczi <stefanha@gmail.com>.
|
||||||
@@ -1,4 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
|
||||||
|
#
|
||||||
|
# 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; either version 2 of the
|
||||||
|
# License, or 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -15,6 +30,15 @@ def err(msg):
|
|||||||
sys.stderr.write('%s: %s\n' % (sys.argv[0], msg))
|
sys.stderr.write('%s: %s\n' % (sys.argv[0], msg))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def to_pxenv_status(errno):
|
||||||
|
return errno & 0xff
|
||||||
|
|
||||||
|
def to_errfile(errno):
|
||||||
|
return (errno >> 13) & 0x7ff
|
||||||
|
|
||||||
|
def to_posix_errno(errno):
|
||||||
|
return (errno >> 24) & 0x7f
|
||||||
|
|
||||||
def load_header_file(filename, regexp):
|
def load_header_file(filename, regexp):
|
||||||
defines = {}
|
defines = {}
|
||||||
for line in open(filename, 'r'):
|
for line in open(filename, 'r'):
|
||||||
@@ -42,7 +66,7 @@ def evaluate(defines, expr):
|
|||||||
err('invalid expression')
|
err('invalid expression')
|
||||||
return eval(pyexpr)
|
return eval(pyexpr)
|
||||||
|
|
||||||
def build(filenames, regexp):
|
def build(filenames, regexp, selector):
|
||||||
unevaluated = {}
|
unevaluated = {}
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
unevaluated.update(load_header_file(filename, regexp))
|
unevaluated.update(load_header_file(filename, regexp))
|
||||||
@@ -59,8 +83,12 @@ def build(filenames, regexp):
|
|||||||
changed = True
|
changed = True
|
||||||
if unevaluated:
|
if unevaluated:
|
||||||
err('unable to evaluate all #defines')
|
err('unable to evaluate all #defines')
|
||||||
return evaluated
|
|
||||||
|
|
||||||
print 'pxenv_status =', repr(build(pxenv_status_files, PXENV_STATUS_RE))
|
lookup = {}
|
||||||
print 'errfile =', repr(build(errfile_files, ERRFILE_RE))
|
for key, val in evaluated.iteritems():
|
||||||
print 'posix_errno =', repr(build(posix_errno_files, POSIX_ERRNO_RE))
|
lookup[selector(val)] = key
|
||||||
|
return lookup
|
||||||
|
|
||||||
|
print 'pxenv_status =', repr(build(pxenv_status_files, PXENV_STATUS_RE, to_pxenv_status))
|
||||||
|
print 'errfile =', repr(build(errfile_files, ERRFILE_RE, to_errfile))
|
||||||
|
print 'posix_errno =', repr(build(posix_errno_files, POSIX_ERRNO_RE, to_posix_errno))
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
<?
|
<?
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
|
||||||
|
*
|
||||||
|
* 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; either version 2 of the
|
||||||
|
* License, or 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
// The path to the errcode.py script.
|
// The path to the errcode.py script.
|
||||||
$ERRCODE_PATH = './errcode.py';
|
$ERRCODE_PATH = './errcode.py';
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,4 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# Copyright (C) 2008 Stefan Hajnoczi <stefanha@gmail.com>.
|
||||||
|
#
|
||||||
|
# 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; either version 2 of the
|
||||||
|
# License, or 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -19,11 +34,11 @@ def to_errfile(errno):
|
|||||||
def to_posix_errno(errno):
|
def to_posix_errno(errno):
|
||||||
return (errno >> 24) & 0x7f
|
return (errno >> 24) & 0x7f
|
||||||
|
|
||||||
def lookup_errno_component(defines, selector, component):
|
def lookup_errno_component(defines, component):
|
||||||
for key, val in defines.iteritems():
|
if component in defines:
|
||||||
if selector(val) == component:
|
return defines[component]
|
||||||
return key
|
else:
|
||||||
return '0x%x' % component
|
return '0x%x' % component
|
||||||
|
|
||||||
class Errno(object):
|
class Errno(object):
|
||||||
def __init__(self, errno):
|
def __init__(self, errno):
|
||||||
@@ -37,10 +52,10 @@ class Errno(object):
|
|||||||
|
|
||||||
def prettystr(self):
|
def prettystr(self):
|
||||||
return 'pxenv_status=%s uniq=%d errfile=%s posix_errno=%s' % (
|
return 'pxenv_status=%s uniq=%d errfile=%s posix_errno=%s' % (
|
||||||
lookup_errno_component(errcodedb.pxenv_status, to_pxenv_status, self.pxenv_status),
|
lookup_errno_component(errcodedb.pxenv_status, self.pxenv_status),
|
||||||
self.uniq,
|
self.uniq,
|
||||||
lookup_errno_component(errcodedb.errfile, to_errfile, self.errfile),
|
lookup_errno_component(errcodedb.errfile, self.errfile),
|
||||||
lookup_errno_component(errcodedb.posix_errno, to_posix_errno, self.posix_errno)
|
lookup_errno_component(errcodedb.posix_errno, self.posix_errno)
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user