Commit Graph

25 Commits

Author SHA1 Message Date
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
73e06a1983 Kernel: Convert klog() => AK::Format in a handful of places 2021-03-12 15:22:35 +01:00
Jean-Baptiste Boric
eedb6480df Kernel: Don't assert if RTC believes we're in the past 2021-02-11 20:58:39 +01:00
Nico Weber
4dfe97f9ae Kernel: Minor tweak to now() computation
Make sure the expression is evaluated as time_t so that it does
the right thing after 2037, and factor things so that the constants
look less magical.
2020-08-26 08:52:07 +02:00
Nico Weber
c85e679e2d AK+LibCore+Kernel: Have fewer implementations of day_of_year
The JS tests pointed out that the implementation in DateTime
had an off-by-one in the month when doing the leap year check,
so this change fixes that bug.
2020-08-26 08:52:07 +02:00
Nico Weber
9b17082899 AK+LibC+Kernel: Have fewer implementations of year_to_days_in_epoch
I believe the implementation in RTC.cpp had an off-by-one
in the year passed to is_leap_year(). If that's true, then this
fixes that too.
2020-08-26 08:52:07 +02:00
Nico Weber
84ed257959 AK+LibC+LibCore+Kernel: Have fewer implementations of is_leap_year 2020-08-26 08:52:07 +02:00
Nico Weber
19a8aa72d2 Kernel: Fix reading RTC
The CMOS sets bit 2 (0x4) if times are binary, if it's not
set they're in BCD.

The CMOS sets bit 1 (0x1) if hours are on a 12 hour clock.
In that case, the highest bit in the hour byte is set for
PM times (both in binary and BCD times).

Three bugs:

1. The lower 7 bits were masked off incorrectly when calling
   bcd_to_binary(). Use 0x7F as mask, not 0x70.

2. The highest bit to check if a time was PM was checked after
   BCD conversion of the low 7 bits, which clobbered that bit.
   Do the check before BCD conversion.

3. In the 12 hour clock, midnight and noon are "12", so those
   need to be converted to 0 even if for non-PM times (else
   midnight is "12", not "0").

With this, SerenityOS consistently shows UTC as the current time,
as it should.

If folks want it to display local time instead, they can get this
by adding `-rtc base=localtime` to Meta/run.sh -- but a better fix
would be to add timezone management and convert from UTC system
clock to the user timezone at display time.
2020-08-21 20:57:52 +02:00
Nico Weber
49d6405164 Kernel: Log time in addition to date in RTC startup 2020-08-20 20:53:43 +02:00
Ben Wiederhake
42b057b0c9 Kernel: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code. Also, in case
of signal_trampoline_dummy, marking it external (non-static) prevents it from
being 'optimized away', which would lead to surprising and weird linker errors.

I found these places by using -Wmissing-declarations.

The Kernel still shows these issues, which I think are false-positives,
but don't want to touch:
- Kernel/Arch/i386/CPU.cpp:1081:17: void Kernel::enter_thread_context(Kernel::Thread*, Kernel::Thread*)
- Kernel/Arch/i386/CPU.cpp:1170:17: void Kernel::context_first_init(Kernel::Thread*, Kernel::Thread*, Kernel::TrapFrame*)
- Kernel/Arch/i386/CPU.cpp:1304:16: u32 Kernel::do_init_context(Kernel::Thread*, u32)
- Kernel/Arch/i386/CPU.cpp:1347:17: void Kernel::pre_init_finished()
- Kernel/Arch/i386/CPU.cpp:1360:17: void Kernel::post_init_finished()
	No idea, not gonna touch it.
- Kernel/init.cpp:104:30: void Kernel::init()
- Kernel/init.cpp:167:30: void Kernel::init_ap(u32, Kernel::Processor*)
- Kernel/init.cpp:184:17: void Kernel::init_finished(u32)
	Called by boot.S.
- Kernel/init.cpp:383:16: int Kernel::__cxa_atexit(void (*)(void*), void*, void*)
- Kernel/StdLib.cpp:285:19: void __cxa_pure_virtual()
- Kernel/StdLib.cpp:300:19: void __stack_chk_fail()
- Kernel/StdLib.cpp:305:19: void __stack_chk_fail_local()
	Not sure how to tell the compiler that the compiler is already using them.
	Also, maybe __cxa_atexit should go into StdLib.cpp?
- Kernel/Modules/TestModule.cpp:31:17: void module_init()
- Kernel/Modules/TestModule.cpp:40:17: void module_fini()
	Could maybe go into a new header. This would also provide type-checking for new modules.
2020-08-12 20:40:59 +02:00
Andreas Kling
e5a20697da Kernel: Fix awkward RTC log message at boot 2020-04-08 17:19:46 +02:00
Liav A
0fc60e41dd Kernel: Use klog() instead of kprintf()
Also, duplicate data in dbg() and klog() calls were removed.
In addition, leakage of virtual address to kernel log is prevented.
This is done by replacing kprintf() calls to dbg() calls with the
leaked data instead.
Also, other kprintf() calls were replaced with klog().
2020-03-02 22:23:39 +01:00
Andreas Kling
94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Conrad Pankoff
07ca753124 Kernel: Fix BIOS date/time on hardware
It turns out some BIOS vendors don't support non-BCD date/time mode, but
we were relying on it being available. We no longer do this, but instead
check whether the BIOS claims to provide BCD or regular binary values for
its date/time data.
2019-09-28 13:59:49 +02:00
Andreas Kling
27f699ef0c AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>:

* u8, u16, u32, u64 (unsigned)
* i8, i16, i32, i64 (signed)
2019-07-03 21:20:13 +02:00
Andreas Kling
891d4c4834 Kernel: Qualify a bunch of #include statements. 2019-06-07 19:29:34 +02:00
Andreas Kling
bc951ca565 Kernel: Run clang-format on everything. 2019-06-07 11:43:58 +02:00
Robin Burchell
1cefb4a3b4 Kernel/RTC: Mark some intentional fallthroughs to suppress compiler warnings 2019-05-17 16:06:26 +02:00
Andreas Kling
932836e3c7 Kernel: Computing the boot timestamp was a bit broken. 2019-05-04 17:05:42 +02:00
Andreas Kling
fad69464f6 Kernel: Fix wrong calculation of current Unix timestamp. 2019-02-19 02:39:18 +01:00
Andreas Kling
c5a00a56c8 WindowServer: Put a clock in the top right corner of the screen.
This way we don't even need the Clock app anymore. Very cool :^)
2019-02-13 09:27:08 +01:00
Andreas Kling
ffab6897aa Big, possibly complete sweep of naming changes. 2019-01-31 17:31:23 +01:00
Andreas Kling
4dec23b487 Add assertion that RTC year is >= 2018. 2018-10-31 00:27:28 +01:00
Andreas Kling
dc6f57f19c Add gettimeofday() syscall and LibC wrappers gettimeofday() and time().
This only has second accuracy right now, I'll work out subseconds later.
2018-10-25 17:36:18 +02:00