xref: /haiku/docs/develop/kernel/arch/sparc/overview.rst (revision 268f99dd7dc4bd7474a8bd2742d3f1ec1de6752a)
1a5061eceSAdrien DestuguesThe SPARC port
2a5061eceSAdrien Destugues##############
3a5061eceSAdrien Destugues
4a5061eceSAdrien DestuguesThe SPARC port targets various machines from Sun product lineup. The initial effort is on the
5a5061eceSAdrien DestuguesUltra 60 and Ultra 5, with plans to latter add the Sun T5120 and its newer CPU. This may change
6a5061eceSAdrien Destuguesdepending on hardware donations and developer interest.
7a5061eceSAdrien Destugues
8a5061eceSAdrien DestuguesSupport for 32-bit versions of SPARC is currently not planned.
9a5061eceSAdrien Destugues
10a5061eceSAdrien DestuguesSPARC ABI
11a5061eceSAdrien Destugues=========
12a5061eceSAdrien Destugues
13a5061eceSAdrien DestuguesThe SPARC architecture has 32 integer registers, divided as follows:
14a5061eceSAdrien Destugues
15a5061eceSAdrien Destugues- global registers (g0-g7)
16a5061eceSAdrien Destugues- input (i0-i7)
17a5061eceSAdrien Destugues- local (l0-l7)
18a5061eceSAdrien Destugues- output (o0-o7)
19a5061eceSAdrien Destugues
20a5061eceSAdrien DestuguesParameter passing and return is done using the output registers, which are
21a5061eceSAdrien Destuguesgenerally considered scratch registers and can be corrupted by the callee. The
22a5061eceSAdrien Destuguescaller must take care of preserving them.
23a5061eceSAdrien Destugues
24a5061eceSAdrien DestuguesThe input and local registers are callee-saved, but we have hardware assistance
25a5061eceSAdrien Destuguesin the form of a register window. There is an instruction to shift the registers
26a5061eceSAdrien Destuguesso that:
27a5061eceSAdrien Destugues
28a5061eceSAdrien Destugues- o registers become i registers
29a5061eceSAdrien Destugues- local and output registers are replaced with fresh sets, for use by the
30a5061eceSAdrien Destugues  current function
31a5061eceSAdrien Destugues- global registers are not affected
32a5061eceSAdrien Destugues
33a5061eceSAdrien DestuguesNote that as a side-effect, o7 is moved to i7, this is convenient because these
34a5061eceSAdrien Destuguesare usually the stack and frame pointers, respectively. So basically this sets
35a5061eceSAdrien Destuguesthe frame pointer for free.
36a5061eceSAdrien Destugues
37a5061eceSAdrien DestuguesSimple enough functions may end up using just the o registers, in that case
38a5061eceSAdrien Destuguesnothing special is necessary, of course.
39a5061eceSAdrien Destugues
40a5061eceSAdrien DestuguesWhen shifting the register window, the extra registers come from the register
41a5061eceSAdrien Destuguesstack in the CPU. This is not infinite, however, most implementations of SPARC
42a5061eceSAdrien Destugueswill only have 8 windows available. When the internal stack is full, an overflow
43a5061eceSAdrien Destuguestrap is raised, and the handler must free up old windows by storing them on the
44a5061eceSAdrien Destuguesstack, likewise, when the internal stack is empty, an underflow trap must fill
45a5061eceSAdrien Destuguesit back from the stack-saved data.
46a5061eceSAdrien Destugues
47a5061eceSAdrien DestuguesMisaligned memory access
48a5061eceSAdrien Destugues========================
49a5061eceSAdrien Destugues
50a5061eceSAdrien DestuguesThe SPARC CPU is not designed to gracefully handle misaligned accesses.
51a5061eceSAdrien DestuguesYou can access a single byte at any address, but 16-bit access only at even
52a5061eceSAdrien Destuguesaddresses, 32bit access at multiple of 4 addresses, etc.
53a5061eceSAdrien Destugues
54a5061eceSAdrien DestuguesFor example, on x86, such accesses are not a problem, it is allowed and handled
55a5061eceSAdrien Destuguesdirectly by the instructions doing the access. So there is no performance cost.
56a5061eceSAdrien Destugues
57a5061eceSAdrien DestuguesOn SPARC, however, such accesses will cause a SIGBUS. This means a trap handler
58a5061eceSAdrien Destugueshas to catch the misaligned access and do it in software, byte by byte, then
59a5061eceSAdrien Destuguesgive back control to the application. This is, of course, very slow, so we
60a5061eceSAdrien Destuguesshould avoid it when possible.
61a5061eceSAdrien Destugues
62a5061eceSAdrien DestuguesFortunately, gcc knows about this, and will normally do the right thing:
63a5061eceSAdrien Destugues
64a5061eceSAdrien Destugues- For usual variables and structures, it will make sure to lay them out so that
65a5061eceSAdrien Destugues  they are aligned. It relies on stack alignment, as well as malloc returning
66a5061eceSAdrien Destugues  sufficiently aligned memory (as required by the C standard).
67a5061eceSAdrien Destugues- On packed structure, gcc knows the data is misaligned, and will automatically
68a5061eceSAdrien Destugues  use the appropriate way to access it (most likely, byte-by-byte).
69a5061eceSAdrien Destugues
70a5061eceSAdrien DestuguesThis leaves us with two undesirable cases:
71a5061eceSAdrien Destugues
72a5061eceSAdrien Destugues- Pointer arithmetics and casting. When computing addresses manually, it's
73a5061eceSAdrien Destugues  possible to generate a misaligned address and cast it to a type with a wider
74a5061eceSAdrien Destugues  alignment requirement. In this case, gcc may access the pointer using a
75a5061eceSAdrien Destugues  multi byte instruction and cause a SIGBUS. Solution: make sure the struct
76a5061eceSAdrien Destugues  is aligned, or declare it as packed so unaligned access are used instead.
77a5061eceSAdrien Destugues- Access to hardware: it is a common pattern to declare a struct as packed,
78a5061eceSAdrien Destugues  and map it to hardware registers. If the alignment isn't known, gcc will use
79a5061eceSAdrien Destugues  byte by byte access. It seems volatile would cause gcc to use the proper way
80a5061eceSAdrien Destugues  to access the struct, assuming that a volatile value is necessarily
81a5061eceSAdrien Destugues  aligned as it should.
82a5061eceSAdrien Destugues
83a5061eceSAdrien DestuguesIn the end, we just need to be careful about pointer math resulting in unalined
84a5061eceSAdrien Destuguesaccess. -Wcast-align helps with that, but it also raises a lot of false positives
85a5061eceSAdrien Destugues(where the alignment is preserved even when casting to other types). So we
86a5061eceSAdrien Destuguesenable it only as a warning for now. We will need to ceck the sigbus handler to
87a5061eceSAdrien Destuguesidentify places where we do a lot of misaligned accesses that trigger it, and
88a5061eceSAdrien Destuguesrework the code as needed. But in general, except for these cases, we're fine.
89a5061eceSAdrien Destugues
90a5061eceSAdrien DestuguesThe Ultrasparc MMUs
91a5061eceSAdrien Destugues============================
92a5061eceSAdrien Destugues
93a5061eceSAdrien DestuguesFirst, a word of warning: the MMU was different in SPARCv8 (32bit)
94a5061eceSAdrien Destuguesimplementations, and it was changed again on newer CPUs.
95a5061eceSAdrien Destugues
96a5061eceSAdrien DestuguesThe Ultrasparc-II we are supporting for now is documented in the Ultrasparc
97a5061eceSAdrien Destuguesuser manual. There were some minor changes in the Ultrasparc-III to accomodate
98a5061eceSAdrien Destugueslarger physical addresses. This was then standardized as JPS1, and Fujitsu
99a5061eceSAdrien Destuguesalso implemented it.
100a5061eceSAdrien Destugues
101a5061eceSAdrien DestuguesLater on, the design was changed again, for example Ultrasparc T2 (UA2005
102a5061eceSAdrien Destuguesarchitecture) uses a different data structure format to enlarge, again, the
103a5061eceSAdrien Destuguesphysical and virtual address tags.
104a5061eceSAdrien Destugues
105a5061eceSAdrien DestuguesFor now te implementation is focused on Ultrasparc-II because that's what I
106a5061eceSAdrien Destugueshave at hand, later on we will need support for the more recent systems.
107a5061eceSAdrien Destugues
108a5061eceSAdrien DestuguesUltrasparc-II MMU
109a5061eceSAdrien Destugues-----------------
110a5061eceSAdrien Destugues
111a5061eceSAdrien DestuguesThere are actually two separate units for the instruction and data address
112a5061eceSAdrien Destuguesspaces, known as I-MMU and D-MMU. They each implement a TLB (translation
113a5061eceSAdrien Destugueslookaside buffer) for the recently accessed pages.
114a5061eceSAdrien Destugues
115a5061eceSAdrien DestuguesThis is pretty much all there is to the MMU hardware. No hardware page table
116a5061eceSAdrien Destugueswalk is provided. However, there is some support for implementing a TSB
117a5061eceSAdrien Destugues(Translation Storage Buffer) in the form of providing a way to compute an
118a5061eceSAdrien Destuguesaddress into that buffer where the data for a missing page could be.
119a5061eceSAdrien Destugues
120a5061eceSAdrien DestuguesIt is up to software to manage the TSB (globally or per-process) and in general
121a5061eceSAdrien Destugueskeep track of the mappings. This means we are relatively free to manage things
122a5061eceSAdrien Destugueshowever we want, as long as eventually we can feed the iTLB and dTLB with the
123a5061eceSAdrien Destuguesrelevant data from the MMU trap handler.
124a5061eceSAdrien Destugues
125a5061eceSAdrien DestuguesTo make sure we can handle the fault without recursing, we need to pin a few
126a5061eceSAdrien Destuguesitems in place:
127a5061eceSAdrien Destugues
128a5061eceSAdrien DestuguesIn the TLB:
129a5061eceSAdrien Destugues
130a5061eceSAdrien Destugues- TLB miss handler code
131a5061eceSAdrien Destugues- TSB and any linked data that the TLB miss handler may need
132a5061eceSAdrien Destugues- asynchronous trap handlers and data
133a5061eceSAdrien Destugues
134a5061eceSAdrien DestuguesIn the TSB:
135a5061eceSAdrien Destugues
136a5061eceSAdrien Destugues- TSB-miss handling code
137a5061eceSAdrien Destugues- Interrupt handlers code and data
138a5061eceSAdrien Destugues
139a5061eceSAdrien DestuguesSo, from a given virtual address (assuming we are using only 8K pages and a
140a5061eceSAdrien Destugues512 entry TSB to keep things simple):
141a5061eceSAdrien Destugues
142a5061eceSAdrien DestuguesVA63-44 are unused and must be a sign extension of bit 43
143a5061eceSAdrien DestuguesVA43-22 are the 'tag' used to match a TSB entry with a virtual address
144a5061eceSAdrien DestuguesVA21-13 are the offset in the TSB at which to find a candidate entry
145a5061eceSAdrien DestuguesVA12-0 are the offset in the 8K page, and used to form PA12-0 for the access
146a5061eceSAdrien Destugues
147a5061eceSAdrien DestuguesInside the TLBs, VA63-13 is stored, so there can be multiple entries matching
148a5061eceSAdrien Destuguesthe same tag active at the same time, even when there is only one in the TSB.
149a5061eceSAdrien DestuguesThe entries are rotated using a simple LRU scheme, unless they are locked of
150a5061eceSAdrien Destuguescourse. Be careful to not fill a TLB with only locked entries! Also one must
151a5061eceSAdrien Destuguestake care of not inserting a new mapping for a given VA without first removing
152a5061eceSAdrien Destuguesany possible previous one (no need to worry about this when handling a TLB
153a5061eceSAdrien Destuguesmiss however, as in that case we obviously know that there was no previous
154a5061eceSAdrien Destuguesentry).
155a5061eceSAdrien Destugues
156a5061eceSAdrien DestuguesEntries also have a "context". This could for example be mapped to the process
157a5061eceSAdrien DestuguesID, allowing to easily clear all entries related to a specific context.
158a5061eceSAdrien Destugues
159a5061eceSAdrien DestuguesTSB entries format
160a5061eceSAdrien Destugues------------------
161a5061eceSAdrien Destugues
162a5061eceSAdrien DestuguesEach entry is composed of two 64bit values: "Tag" and "Data". The data uses the
163a5061eceSAdrien Destuguessame format as the TLB entries, however the tag is different.
164a5061eceSAdrien Destugues
165a5061eceSAdrien DestuguesThey are as follow:
166a5061eceSAdrien Destugues
167a5061eceSAdrien DestuguesTag
168a5061eceSAdrien Destugues***
169a5061eceSAdrien Destugues
170a5061eceSAdrien DestuguesBit 63: 'G' indicating a global entry, the context should be ignored.
171a5061eceSAdrien DestuguesBits 60-48: context ID (13 bits)
172a5061eceSAdrien DestuguesBits 41-0: VA63-22 as the 'tag' to identify this entry
173a5061eceSAdrien Destugues
174a5061eceSAdrien DestuguesData
175a5061eceSAdrien Destugues****
176a5061eceSAdrien Destugues
177a5061eceSAdrien DestuguesBit 63: 'V' indicating a valid entry, if it's 0 the entry is unused.
178a5061eceSAdrien DestuguesBits 62-61: size: 8K, 64K, 512K, 4MB
179a5061eceSAdrien DestuguesBit 60: NFO, indicating No Fault Only
180a5061eceSAdrien DestuguesBit 59: Invert Endianness of accesses to this page
181a5061eceSAdrien DestuguesBits 58-50: reserved for use by software
182a5061eceSAdrien DestuguesBits 49-41: reserved for diagnostics
183a5061eceSAdrien DestuguesBits 40-13: Physical Address<40-13>
184a5061eceSAdrien DestuguesBits 12-7: reserved for use by software
185a5061eceSAdrien DestuguesBit 6: Lock in TLB
186a5061eceSAdrien DestuguesBit 5: Cachable physical
187a5061eceSAdrien DestuguesBit 4: Cachable virtual
188a5061eceSAdrien DestuguesBit 3: Access has side effects (HW is mapped here, or DMA shared RAM)
189a5061eceSAdrien DestuguesBit 2: Privileged
190a5061eceSAdrien DestuguesBit 1: Writable
191a5061eceSAdrien DestuguesBit 0: Global
192a5061eceSAdrien Destugues
193a5061eceSAdrien DestuguesTLB internal tag
194a5061eceSAdrien Destugues****************
195a5061eceSAdrien Destugues
196a5061eceSAdrien DestuguesBits 63-13: VA<63-13>
197a5061eceSAdrien DestuguesBits 12-0: context ID
198a5061eceSAdrien Destugues
199a5061eceSAdrien DestuguesConveniently, a 512 entries TSB fits exactly in a 8K page, so it can be locked
200a5061eceSAdrien Destuguesin the TLB with a single entry there. However, it may be a wise idea to instead
201a5061eceSAdrien Destuguesmap 64K (or more) of RAM locked as a single entry for all the things that needs
202a5061eceSAdrien Destuguesto be accessed by the TLB miss trap handler, so we minimize the use of TLB
203a5061eceSAdrien Destuguesentries.
204a5061eceSAdrien Destugues
205a5061eceSAdrien DestuguesLikewise, it may be useful to use 64K pages instead of 8K whenever possible.
206a5061eceSAdrien DestuguesThe hardware provides some support for mixing the two sizes but it makes things
207a5061eceSAdrien Destuguesa bit more complex. Let's start out with simpler things.
208a5061eceSAdrien Destugues
209a5061eceSAdrien DestuguesSoftware floating-point support
210a5061eceSAdrien Destugues===============================
211a5061eceSAdrien Destugues
212a5061eceSAdrien DestuguesThe SPARC instruction set specifies instruction for handling long double
213a5061eceSAdrien Destuguesvalues, however, no hardware implementation actually provides them. They
214a5061eceSAdrien Destuguesgenerate a trap, which is expected to be handled by the softfloat library.
215a5061eceSAdrien Destugues
216a5061eceSAdrien DestuguesSince traps are slow, and gcc knows better, it will never generate those
217a5061eceSAdrien Destuguesinstructions. Instead it directly calls into the C library, to functions
218a5061eceSAdrien Destuguesspecified in the ABI and used to do long double math using softfloats.
219a5061eceSAdrien Destugues
220a5061eceSAdrien DestuguesThe support code for this is, in our case, compiled into both the kernel and
221a5061eceSAdrien Destugueslibroot. It lives in src/system/libroot/os/arch/sparc/softfloat.c (and other
222a5061eceSAdrien Destuguessupport files). This code was extracted from FreeBSD, rather than the glibc,
223a5061eceSAdrien Destuguesbecause that made it much easier to get it building in the kernel.
224a5061eceSAdrien Destugues
225a5061eceSAdrien DestuguesOpenboot bootloader
226a5061eceSAdrien Destugues===================
227a5061eceSAdrien Destugues
228a5061eceSAdrien DestuguesOpenboot is Sun's implementation of Open Firmware. So we should be able to share
229a5061eceSAdrien Destuguesa lot of code with the PowerPC port. There are some differences however.
230a5061eceSAdrien Destugues
231a5061eceSAdrien DestuguesExecutable format
232a5061eceSAdrien Destugues-----------------
233a5061eceSAdrien Destugues
234a5061eceSAdrien DestuguesPowerPC uses COFF. Sparc uses a.out, which is a lot simpler. According to the
235a5061eceSAdrien Destuguesspec, some fields should be zeroed out, but they say implementation may chose
236a5061eceSAdrien Destuguesto allow other values, so a standard a.out file works as well.
237a5061eceSAdrien Destugues
238a5061eceSAdrien DestuguesIt used to be possible to generate one with objcopy, but support was removed,
239a5061eceSAdrien Destuguesso we now use elf2aout (imported from FreeBSD).
240a5061eceSAdrien Destugues
241a5061eceSAdrien DestuguesThe file is first loaded at 4000, then relocated to its load address (we use
242a5061eceSAdrien Destugues202000 and executed there)
243a5061eceSAdrien Destugues
244a5061eceSAdrien DestuguesOpenfirmware prompt
245a5061eceSAdrien Destugues-------------------
246a5061eceSAdrien Destugues
247a5061eceSAdrien DestuguesTo get the prompt on display, use STOP+A at boot until you get the "ok" prompt.
248a5061eceSAdrien DestuguesOn some machines, if no keyboard is detected, the ROM will assume it is set up
249a5061eceSAdrien Destuguesin headless mode, and will expect a BREAK+A on the serial port.
250a5061eceSAdrien Destugues
251a5061eceSAdrien DestuguesSTOP+N resets all variables to default values (in case you messed up input or
252a5061eceSAdrien Destuguesoutput, for example).
253a5061eceSAdrien Destugues
254a5061eceSAdrien DestuguesUseful commands
255a5061eceSAdrien Destugues---------------
256a5061eceSAdrien Destugues
257a5061eceSAdrien DestuguesDisable autoboot to get to the openboot prompt and stop there
258a5061eceSAdrien Destugues
259a5061eceSAdrien Destugues.. code-block:: text
260a5061eceSAdrien Destugues
261a5061eceSAdrien Destugues   setenv auto-boot? false
262a5061eceSAdrien Destugues
263a5061eceSAdrien DestuguesConfiguring for keyboard/framebuffer io
264a5061eceSAdrien Destugues
265a5061eceSAdrien Destugues.. code-block:: text
266a5061eceSAdrien Destugues
267a5061eceSAdrien Destugues   setenv screen-#columns 160
268a5061eceSAdrien Destugues   setenv screen-#rows 49
269a5061eceSAdrien Destugues   setenv output-device screen:r1920x1080x60
270a5061eceSAdrien Destugues   setenv input-device keyboard
271a5061eceSAdrien Destugues
272a5061eceSAdrien DestuguesConfiguring openboot for serial port
273a5061eceSAdrien Destugues
274a5061eceSAdrien Destugues.. code-block:: text
275a5061eceSAdrien Destugues
276a5061eceSAdrien Destugues   setenv ttya-mode 38400,8,n,1,-
277a5061eceSAdrien Destugues   setenv output-device ttya
278a5061eceSAdrien Destugues   setenv input-device ttya
279a5061eceSAdrien Destugues   reset
280a5061eceSAdrien Destugues
281a5061eceSAdrien DestuguesBoot from network
282a5061eceSAdrien Destugues-----------------
283a5061eceSAdrien Destugues
284*d1ecc095SPulkoMandyThe openboot bootloader supports network booting. See the
285*d1ecc095SPulkoMandy`Network booting guide <https://www.haiku-os.org/guides/network_booting/>`_
286*d1ecc095SPulkoMandyfor general information about the general network booting process. This page
287*d1ecc095SPulkoMandydocuments the parts specific to the openboot bootloader configuration.
288*d1ecc095SPulkoMandy
289*d1ecc095SPulkoMandyIn openboot, booting from the network is done simply by using the "net:" device
290*d1ecc095SPulkoMandyalias in the boot command line. This lets openboot load our bootloader, which
291*d1ecc095SPulkoMandythen uses the openboot ability to send and receive data over the network to load
292*d1ecc095SPulkoMandythe filesystem (and kernel contained in it) over the network. The two parts are
293*d1ecc095SPulkoMandyindependent: it's also possible to load the bootloader from the network but boot
294*d1ecc095SPulkoMandya local filesystem, or use the local bootloader and load the filesystem from the
295*d1ecc095SPulkoMandynetwork.
296*d1ecc095SPulkoMandy
297*d1ecc095SPulkoMandyThe bootloader needs to be placed in a tftp server, I use atftpd in Debian,
298*d1ecc095SPulkoMandywhich serve files from /srv/tftp/ (so "somefile" in the example below will look
299*d1ecc095SPulkoMandyfor /srv/tftp/somefile).
300*d1ecc095SPulkoMandy
301a5061eceSAdrien Destuguesstatic ip
302a5061eceSAdrien Destugues*********
303a5061eceSAdrien Destugues
304a5061eceSAdrien DestuguesThis currently works best, because rarp does not let the called binary know the
305a5061eceSAdrien DestuguesIP address. We need the IP address if we want to mount the root filesystem using
306a5061eceSAdrien Destuguesremote_disk server.
307a5061eceSAdrien Destugues
308a5061eceSAdrien Destugues.. code-block:: text
309a5061eceSAdrien Destugues
310a5061eceSAdrien Destugues    boot net:192.168.1.2,somefile,192.168.1.89
311a5061eceSAdrien Destugues
312a5061eceSAdrien DestuguesThe first IP is the server from which to download (using TFTP), the second is
313a5061eceSAdrien Destuguesthe client IP to use. Once the bootloader starts, it will detect that it is
314a5061eceSAdrien Destuguesbooted from network and look for a the remote_disk_server on the same machine.
315a5061eceSAdrien Destugues
316a5061eceSAdrien Destuguesrarp
317a5061eceSAdrien Destugues****
318a5061eceSAdrien Destugues
319a5061eceSAdrien DestuguesThis needs a reverse ARP server (easy to setup on any Linux system). You need
320a5061eceSAdrien Destuguesto list the MAC address of the SPARC machine in /etc/ethers on the server. The
321a5061eceSAdrien Destuguesmachine will get its IP, and will use TFTP to the server which replied, to get
322a5061eceSAdrien Destuguesthe boot file from there.
323a5061eceSAdrien Destugues
324a5061eceSAdrien Destugues.. code-block:: text
325a5061eceSAdrien Destugues
326a5061eceSAdrien Destugues    boot net:,somefile
327a5061eceSAdrien Destugues
328a5061eceSAdrien Destugues(net is an alias to the network card and also sets the load address: /pci@1f,4000/network@1,1)
329a5061eceSAdrien Destugues
330*d1ecc095SPulkoMandyThis currently does not work completely: the server address is not forwarded to
331*d1ecc095SPulkoMandythe bootloader, and as a result, remote filesystems will not be available. The
332*d1ecc095SPulkoMandybootloader needs to be updated to know where to find the address in this case
333*d1ecc095SPulkoMandy(it is done for PowerPC, I think).
334*d1ecc095SPulkoMandy
335a5061eceSAdrien Destuguesdhcp
336a5061eceSAdrien Destugues****
337a5061eceSAdrien Destugues
338a5061eceSAdrien DestuguesThis needs a DHCP/BOOTP server configured to send the info about where to find
339a5061eceSAdrien Destuguesthe file to load and boot.
340a5061eceSAdrien Destugues
341a5061eceSAdrien Destugues.. code-block:: text
342a5061eceSAdrien Destugues
343a5061eceSAdrien Destugues    boot net:dhcp
344a5061eceSAdrien Destugues
345a5061eceSAdrien Destugues
346a5061eceSAdrien Destugues
347a5061eceSAdrien DestuguesDebugging
348a5061eceSAdrien Destugues---------
349a5061eceSAdrien Destugues
350*d1ecc095SPulkoMandyThe openboot environment provide several useful commands to assist in debugging:
351*d1ecc095SPulkoMandy
352a5061eceSAdrien Destugues.. code-block:: text
353a5061eceSAdrien Destugues
354a5061eceSAdrien Destugues   202000 dis (disassemble starting at 202000 until next return instruction)
355a5061eceSAdrien Destugues   4000 1000 dump (dump 1000 bytes from address 4000)
356a5061eceSAdrien Destugues   .registers (show global registers)
357a5061eceSAdrien Destugues   .locals (show local/windowed registers)
358a5061eceSAdrien Destugues   %pc dis (disassemble code being exectuted)
359a5061eceSAdrien Destugues   ctrace (backtrace)
360*d1ecc095SPulkoMandy
361*d1ecc095SPulkoMandyThe backtrace provides addresses and register values (allowing to know the
362*d1ecc095SPulkoMandyfunction arguments), there is no symbols and function names printed.
363*d1ecc095SPulkoMandyobjdump (on the build machine) can be used to disassemble the kernel or
364*d1ecc095SPulkoMandybootloader and find the corresponding code:
365*d1ecc095SPulkoMandy
366*d1ecc095SPulkoMandy.. code-block:: text
367*d1ecc095SPulkoMandy
368*d1ecc095SPulkoMandy    ./cross-tools-sparc/bin/sparc64-unknown-haiku-objdump -d objects/haiku/sparc/release/system/kernel/kernel_sparc |c++filt|less
369*d1ecc095SPulkoMandy    ./cross-tools-sparc/bin/sparc64-unknown-haiku-objdump -d objects/haiku/sparc/release/system/boot/openfirmware/boot_loader_openfirmware |c++filt|less
370