Skip to content

Commit

Permalink
protos/limine: Rename 'boot time' feature to 'date at boot' for APIv3
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Feb 16, 2025
1 parent c9bf460 commit 278881c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
14 changes: 7 additions & 7 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -1262,31 +1262,31 @@ struct limine_efi_memmap_response {
Note: This feature provides data suitable for use with RT->SetVirtualAddressMap(), provided
HHDM offset is subtracted from `memmap`.

### Boot Time Feature
### Date at Boot Feature

ID:
```c
#define LIMINE_BOOT_TIME_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
#define LIMINE_DATE_AT_BOOT_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
```
Request:
```c
struct limine_boot_time_request {
struct limine_date_at_boot_request {
uint64_t id[4];
uint64_t revision;
struct limine_boot_time_response *response;
struct limine_date_at_boot_response *response;
};
```

Response:
```c
struct limine_boot_time_response {
struct limine_date_at_boot_response {
uint64_t revision;
int64_t boot_time;
int64_t timestamp;
};
```

* `boot_time` - The UNIX time on boot, in seconds, taken from the system RTC.
* `timestamp` - The UNIX timestamp, in seconds, taken from the system RTC, representing the date and time of boot.

### Executable Address Feature

Expand Down
12 changes: 6 additions & 6 deletions common/protos/limine.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,17 +1291,17 @@ FEAT_END
no_fb:
// Boot time feature
FEAT_START
struct limine_boot_time_request *boot_time_request = get_request(LIMINE_BOOT_TIME_REQUEST);
if (boot_time_request == NULL) {
struct limine_date_at_boot_request *date_at_boot_request = get_request(LIMINE_DATE_AT_BOOT_REQUEST);
if (date_at_boot_request == NULL) {
break; // next feature
}

struct limine_boot_time_response *boot_time_response =
ext_mem_alloc(sizeof(struct limine_boot_time_response));
struct limine_date_at_boot_response *date_at_boot_response =
ext_mem_alloc(sizeof(struct limine_date_at_boot_response));

boot_time_response->boot_time = time();
date_at_boot_response->timestamp = time();

boot_time_request->response = reported_addr(boot_time_response);
date_at_boot_request->response = reported_addr(date_at_boot_response);
FEAT_END

// Wrap-up stuff before memmap close
Expand Down
24 changes: 22 additions & 2 deletions limine.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,19 +635,39 @@ struct limine_efi_memmap_request {
LIMINE_PTR(struct limine_efi_memmap_response *) response;
};

/* Boot time */
/* Date at boot */

#define LIMINE_BOOT_TIME_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
#if LIMINE_API_REVISION >= 3
# define LIMINE_DATE_AT_BOOT_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
#else
# define LIMINE_BOOT_TIME_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
#endif

#if LIMINE_API_REVISION >= 3
struct limine_date_at_boot_response {
#else
struct limine_boot_time_response {
#endif
uint64_t revision;
#if LIMINE_API_REVISION >= 3
int64_t timestamp;
#else
int64_t boot_time;
#endif
};

#if LIMINE_API_REVISION >= 3
struct limine_date_at_boot_request {
#else
struct limine_boot_time_request {
#endif
uint64_t id[4];
uint64_t revision;
#if LIMINE_API_REVISION >= 3
LIMINE_PTR(struct limine_date_at_boot_response *) response;
#else
LIMINE_PTR(struct limine_boot_time_response *) response;
#endif
};

/* Executable address */
Expand Down
12 changes: 6 additions & 6 deletions test/limine.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ static volatile struct limine_efi_memmap_request efi_memmap_request = {
};

__attribute__((section(".limine_requests")))
static volatile struct limine_boot_time_request boot_time_request = {
.id = LIMINE_BOOT_TIME_REQUEST,
static volatile struct limine_date_at_boot_request date_at_boot_request = {
.id = LIMINE_DATE_AT_BOOT_REQUEST,
.revision = 0, .response = NULL
};

Expand Down Expand Up @@ -465,13 +465,13 @@ FEAT_END

FEAT_START
e9_printf("");
if (boot_time_request.response == NULL) {
if (date_at_boot_request.response == NULL) {
e9_printf("Boot time not passed");
break;
}
struct limine_boot_time_response *boot_time_response = boot_time_request.response;
e9_printf("Boot time feature, revision %d", boot_time_response->revision);
e9_printf("Boot time: %d", boot_time_response->boot_time);
struct limine_date_at_boot_response *date_at_boot_response = date_at_boot_request.response;
e9_printf("Date at boot feature, revision %d", date_at_boot_response->revision);
e9_printf("Timestamp: %d", date_at_boot_response->timestamp);
FEAT_END

// TODO: LoongArch MP
Expand Down

0 comments on commit 278881c

Please sign in to comment.