|
|
|
PLEASE KEEP IN MIND
(THAT THIS)
|
|
PAGE IS NOT FINISHED
|
|
What's this?
(in short: a replacement for /boot/bin/poke)
|
|
In case you didn't knew it, BeOS PE R5 (not sure about older versions)
included a useful utility called "poke".
This is an open-source replacement for that app, that aims to improve it
where possible.
Poke is an interactive "peeking and poking" command line app that
allows you to do read/write operations in/to:
- ISA I/O Ports.
- "VGA-Style" indexed ISA Ports.
- PCI Configuration Space Registers.
- Virtual Memory.
- Memory Mapped PCI Registers ("Physical Memory").
You can do that in the following supported platforms:
- BeOS/Haiku (and Zeta, I guess)
- Win9x
There are even D.O.S. and WinXP versions planned, but those are not yet ready and/or feature complete.
It guess that porting it to unixes and/or *BSD should be easily, but I don't see the point in doing it.
|
|
What is this good for?
(besides making good coffee?)
|
|
It depends on the problem. For example:
- Are you trying to hunt an evasive bug? Maybe peeking (or poking)
some mem can help you out.
- Are you working on a driver for a device and you don't have
enough hardware information (specs) about it? Then spy what
those closed-source driver do!
Some "real-world" examples:
- While adding Hardware Cursor support for a driver I'm writing,
the original poke allowed me to understand how the hardware
expected the cursor data to be like in the video-card's mem.
I used it to dump the whole mem block that the BeOS driver
reserved for the cursor data (16 KB, quite different from what
both the Win and XFree86 drivers do, they use only 4 KB,
placing the 64x64x2 cursor at the start of that block)
- On BeOS (using Be-provided graphic-card driver) I've noticed that
switching to VESA at boot-time had a nice side-effect: quite
a big improvement on the speed on the access to the
graphics-card mem (notable drop in the CPU usage of, for
example non-overlayed video display).
A more-or-less careful examination of the dumped VGA registers
on both BeOS (with/without VESA) and Win9x, plus poking with
some of them while executing a graphic-demanding app allowed
me to find the best-performing setup for my own driver.
- Thanks to poke, now my trusty AMD K7 Thunderbird @ 900 MHz,
running over a SiS 730 based motherboard, only reaches between 27/30
Celcius degrees when idle! (previously it reached an steady 42
Celcius degrees). This thanks to have being able to change the
appropiate Northbridge's PCI config registers at will.
|
|
Documentation.
(kind of)
|
|
Poke is a shell-like command line application. Just start, type
"help" and hit [ENTER] to get a list of the available commands.
So far, these they are:
- Basic stuffs
- Getting help (for
'command').
- help [command]
- ? [command]
- Self-explaing commands
- ISA I/O
- Reading Byte/Word/Long (8/16/32 bits) from
'port' (up to
'last_port').
- inb port [last_port]
- inw port
- inl port
Examples:
- inb 0x290 0x297
- outb 0x80 0xBE
- Writing a Byte/Word/Long (8/16/32 bits) to 'port'.
- outb port value
- outw port value
- outl port value
- VGA-Style (indexed) Registers I/O from/to
'port' (and up to
'last_port' for reads).
- idxinb port [last_port]
- idxoutb port value
- Examples:
'port' (and up to
'last_port' for reads).
- idxinb 0x290 0x297
- idxoutb 0x80 0xBE
- PCI Configuration Space I/O
- Reading Byte/Word/Long (8/16/32 bits) from the PCI device
located at: 'bus' 'dev' 'fun'
starting at the register at 'reg_offset'
offset (and up to 'last_reg_offset').
- cfinb bus dev fun reg_offset [last_reg_offset]
- cfinw bus dev fun reg_offset [last_reg_offset]
- cfinl bus dev fun reg_offset [last_reg_offset]
- Writing a Byte/Word/Long (8/16/32 bits) from the PCI device
located at: 'bus' 'dev' 'fun'
and from the register at 'reg_offset'
offset.
- cfoutb bus dev fun reg_offset value
- cfoutw bus dev fun reg_offset value
- cfoutl bus dev fun reg_offset value
- Memory I/O
- Reading Byte/Word/Long (8/16/32 bits) from
'address' (up to
'last_address').
- db address [last_address]
- dw address [last_address]
- dl address [last_address]
- Writing a Byte/Word/Long (8/16/32 bits) to 'address'.
- sb address value
- sw address value
- sl address value
|
|
Tips
(and tricks)
|
|
You can 'script' poke! Just write a text file with one command per
line, like this:
idxinb 0x3C4 0x0 0xFF
idxout 0x3C4 0x30 0xA1
inb 0xD000 0xD0FF
quit
(don't forget the last 'quit') And then you can call it like this:
/boot/home> cat input.txt | poke > output.txt
|
|
What's new?
(are you already a poke-aholic? You'll love this...)
|
|
Original poke was made by Be Inc. And it was good. But it was not really
comfortable, and had some few bugs/quirks.
This replacement is has some neat features over the original, namely:
- Command line editing/history (bash-like).
- Less segment-fault prone (checks the memory before touching it).
- Lets you do memory-pages dumps to HD (physical and virtual).
- (basic) PCI device listing.
- Smaller things that I've forgot already.
|
|