Skip to content

Commit 4b8debb

Browse files
committed
[mk][platform] Migrate to C++ comp/linkage
1 parent 7633bd5 commit 4b8debb

File tree

14 files changed

+78
-65
lines changed

14 files changed

+78
-65
lines changed

mk/arch/x86/faults.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#define INT_MF 0x10
2424
#define INT_XM 0x13
2525

26-
extern "C" enum handler_return platform_irq(x86_iframe_t *frame);
26+
extern enum handler_return platform_irq(x86_iframe_t *frame);
2727

2828
static void dump_fault_frame(x86_iframe_t *frame) {
2929
#if ARCH_X86_32

mk/dev/include/dev/driver.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,23 @@ struct driver {
6969
#define concat(a, b) __ex_concat(a, b)
7070
#define __ex_concat(a, b) a##b
7171

72-
#define DRIVER_EXPORT(type_, ops_) \
73-
const struct driver concat(__driver_, type_) __ALIGNED(sizeof(void *)) __SECTION("drivers") = { \
74-
.type = #type_, \
75-
.ops = ops_, \
76-
}
77-
78-
#define DEVICE_INSTANCE(type_, name_, config_, flags_) \
79-
extern const struct driver concat(__driver_, type_); \
80-
struct device concat(__device_, concat(type_, concat(_, name_))) __ALIGNED(sizeof(void *)) \
81-
__SECTION("devices") = { \
82-
.name = #name_, \
83-
.driver = &concat(__driver_, type_), \
84-
.flags = flags_, \
85-
.config = config_, \
86-
.state = NULL, \
87-
.device_state = DEVICE_UNINITIALIZED, \
72+
#define DRIVER_EXPORT(type_, ops_) \
73+
__ALIGNED(sizeof(void *)) \
74+
__USED __SECTION("drivers") const struct driver concat(__driver_, type_) = { \
75+
.type = #type_, \
76+
.ops = ops_, \
77+
};
78+
79+
#define DEVICE_INSTANCE(type_, name_, config_, flags_) \
80+
extern const struct driver concat(__driver_, type_); \
81+
__ALIGNED(sizeof(void *)) \
82+
__USED __SECTION("devices") struct device concat(__device_, concat(type_, concat(_, name_))) = { \
83+
.name = #name_, \
84+
.driver = &concat(__driver_, type_), \
85+
.flags = flags_, \
86+
.config = config_, \
87+
.state = NULL, \
88+
.device_state = DEVICE_UNINITIALIZED, \
8889
}
8990

9091
/*
File renamed without changes.

mk/platform/pc/console.c renamed to mk/platform/pc/console.cc

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
/*
2-
* Copyright (c) 2009 Corey Tabaka
3-
* Copyright (c) 2016 Travis Geiselbrecht
4-
*
5-
* Use of this source code is governed by a MIT-style
6-
* license that can be found in the LICENSE file or at
7-
* https://opensource.org/licenses/MIT
8-
*/
1+
// Copyright 2016 The Fuchsia Authors
2+
// Copyright (c) 2009 Corey Tabaka
3+
// Copyright (c) 2016 Travis Geiselbrecht
4+
//
5+
// Use of this source code is governed by a MIT-style
6+
// license that can be found in the LICENSE file or at
7+
// https://opensource.org/licenses/MIT
8+
9+
#if WITH_LEGACY_PC_CONSOLE
10+
911
#include <lib/io.h>
1012
#include <stdarg.h>
1113
#include <stdio.h>
@@ -275,3 +277,5 @@ int printf_xy(int x, int y, char attr, char *fmt, ...) {
275277

276278
return result;
277279
}
280+
281+
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mk/platform/pc/platform.c renamed to mk/platform/pc/platform.cc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ static status_t platform_parse_multiboot_info(size_t *found_mem_arenas) {
129129

130130
/* bump the multiboot pointer up to the kernel mapping */
131131
/* TODO: test that it's within range of the kernel mapping */
132-
const multiboot_info_t *multiboot_info = (void *)((uintptr_t)_multiboot_info + KERNEL_BASE);
132+
const multiboot_info_t *multiboot_info =
133+
reinterpret_cast<const multiboot_info_t *>((uintptr_t)_multiboot_info + KERNEL_BASE);
133134

134135
dprintf(SPEW, "\tflags %#x\n", multiboot_info->flags);
135136

@@ -154,7 +155,7 @@ static status_t platform_parse_multiboot_info(size_t *found_mem_arenas) {
154155
// more modern multiboot mmap array
155156
if (multiboot_info->flags & MB_INFO_MMAP) {
156157
const memory_map_t *mmap = (const memory_map_t *)(uintptr_t)multiboot_info->mmap_addr;
157-
mmap = (void *)((uintptr_t)mmap + KERNEL_BASE);
158+
mmap = (const memory_map_t *)((uintptr_t)mmap + KERNEL_BASE);
158159

159160
dprintf(SPEW, "PC: multiboot memory map, length %u:\n", multiboot_info->mmap_length);
160161
parse_multiboot_mmap(mmap, multiboot_info->mmap_length, found_mem_arenas);
@@ -185,8 +186,10 @@ void platform_early_init(void) {
185186
/* get the debug output working */
186187
platform_init_debug_early();
187188

189+
#if WITH_LEGACY_PC_CONSOLE
188190
/* get the text console working */
189191
platform_init_console();
192+
#endif
190193

191194
/* initialize the interrupt controller */
192195
platform_init_interrupts();
@@ -220,21 +223,24 @@ void platform_early_init(void) {
220223
}
221224

222225
void local_apic_callback(const void *_entry, size_t entry_len) {
223-
const struct acpi_madt_local_apic_entry *entry = _entry;
226+
const struct acpi_madt_local_apic_entry *entry =
227+
reinterpret_cast<const struct acpi_madt_local_apic_entry *>(_entry);
224228

225229
printf("\tLOCAL APIC id %d, processor id %d, flags %#x\n", entry->apic_id, entry->processor_id,
226230
entry->flags);
227231
}
228232

229233
void io_apic_callback(const void *_entry, size_t entry_len) {
230-
const struct acpi_madt_io_apic_entry *entry = _entry;
234+
const struct acpi_madt_io_apic_entry *entry =
235+
reinterpret_cast<const struct acpi_madt_io_apic_entry *>(_entry);
231236

232237
printf("\tIO APIC id %d, address %#x gsi base %u\n", entry->io_apic_id, entry->io_apic_address,
233238
entry->global_system_interrupt_base);
234239
}
235240

236241
void int_source_override_callback(const void *_entry, size_t entry_len) {
237-
const struct acpi_madt_int_source_override_entry *entry = _entry;
242+
const struct acpi_madt_int_source_override_entry *entry =
243+
reinterpret_cast<const struct acpi_madt_int_source_override_entry *>(_entry);
238244

239245
printf("\tINT OVERRIDE bus %u, source %u, gsi %u, flags %#x\n", entry->bus, entry->source,
240246
entry->global_sys_interrupt, entry->flags);
@@ -264,7 +270,8 @@ void platform_init(void) {
264270
(const struct acpi_mcfg_table *)acpi_get_table_by_sig(ACPI_MCFG_SIG);
265271
if (table) {
266272
if (table->header.length >= sizeof(*table) + sizeof(struct acpi_mcfg_entry)) {
267-
const struct acpi_mcfg_entry *entry = (const void *)(table + 1);
273+
const struct acpi_mcfg_entry *entry =
274+
reinterpret_cast<const struct acpi_mcfg_entry *>(table + 1);
268275
printf("PCI MCFG: segment %#hx bus [%hhu...%hhu] address %#llx\n", entry->segment,
269276
entry->start_bus, entry->end_bus, entry->base_address);
270277

@@ -292,8 +299,9 @@ void platform_init(void) {
292299
}
293300

294301
#if WITH_LIB_MINIP
302+
extern "C" status_t e1000_register_with_minip(void);
303+
295304
void _start_minip(uint level) {
296-
extern status_t e1000_register_with_minip(void);
297305
status_t err = e1000_register_with_minip();
298306
if (err == NO_ERROR) {
299307
minip_start_dhcp();

0 commit comments

Comments
 (0)