mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:08:12 +00:00
Prekernel: Implement print_hex
UART function on aarch64
This allows us to print a hex number to the serial terminal.
This commit is contained in:
parent
7b237e5028
commit
28e36a70d6
1 changed files with 18 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Nico Weber <thakis@chromium.org>
|
||||
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -38,6 +39,23 @@ public:
|
|||
send(buf[i]);
|
||||
}
|
||||
|
||||
void print_hex(u64 n)
|
||||
{
|
||||
char buf[17];
|
||||
static const char* digits = "0123456789ABCDEF";
|
||||
int i = 0;
|
||||
do {
|
||||
buf[i++] = digits[n % 16];
|
||||
n /= 16;
|
||||
} while (n);
|
||||
send(static_cast<u32>('0'));
|
||||
send(static_cast<u32>('x'));
|
||||
buf[16] = '\0';
|
||||
for (i--; i >= 0; i--) {
|
||||
send(buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
UART();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue