From 3061c267ba80174da0f702be87e0a4b2c09ceb55 Mon Sep 17 00:00:00 2001
From: Andreas Faerber <andreas.faerber@web.de>
Date: Sun, 23 May 2010 14:46:10 +0200
Subject: [PATCH 3/4] system_time: Fall back to get-msecs if milliseconds fails
---
.../kernel/platform/openfirmware/openfirmware.h | 1 +
src/system/boot/platform/openfirmware/support.cpp | 7 +++++--
.../kernel/platform/openfirmware/openfirmware.cpp | 17 +++++++++++++++++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/headers/private/kernel/platform/openfirmware/openfirmware.h b/headers/private/kernel/platform/openfirmware/openfirmware.h
index 9e75fc1..e43d1ba 100644
a
|
b
|
extern int of_call_method(int handle, const char *method, int numArgs,
|
74 | 74 | int numReturns, ...); |
75 | 75 | extern int of_test(const char *service); |
76 | 76 | extern int of_milliseconds(void); |
| 77 | extern int of_get_msecs(void); |
77 | 78 | extern void of_exit(void); |
78 | 79 | |
79 | 80 | #ifdef __cplusplus |
diff --git a/src/system/boot/platform/openfirmware/support.cpp b/src/system/boot/platform/openfirmware/support.cpp
index 965b2e4..1f8b95e 100644
a
|
b
|
|
10 | 10 | bigtime_t |
11 | 11 | system_time(void) |
12 | 12 | { |
13 | | int result = of_milliseconds(); |
14 | | return (result == OF_FAILED ? 0 : bigtime_t(result) * 1000); |
| 13 | int milliseconds = of_milliseconds(); |
| 14 | if (milliseconds == OF_FAILED) { |
| 15 | milliseconds = of_get_msecs(); |
| 16 | } |
| 17 | return (milliseconds == OF_FAILED ? 0 : bigtime_t(milliseconds) * 1000); |
15 | 18 | } |
diff --git a/src/system/kernel/platform/openfirmware/openfirmware.cpp b/src/system/kernel/platform/openfirmware/openfirmware.cpp
index 1f1d997..14920d3 100644
a
|
b
|
of_milliseconds(void)
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
| 569 | int |
| 570 | of_get_msecs(void) |
| 571 | { |
| 572 | struct { |
| 573 | const char *name; |
| 574 | int num_args; |
| 575 | int num_returns; |
| 576 | int milliseconds; |
| 577 | } args = { "get-msecs", 0, 1, 0 }; |
| 578 | |
| 579 | if (gCallOpenFirmware(&args) == OF_FAILED) |
| 580 | return OF_FAILED; |
| 581 | |
| 582 | return args.milliseconds; |
| 583 | } |
| 584 | |
| 585 | |
569 | 586 | void |
570 | 587 | of_exit(void) |
571 | 588 | { |