forked from biosbits/bits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NEWS.txt
2711 lines (1942 loc) · 105 KB
/
NEWS.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
bits-2005
=========
- Makefile: Fix version calculation when not building from git
bits-2003
=========
Track all BITS dependencies (GRUB2, Python, ACPICA, libffi, and fdlibm)
as git submodules, rather than as separate tarballs to unpack. Split
all BITS-specific changes to these dependencies as commits in those git
repositories, making them easier to track, update, and upstream.
Submodules also ensure that each commit to BITS has a matching version
of all dependencies that it builds with, and that changes to BITS and
corresponding changes to dependencies are committed atomically.
BITS releases now provide a single source tarball containing both the
BITS source and the dependencies under the deps directory. This avoids
the need to unpack multiple source tarballs to specific locations before
building.
New features:
- Add support to decode and execute ACPI error injection (APEI, EINJ)
- Add explore option to decode and display variable MTRRs
- smilatency: Add a new function to time explicitly invoked SMIs
The new smilatency.time_io_smi function explicitly invokes SMIs by
writing to an IO port (by default, port 0xb2), and times the duration
of those SMIs. The port, the byte written, and the number of SMIs to
average can all be changed via optional parameters.
- Update Python to a post-2.7.10 snapshot that supports --with-computed-gotos.
This improves the performance of the Python interpreter.
- python: Support the glob, optparse, pickle, profile, pstats, and
unicodedata modules
- Provide a bits.rdtsc() function to directly invoke the rdtsc
instruction. Previously, Python code used rdmsr on MSR 0x10.
- Update to ACPICA 20150717
- acpi: Add summary before SRAT table decode
- efi: Add SMBIOS3_TABLE_GUID
Bugfixes and cleanups:
- Makefile: Fix build on systems that change configure's default libdir
The invocation of configure for grub did not specify --libdir, and
assumed that it would end up as the default $(prefix)/lib. However,
some distributions set a different systemwide default libdir (such as
/lib64) in a way that affects the default for configured software. On
such systems, the build would fail because it could not find files in
GRUB's libdir. To avoid that, explicitly specify --libdir.
- Makefile: When computing build version information, only use our own git
repository
If we don't have a .git directory, avoid searching upwards for a git
repository. Otherwise, builds from beneath some other unrelated git
repository would pick up a version number from there.
- Don't hardcode a specific mwait hint value in pstate tests or
cpu_frequency
bits.cpu_frequency hardcoded an mwait hint of 0x20, and set that
unconditionally, without restoring the original hint afterward.
pstate.test_hardware_pstates and testacpi.test_pstates also hardcoded
0x20, and each had identical code to save and restore the original
hints.
Stop setting a hint in cpu_frequency; it now measures based on the
current state only. Factor out the duplicate save/restore code into a
new context manager bits.mwait.use_hint, and add a mechanism for CPUs
to quirk the default hint to something other than 0x20.
- bits.cpu_frequency: Stop assuming that APERF and MPERF use TSC
frequency
APERF and MPERF are only guaranteed to be proportional; MPERF need not
actually match TSC. Read and use the TSC delta separately to scale
the APERF/MPERF ratio.
- Avoid calling bits.cpu_frequency twice when checking for availability.
This speeds up the CPU frequency test.
- bitfields.setbits: Fix bug referencing a name from the same module
- topology.display: Let ttypager.page() catch and display exceptions.
- smilatency: Factor out the computation of TSCs per second as a helper.
The new bits.tsc_per_sec() function computes the number of TSC counts
per second; after the first call, it just returns the cached value.
The new bits.format_tsc() function formats a number of TSC counts as a
time string with units.
- cstate_residency: Use the new bits.mwait.use_hint helper.
This factors out common code, and ensures that the hint is restored
after the test.
- python: Fix time.localtime to accept float arguments
- python: Make our file-like objects, used for stdout/stderr streams,
support .flush()
- Move some bits-specific modules into the bits.* module namespace
This avoids possible conflicts between bits modules and standard
Python modules.
- Work around ACPICA bug: skip over initial NULLs from
AcpiGetTableByIndex below index 3
ACPICA started reserving index slots for 32-bit and 64-bit FACS, and
returning NULL for those that don't exist, with other tables starting
at index 3. This breaks the previous API that allowed enumerating
tables until the first NULL is returned. Work around that by always
grabbing the first 3 (filtering NULL), and then starting the
enumeration-until-NULL from 3 rather than 0.
- acpi: Rename duplicate field in SRATMemoryAffinity
- acpi: get_cpupaths: Fix handling of x2apic CPUs (with _UID)
- acpi: Fix FACS parsing to return the parsed structure
- cpudetect: Replace hardcoded list of CPU names with detection of
available CPU modules
- Move errno compatibility changes from pyconfig.h to errno.h. This
allows them to support fdlibm as well, which eliminates one of our
changes to fdlibm.
bits-1219
=========
BITS now builds via a Makefile rather than a shell script. This allows
the build to run in parallel, significantly speeding up builds.
Note that unlike the build script, which autodetected the number of CPUs
to build on, the Makefile uses the usual -j option to make. So, if
you're used to ./build autodetecting your CPUs, you'll want to use make
-j$(nproc) (or just directly specify your desired amount of parallelism,
as you do with other makefiles).
Use make V=1 to let make echo commands before it runs them.
Use make LOCAL=1 to include local-files in the build (formerly ./build
local).
BITS now builds within a "build" subdirectory of the source rather than
a temporary directory under /tmp. The build system no longer removes
this directory as part of the build, only via an explicit "make clean",
to make it easier to investigate the build results.
Note that despite building via Make, BITS does *not* attempt to support
incremental builds. We continue to recommend ccache to speed up rebuilds.
Notable new features:
- Add a menu entry to exit back to EFI.
- Show on the main menu how BITS was booted: 32-bit BIOS, 32-bit EFI, or
64-bit EFI.
- Support reading and writing control registers.
bits.read_cr(apicid, n) reads CRn.
bits.write_cr(apicid, n, value) writes value to CRn.
Both functions return None on GPF.
Various improvements to the pager:
- When showing output from Python code via the pager, capture tracebacks
and display those via the pager as well, so that they wait for input.
Previously, if an exception occurred, it would flash on the screen
briefly before returning directly to the menu, requiring a trip to the
log to view the traceback.
Also display the output produced before the exception.
- Don't suggest going up when at the top of the output.
- Mention Up as well as PgUp.
- Clean up and simplify logic for EFI file handling and for displaying
available options.
Migrate quite a bit of code from C to Python:
- efi: Remove efi.call and the underlying _efi methods supporting it
Now that we can call EFI functions via ctypes, we don't need efi.call
anymore.
- Remove bits.malloc and bits.memmove, now unused with the move to ctypes
- acpi: Use ctypes to call most ACPICA functions from Python, rather
than wrapping them via the Python C API.
This allows replacing several C functions with simpler Python
equivalents.
Because the 32-bit BIOS port uses a calling convention unsupported by
libffi, introduce various trivial C wrappers that re-export ACPICA
functions with the standard C calling convention. For
AcpiWalkNamespace, introduce a more detailed wrapper that handles
callbacks back into Python-provided functions.
Export acpica_init to Python as well, and call it before calling the
ACPICA functions.
- acpi: Move unsafe_io handling from C to Python.
Directly export the address of the variable and manipulate it using
ctypes.
- acpi: Add acpi.install_interface, wrapping AcpiInstallInterface, for
use in the ACPI OS features menu.
- acpi: Add an exception mechanism with error code names, and a function
to transform an ACPI_STATUS value into an exception. This uses
AcpiFormatException to decode error codes.
- acpi: Add docstrings to ACPICA functions
Migrate quite a bit of code from GRUB scripting (and supporting C and
Python scaffolding) to Python:
- Convert MWAIT latency test to Python, with a minimal C helper for the
timing-sensitive portion.
Delete the now-unused "timer" and "cpu_ping" commands.
- Port mwait menu to Python
- Drop code to force specific configuration profiles on Nehalem and
Sandy Bridge.
This code remains available in older releases, but drop it from the
current version rather than porting it from GRUB configuration
language to Python.
- configure.cfg: Drop support for CPU-specific GRUB configure menu
files, since no more such files remain.
- Factor out a bits.brandstring() function to return the brandstring.
- Generate the CPU name on the main menu using Python, and improve title
to use CPU brandstring rather than maintaining a table of CPU
marketing names in BITS.
- Delete CPU family names and marketing names.
- Drop GRUB-based CPU detection entirely.
None of the GRUB config files depend on the variables this sets
anymore; all CPU-specific code lives in Python now.
- Remove the testsuite module and C expression evaluator.
The GRUB CPU detection code was the last user of this.
- Remove options to GRUB commands to run on particular CPUs.
The GRUB CPU detection code was the last programmatic user of this, and
command-line users can use Python for this.
- Remove all GRUB commands and options not used manually.
Nothing uses these commands programmatically anymore, so drop mechanisms
to write to environment variables, operate quietly, run tests, format
environment variables for display, sleep, or set mwait.
A future version of BITS may remove the remaining commands entirely,
in favor of Python functions, as the Python functions become
increasingly high-level and convenient. If you still rely on the GRUB
commands, please contact us.
Migrating all this code from C and GRUB to Python allowed deleting over 9000
lines of code in BITS relative to the previous release.
Other changes in this release:
- Remove the runppm command to load and run power-management reference
code; this is no longer used with current CPUs.
- README.Developers.txt: Update for the switch to build with make.
- README.Developers.txt: Update reference to GRUB version information.
- README.Developers.txt: BITS doesn't need the todos command anymore.
- acpi: Fix reinitialization after termination. Clear all of the
initialization flags, so that reinitialization actually loads tables
rather than failing. This fixes the menu items to change what OS
features BITS advertises to ACPI.
- acpi: Don't retrieve full table data just to check if a table exists.
get_table and get_table_addr both return None for a nonexistent table,
but the former returns a string containing the full table data, while
the latter just returns the address.
- acpi: Drop support for AcpiGbl_EnableAmlDebugObject. Our current
setting for AcpiDbgLevel leaves the debug object always enabled
regardless of this value, so drop it.
- acpi: Add assert that the number of ACPI_OBJECT_TYPE values hasn't
changed
- acpi: Use "bool" to return errors from ACPICA initialization
Stop using GRUB error codes, since the error code never gets passed
through GRUB.
Also use the proper type to hold ACPICA error codes.
- efi: Add network-related protocol GUIDs
- efi: Add EFI_PCI_IO_PROTOCOL and a simple test function
- Convert many modules to use "from __future__ import print_function".
- testmsr: Remove redundant output in MSR result descriptions
- Eliminate redundant acpica2.h header; move contents to acpica.h
- Delete unused header file misc.h
bits-1154
=========
- efi: Fix typo in type signatures of OutputString and TestString
- NEWS.txt: Fix typos in release notes for bits-1151
bits-1151
=========
The "I FFI, UEFI, we all FFI for EFI" release.
BITS now supports making EFI calls via the Python ctypes module, rather than
manually using efi.call. This provides simplified call syntax, type safety,
better (reference-counted) memory lifetime handling, bounds checking, and the
ability to have EFI call Python callbacks.
All EFI protocols, functions, and types have been converted to use ctypes.
This also provides automatic conversions to and from Python types as
appropriate. For instance, functions declared to accept a c_wchar_p (a Unicode
string) accept Python string and unicode objects:
out = efi.system_table.ConOut.contents
out.OutputString(out, "Hello world!\r\n")
- Add support for the 64-bit EFI calling convention in ctypes
Ship a separate copy of libffi with 64-bit EFI support added, and change
Python's _ctypes module to support that calling convention.
Add the uintptr_t and intptr_t types to our stdint.h, since libffi needs
uintptr_t.
- Convert all EFI functions, structure, and protocols to ctypes
Now that ctypes can call EFI functions, convert all functions to use it,
along with the corresponding types and protocols. This significantly
improves type safety, memory lifetime handling, bounds checking, and
similar.
In particular, code should now almost never use from_address or
addressof, since those produce raw addresses that may outlive the
objects they point to; code using from_address should now use
from_buffer or similar, and code using addressof should use byref or
similar.
Define a new type EFIFUNCTYPE, analogous to ctypes.CFUNCTYPE, for calls
using the EFI calling convention. For convenience, provide a wrapper
efi.FUNC that assumes a return type of EFI_STATUS (overridable with a
keyword parameter "ret").
To simplify the process of translating EFI functions and structures from
specifications, define appropriate EFI type aliases for ctypes types.
For instance, EFI extensively uses the type UINTN for "an integer the
size of a pointer", so the efi module defines that type as c_ulong.
Using ctypes function types also enables many convenient conversions.
For example, a function taking a parameter of type c_wchar_p can accept
a Python string or unicode object. See the ctypes documentation for
more details.
When defining function parameter and return types, note that the ctypes
types c_char_p and c_wchar_p have additional magic behavior above and
beyond a normal pointer, to transparently accept and return strings.
This behavior can be convenient, but it means that an EFI function
specified to accept or return a pointer to CHAR16 may want to use either
POINTER(CHAR16) or EFI_STRING (AKA c_wchar_p) as its type, depending on
the desired semantic behavior. Use POINTER(CHAR16) (and
create_unicode_buffer) for a pointer that EFI will fill in (since
passing a temporary object converted from a Python unicode object would
not produce useful results), or for a returned pointer that the caller
must free via the EFI FreePool or similar (since the automatic
conversion of return types from c_wchar_p to a Python unicode object
would discard the pointer that needs freeing).
EFIException now decodes known EFI error codes as symbolic names, in
addition to showing the hex value of all error codes.
Since efi now makes much more extensive use of ctypes types, switch from
"import ctypes" to "from ctypes import *". Similarly, bits.present does
"from efi import *" to get the EFI types. In general, modules that just
call efi functions should "import efi", but modules defining new EFI
protocols or structures should "from efi import *".
efi.call, and the associated split64() magic for 64-bit parameters on
32-bit EFI, are no more. They will not be mourned.
- Backport a grub change to fix a build failure on systems with new flex
With current versions of flex, grub failed to build with this error:
grub_script.yy.c:2367:13: error: 'yy_fatal_error' defined but not used [-Werror=unused-function]
static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
Fix that by backporting the change from git commit
9cc836a27be4a95f6f7bfd5b6bc099801645c0ea to disable additional warnings
for the flex-generated lexer.
- Disable -Wunused-value for Python
Current Python on current GCC generates a -Wunused-value warning on uses
of the PyObject_INIT macro, because it expands to a comma expression
where the rightmost value goes unused if nothing looks at the return
value. This warning turns into an error because of -Werror.
bits-1146
=========
The "EFI, FFI, fo, fum" release.
BITS now uses the Python ctypes module to access many types of data
structures and tables in memory, not just EFI. The ctypes module now
works for non-EFI builds, so modules such as acpi and pirtable can
safely use it. This required modifications to Python's libffi and
ctypes modules, to handle the various required calling conventions. See
the new bits.cdata module for ctypes wrappers that provide improved
printing, formatting, bitfield handling, and types such as GUIDs.
Much of acpi, pirtable, mptable, and smbios now use ctypes instead of
custom unpacking routines based on the struct module. Several new
internal C routines provide access to data structures as addresses
rather than Python strings, for direct access via ctypes. Further
conversion to ctypes will allow significant reduction in C code in favor
of Python.
Thanks to many new optimizations, BITS 1146 starts up several times
faster than previous releases:
- The filesystem API layer for Python code now has a faster
implementation of stat(), reducing the cases where it needs to
enumerate the parent directory to find the appropriate directory
entry.
- The Python pydoc module (with its various dependencies) now loads
on-demand when first invoked via help() or the pydoc command.
- Python now supports the zipimport module, and loads the Python
standard library from a zipfile.
Other changes in this release:
- Update Python to 2.7.9. Drop changes merged upstream, and add new
stubs and compatibility APIs for functions now called by 2.7.9.
- Update to ACPICA version 20141107
- Support the Python shlex module
- The pager now supports saving the currently displayed data to a file
on disk. Since this requires file write support, it only works when
booted via EFI.
- Print a message when starting BITS and when loading and initializing
early Python modules, to help debug BITS startup and provide an
indication of progress.
- smbios: Decode many additional structure types, and add a preliminary
Annex A conformance test. Includes contributions by Cathy Ji.
- efi: Add constants, structures, and helper functions for HII
configuration protocols.
- efi: The efi_file class now provides context manager support, to work
with the "with" statement.
- efi: Add menu entries to save and print EFI tables, in both raw and
decoded form. Includes the System Table, Configuration Table, Runtime
Services. and Boot Services. Decoded versions include names for known
GUIDs in Configuration table entries.
- acpi: Optionally allow I/O port access from ACPI method evaluation. By
default, ACPI method evaluation still ignores attempts to read or
write I/O ports. However, acpi.evaluate now accepts a keyword argument
unsafe_io=True to explicitly allow I/O. Also add a new debug printf to
show attempts to access I/O ports; add "acpica_io" to the debug
environment variable to see those attempts.
- acpi: When running under EFI, support saving ACPI tables to disk as
separate files, both raw and optionally decoded.
- acpi: Generate the table-dumping menu items from Python.
- acpi: Support dumping decoded ACPI tables to the BITS log.
- acpi: Add a new load_table method to load an SSDT table binary into
the ACPI namespace. Usage: acpi.load_table(table_data), where
table_data is a string buffer of the SSDT's AML. The contents of the
SSDT can be used to either patch existing or add new ACPI methods or
data for debug purposes. Given a binary AML file stored on the BITS
boot media as /ssdt.aml: acpi.load_table(open("/ssdt.aml").read())
- acpi: get_objpaths, display_objects, and dump now support limiting
maximum object depth, with a new optional depth parameter.
- acpica: Provide more logging and debugging functions, to help debug
internal ACPICA failures.
- _acpi: Add internal functions to get and set AcpiGbl_EnableAmlDebugObject
- init.cfg: Add a commented example to enable verbose logging from
Python; useful to debug Python module loading.
Bugfixes:
- acpi: Fix double-free in _eval error path when processing packages
- acpi: Handle package arguments correctly in acpi.evaluate.
acpi.evaluate attempted to convert tuples to ACPI packages, but did
not recursively convert the objects in the tuple to ACPI objects, so
any attempt to pass a non-empty tuple as an argument failed. Fix by
recursively calling _acpi_object_from_python on each component of the
tuple.
- acpi: Handle CPU paths and Device paths separately. Evaluate the
former to get a ProcID, and call ._UID on the latter to get a UID;
don't do both on both. Make display handle processors with UIDs
correctly, and format them correctly.
- acpimodule.c: Fix unused parameter warnings
Previously hidden by lax warning flags that ACPICA requires; this will
allow re-enabling that warning via GCC pragmas.
- efi: import efi from generated menu entries; avoid assuming that some
other global Python code has already imported efi.
- efi: Make EFI table saving more robust (and verbose). Add error
handling for unusual boot scenarios in which the EFI boot filesystem
does not match the GRUB root directory.
- Avoid printing spurious pre-import messages for efi modules when not
on efi. Using try/except to catch ImportError didn't stop the initial
message from printing. Check sys.platform instead.
- ttypager: When trying to import efi, only catch ImportError
- When viewing the log, don't write the log to the log
bits-1090
=========
- Update to ACPICA version 20140325
- Backport GRUB2 commit 4e42521d8c9232b6ee9eac7d8b4945a7479de781 to preserve
16-byte alignment of the stack on EFI calls
- python: Support the csv module
bits-1084
=========
- efi: Implement comparisons on GUIDs properly, including comparisons with
UUIDs
Fixes an exception in smbios and mptable on EFI systems when doing
GUID lookups.
- mkpresent: Work around bug in pdftoppm with rotated PDFs
If the generated image has width and height transposed, rerun pdftoppm
with transposed input values.
bits-1081
=========
The "ctypes. ctypes run. run types run" release.
This release introduces preliminary support for the Python ctypes module
in EFI builds. This includes the initial infrastructure to compile
libffi as part of BITS.
ctypes data types, ctypes structures, and read/write access to memory
work. This replaces many uses of bits.memory, struct.pack,
struct.unpack, and the BITS unpack module. In particular, the use of
ctypes data types and structures allows round-trip conversions from
structures in memory to Python data types and back, generally without
making copies.
This initial implementation provides enough support for all the data
structures in the efi module, which has now completely switched over to
ctypes-based data types and structures.
Notable limitations:
- No support for non-EFI builds yet, because GRUB uses stdcall and
regparm=3 for PC BIOS builds, which libffi does not support on
non-Windows systems.
- Function calls to EFI functions still require efi.call; the
ctypes-based FFI does not yet work, as it does not understand the EFI
calling convention.
- dlopen does not work, so there's no way to obtain pointers to existing
C functions to call.
Note that to support this change, the version of Python built into BITS
now internally uses UTF-16 (2-byte characters) rather than UCS-4 (4-byte
characters), to match EFI. This allows the use of the ctypes functions
for the C wchar_t type, rather than hand-rolled functions for two-byte
Unicode. Python still has full support for all of Unicode, including
characters outside the Basic Multilingual Plane; this just changes the
internal representation. However, attempting to use characters outside
the BMP in EFI calls may or may not work, depending on your firmware;
your mileage may vary.
This release also introduces support for reading and writing files using
EFI. On EFI systems, BITS now has full support for writing arbitrary
files to a FAT filesystem. The new efi.get_boot_fs() function will
retrieve the filesystem BITS booted from, as an efi_file, a new Python
file-like object. In addition to the usual file methods, an efi_file
provides methods to open and create files and directories. For example:
import efi
root = efi.get_boot_fs()
newdir = root.mkdir("newdir")
newfile = newdir.create("newfile")
newfile.write("Hello world!\n")
Or, chaining the calls together (convenient for command-line usage):
efi.get_boot_fs().mkdir("newdir").create("newfile").write(data)
The new functions `acpi.efi_save_tables()` and `efi.save_tables()` use
this new filesystem write capability to save copies of ACPI and EFI
tables, for later inspection.
Note that EFI firmware typically only supports FAT filesystems, not
iso9660 (the filesystem used on optical media). The BITS .iso images,
even when imaged to a USB disk, keep most of their files in an iso9660
filesystem, with the exception of a small FAT filesystem used to store
GRUB itself as an EFI binary. Thus, get_boot_fs() will not produce the
expected results when booting from an optical disc or from a disk
created from a BITS .iso; for full read/write support, create a
FAT-based BITS disk, following the procedure in INSTALL.txt.
This release adds support for many new EFI protocols:
- efi: Add read/write file support using FileProtocol, including a
file-like object
The efi_file wrapper includes the standard Python file-like methods
(read, write, seek, tell, close, flush), EFI-specific properties
(file_info, file_system_info, volume_label) and methods (delete), and
methods to create or open another efi_file relative to a directory
(open, create, mkdir).
Also add a definition of the EFI SimpleFileSystemProtocol to open a
block device, with a "root" property to get the root directory as an
efi_file.
Add a get_boot_fs() function to return the filesystem BITS booted
from, obtained via the DeviceHandle of the LoadedImageProtocol on the
image handle. Useful as the root for writing files.
- efi: Add DevicePathProtocol and DevicePathToTextProtocol
DevicePathToTextProtocol includes helpers to transform the returned
paths into Python unicode strings, and then free the original memory.
- efi: Add LoadedImageProtocol
Other changes in this release:
- python: Support the zlib module
- bits.present, mkpresent: Use zlib to compress and decompress slide images
Provides an order of magnitude improvement to disk usage and load time.
- acpi: Add an efi_save_tables utility function to save ACPI tables to files
As the name suggests, this function only works on EFI, since it uses the
EFI file write support.
In addition to the binary dumps, this also includes text decodes of
selected structures, and enough address information to recreate the
tables in memory.
- efi: Add a function efi.save_tables() to save the core EFI tables to files
- efi: As a workaround for limitations in the internal EFI function call
interface, add a compatibility layer for 64-bit arguments on 32-bit
platforms. Wrap 64-bit arguments in efi.split64(), and they will
automatically be split into pairs of 32-bit arguments on 32-bit
platforms, for compatibility with the current efi.call interface.
- Add EFI tests. The first round of tests verifies the CRCs of the core
EFI tables.
- efi: Add a base class for EFI protocols
Protocols are ctypes structures with an associated GUID; they provide
a .from_handle classmethod to get the protocol from an EFI handle (via
OpenProtocol) and wrap it in the protocol class.
- efi: Add more known UUIDs
- efi: When printing structures, format pointers and unsigned types as
hex, and list out the contents of arrays.
- efi: Various new helper functions:
- Add a helper function check_status to throw an exception for !=
EFI_SUCCESS
- Add a helper check_error_value to handle non-status return values.
Some EFI functions return a non-status return value, but still use
the EFI_ERROR bit to indicate an error. Add a helper that checks
only that bit, and otherwise returns the value for subsequent use.
- Add a locate_handles helper to call LocateHandle with a given GUID.
This helper handles the two-pass memory allocation, and returns a
ctypes array of handles.
- Add helper functions to compute table CRC32 values. These compute
the CRC32 as if the table's CRC32 field is 0, and then compare the
result to the table's actual CRC32 field.
- Add a helper function efi.to_bytes to convert a ctypes structure to
raw bytes
- README.Developers.txt: Document Python patches for ctypes and libffi
bits-1048
=========
This release introduces a new bits.* Python module namespace for new modules,
to keep the module namespace more contained:
- python: Move bits to bits/__init__.py to allow modules under bits.*
- python: Split pyfs functions out of bits into their own module, bits.pyfs
- python: Split pause() into a separate bits.pause module to avoid a circular
reference
bits imported redirect for redirect.nolog(), for use in pause(), and
redirect imports bits, creating a circular reference. Split pause()
into its own module, bits.pause, to break that cycle.
- Add new bits.pirtable module to find, parse, and test the PCI Interrupt
Routing ($PIR) table
Other changes in this release:
- Add bits.present, a module for giving a presentation using EFI GOP
- Add mkpresent, a script to generate slide images for bits.present
- readline: Add a mechanism to hook function keys and call arbitrary functions
- build: Support building local files into the .iso
Useful for local testing; avoids the need to construct and subsequently
modify a writable USB disk.
- mptable: Support finding the MP Table on EFI via configuration table GUID
- smbios: Support finding the SMBIOS tables on EFI via configuration table GUID
- efi: Add known UUIDs for various protocols
- efi: Create named constants for known UUIDs
- efi: Add function to dump all protocols in use, using LocateHandleBuffer and
ProtocolsPerHandle
- acpi: Handle "local reference" objects
- acpi: Add test for parsing MPST
- mptable: Validate header length and checksum after finding an _MP_ signature
If the length isn't valid or the checksum doesn't match, keep searching.
- acpi: When displaying the RSDT or XSDT, decode the name of each table
A list of table pointers is...uninformative.
- acpi: Add a display_objects() function to show object types
get_objpaths just retrieves all the object names; display_objects
additionally shows the type of each object.
- ttypager: Add a context manager that sends all output through the pager
This avoids the need to manually accumulate a string and call ttypager
on it, and thus avoids creating duplicate versions of functions, one
with the pager and one without.
Note that all output is deferred until the context manager exits, and
the context manager captures all exceptions and displays the traceback
through the pager.
- acpi: Use the new ttypager context manager in display_resources
- ttypager: Make home and end keys move to beginning and end, respectively
- platform: Make cpuids and msrs iterable
Walking them produces the list of all known (non-generic) CPUID and MSR
decoded values.
- platform: Add a dump() function to show all CPUIDs and MSRs for all CPUs
- platform: Make platform.dump() display using the pager
- Add an explore menu option to show platform information via platform.dump()
- platformbase: Improve documentation printed with CPUID and MSR objects
Show the APIC ID and docstring for CPUIDs and MSRs.
- platformbase: Add a sanity check to MSRs to prevent instantiating the generic
MSR
The MSR class requires an MSR number, and does not set that MSR number
itself. Subclasses that decode specific MSRs must set that MSR number.
- python: Stop using Python 2.7 {set} notation, for 2.6 syntax compatibility
BITS is built using Python 2.7, but with this one change, the modules
are parseable using the Python 2.6 ast module, useful for running
analysis scripts from a host system.
Bugfixes:
- acpi: Fix structure alignment and padding for ObjectInfo on 64-bit
ACPI_PNP_DEVICE_ID contains an integer followed by a pointer, so it has
padding in the middle on 64-bit. The containing structure has an 8-byte
address which needs padding to an 8-byte boundary on 64-bit. Handle
both of those instances of padding.
- acpi.evaluate: Fix error handling when translating an object within a package
When converting an ACPI object to a Python object, an unknown ACPI
object type will set the Python exception and return NULL. However,
when that error occurred within a package, the caller would then add
that NULL to the package and continue, rather than propagating the
error. Fix the package-handling code to reclaim the tuple and propagate
the error further up.
- acpi: Fix unpacking of object info structure
Invalid strings still have both a length and offset to unpack, even
though the length is 0.
- python: redirect: Drop unused import of acpi
- testacpi: Fix typo in a test description
- python/msrs.py: Fix typo in an MSR name
bits-1007
=========
The "64 bits ought to be enough for anyone" release.
Add initial support for 64-bit EFI. A BITS .iso image will now boot as
either a disk image or CD image for any of 32-bit BIOS, 32-bit EFI, or
64-bit EFI. For updated installation procedures, see INSTALL.txt.
Add a GRUB patch to 16-byte align the stack for grub_main(). The x86-64
ABI requires a 16-byte-aligned stack, which GRUB did not provide. That
caused some crashes, notably when running some SSE instructions. Fix by
aligning the stack in assembly before calling grub_main().
Port SMP support to support running processors in 64-bit mode:
- Add CPU bringup code for 64-bit long mode. Port all remaining
assembly to 64-bit, and to the 64-bit ABI.
- Since long mode requires paging, pass the page-table pointer from the
BSP (as set up by the firmware) to the APs. Note that the current
approach to this will fail if the firmware relocates its page tables
above 4GB after its initial page table setup. Also note that since
all memory requires mapping via the page table, accessing memory not
mapped by the BSP page table (such as a wild pointer supplied by a
firmware structure or an adventurous tester) will trigger an unhandled
page fault and unceremoniously die.
- Increase the size of the SMP working memory to accomodate larger
data structures.
- Use a relative offset in the GPF handler, not an absolute offset; that
avoids the need for a 64-bit offset.
- Port IDT parsing and setup from assembly to C.
- Port many assembly functions to use inline assembly, eliminating their
calling-convention-specific prologue and epilogue code, to simplify
the 64-bit port, and make the assembly more maintainable (by having
less of it):
- cpuid
- pause
- I/O port read/write
- rdtsc
- cli and sti
- rdmsr
- wrmsr
- infinite loop
- lidt and sidt
- getting CS
- drop_ap_lock
- smp: Delete several bits of old unused code:
- Unused assembly functions
- Unused data structures
- Unused function prototypes
- The "real-mode callback" mechanism, once used to park CPUs before
booting an OS, but eliminated long ago by simply leaving the CPUs in
an mwait loop in memory reserved from the OS.
- A synchronization variable that the AP code no longer uses (a relic
of waking the APs up via SIPI each time we have code to run, rather
than waking them up once and putting them in an mwait loop waiting
for work to do).
- Code that allows the function called via SIPI to return, now unused
because we call a function that waits forever for work to do.
Numerous cleanups to make C code 64-bit clean:
- Use pointer types rather than integral types when appropriate.
- Fix pointer-size and integer-size assumptions.
- Fix printf format strings.
- Make Python interface code 64-bit clean. Use Py_BuildValue and
PyArg_ParseTuple 'k' conversions for pointers. Convert safely between
some ACPI always-32-bit "pointers" and native pointers, with bounds
checking. Consistently use "unsigned long" for an integer of the same
size as a pointer.
- Make various config defines and typedefs portable.
- Rewrite Python's file <-> fd mapping to support sizeof(int) != sizeof(FILE *)
Abstract FILE * <-> integer fd conversions into functions to make them
easier to replace and more maintainable.
- Handle overflow errors safely in fwrite()
- python: fdlibm: Explicitly define __LITTLE_ENDIAN
fdlibm autodetected __LITTLE_ENDIAN based on some compiler definitions
defined for 32-bit x86, but not for 64-bit x86. Define it explicitly to
bypass fdlibm's faulty autodetection.
Only one change to make the Python code 64-bit clean; thanks to the
wonders of a language with arbitrary-precision integers, the one and
only change involves parsing data structures supplied by the
(non-Python) firmware:
- efi: Parse the (completely undocumented) padding after
FirmwareRevision in system table
Update boot support and documentation:
- INSTALL.txt: Update installation instructions for EFI support
- build: Build and install EFI binaries
grub-mkrescue already creates EFI binaries and embeds them in the El
Torito disk image for the .iso; however, those are not easily accessible
for use when creating a writable disk image, and they don't include all
the necessary modules to support disks. Build images with a more
complete set of modules for disk support, and ship them in /efi/boot in