Skip to content

Commit

Permalink
Map ACPI tables (#112)
Browse files Browse the repository at this point in the history
Map ACPI tables in kernel. Cleanup existing implementation that mapped
it from userspace.
  • Loading branch information
phaubertin authored Jan 19, 2025
1 parent dc7ee85 commit b118e64
Show file tree
Hide file tree
Showing 45 changed files with 947 additions and 886 deletions.
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"cmake.configureOnOpen": false,
"makefile.configureOnOpen": false,
"files.associations": {
"*.h": "c"
"*.h": "c",
"array": "c",
"deque": "c",
"string": "c",
"unordered_map": "c",
"vector": "c",
"string_view": "c",
"initializer_list": "c"
},
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86"
}
2 changes: 0 additions & 2 deletions devel/virtualbox/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ linux16 /boot/jinue \
DEBUG_DUMP_MEMORY_MAP=1 \
DEBUG_DUMP_SYSCALL_IMPLEMENTATION=1 \
DEBUG_DUMP_RAMDISK=1 \
RUN_TEST_ACPI=1 \
RUN_TEST_IPC=1

initrd16 /boot/jinue-testapp-initrd.tar.gz
boot
5 changes: 2 additions & 3 deletions doc/syscalls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
| 20 | [START_THREAD](start-thread.md) | Start a thread |
| 21 | [AWAIT_THREAD](await-thread.md) | Wait for a thread to exit |
| 22 | [REPLY_ERROR](reply-error.md) | Reply to message with an error |
| 23 | [SET_ACPI](set-acpi.md) | Provide mapped ACPI tables |
| 24-4095 | - | Reserved |
| 4096+ | [SEND](send.md) | Send a message |
| 23-4095 | - | Reserved |
| 4096+ | [SEND](send.md) | Send a message |

#### Reserved Function Numbers

Expand Down
59 changes: 0 additions & 59 deletions doc/syscalls/set-acpi.md

This file was deleted.

2 changes: 0 additions & 2 deletions include/jinue/jinue.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,4 @@ int jinue_await_thread(int fd, int *perrno);

int jinue_reply_error(uintptr_t errcode, int *perrno);

int jinue_set_acpi(jinue_acpi_tables_t *tables, int *perrno);

#endif
3 changes: 0 additions & 3 deletions include/jinue/shared/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@
/** reply to current message with an error code */
#define JINUE_SYS_REPLY_ERROR 22

/** provide the mapped ACPI tables */
#define JINUE_SYS_SET_ACPI 23

/** start of function numbers for user space messages */
#define JINUE_SYS_USER_BASE 4096

Expand Down
6 changes: 0 additions & 6 deletions include/jinue/shared/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,4 @@ typedef struct {
uintptr_t cookie;
} jinue_mint_args_t;

typedef struct {
const void *rsdt;
const void *fadt;
const void *madt;
} jinue_acpi_tables_t;

#endif
2 changes: 0 additions & 2 deletions include/kernel/application/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ int reply_error(uintptr_t errcode);

int send(uintptr_t *errcode, int fd, int function, const jinue_message_t *message);

int set_acpi(const jinue_acpi_tables_t *tables);

void set_thread_local(void *addr, size_t size);

int start_thread(int fd, const thread_params_t *params);
Expand Down
4 changes: 4 additions & 0 deletions include/kernel/domain/services/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@

void *map_in_kernel(kern_paddr_t paddr, size_t size, int prot);

void resize_map_in_kernel(size_t size);

void undo_map_in_kernel(void);

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Philippe Aubertin.
* Copyright (C) 2025 Philippe Aubertin.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -29,12 +29,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef JINUE_KERNEL_MACHINE_ACPI_H
#define JINUE_KERNEL_MACHINE_ACPI_H
#ifndef JINUE_KERNEL_INFRASTRUCTURE_ACPI_ACPI_H
#define JINUE_KERNEL_INFRASTRUCTURE_ACPI_ACPI_H

#include <jinue/shared/types.h>
#include <stdint.h>
#include <kernel/machine/types.h>
#include <kernel/infrastructure/acpi/tables.h>
#include <kernel/infrastructure/acpi/types.h>
#include <stdbool.h>
#include <stddef.h>

void machine_set_acpi_tables(const jinue_acpi_tables_t *tables);
bool verify_acpi_rsdp(const acpi_rsdp_t *rsdp);

void map_acpi_tables(kern_paddr_t rsdp_paddr, const acpi_table_def_t *table_defs);

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Philippe Aubertin.
* Copyright (C) 202-2025 Philippe Aubertin.
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -29,15 +29,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef JINUE_KERNEL_INFRASTRUCTURE_I686_DRIVERS_ASM_ACPI_H
#define JINUE_KERNEL_INFRASTRUCTURE_I686_DRIVERS_ASM_ACPI_H

#define ACPI_BDA_EBDA 0x40e
#ifndef JINUE_KERNEL_INFRASTRUCTURE_ACPI_ASM_ACPI_H
#define JINUE_KERNEL_INFRASTRUCTURE_ACPI_ASM_ACPI_H

#define ACPI_V1_REVISION 0

#define ACPI_V2_REVISION 2

#define ACPI_V1_RSDP_SIZE 20

/* Arbitrary value expected to be large enough to accomodate any real table
* while ensuring we don't create arbitrary large mappings because of garbage
* data in length members. */
#define ACPI_TABLE_MAX_SIZE (128 * 1024)

#endif
Loading

0 comments on commit b118e64

Please sign in to comment.