diff options
author | Damien Zammit <damien@zamaudio.com> | 2024-10-27 09:28:41 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2024-10-27 13:51:49 +0100 |
commit | 1f39d752da4eed39d1b7ebc17b7ce75c3f0a6865 (patch) | |
tree | 619a8fd83147632b6648b04c5d6752f2c7c0c35e /i386/i386at/mbinfo.c | |
parent | 7ea3a05d1dd190db757d577757f2e3dba85e3e15 (diff) | |
download | gnumach-1f39d752da4eed39d1b7ebc17b7ce75c3f0a6865.tar.gz gnumach-1f39d752da4eed39d1b7ebc17b7ce75c3f0a6865.tar.bz2 gnumach-1f39d752da4eed39d1b7ebc17b7ce75c3f0a6865.zip |
Expose device(mbinfo) with read access to multiboot raw info
Message-ID: <20241027092828.3162279-1-damien@zamaudio.com>
Diffstat (limited to 'i386/i386at/mbinfo.c')
-rw-r--r-- | i386/i386at/mbinfo.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/i386/i386at/mbinfo.c b/i386/i386at/mbinfo.c new file mode 100644 index 00000000..0722b8eb --- /dev/null +++ b/i386/i386at/mbinfo.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <string.h> +#include <i386at/mbinfo.h> +#include <mach/vm_param.h> +#include <vm/pmap.h> +#include <device/ds_routines.h> + +static struct multiboot_raw_info mb_info; + +void +mbinfo_register_boot_data(const struct multiboot_raw_info *mbi) +{ + mb_info = *mbi; +} + +io_return_t +mbinforead(dev_t dev, io_req_t ior) +{ + int err; + + /* Check if IO_COUNT is valid */ + if (ior->io_count > sizeof(struct multiboot_raw_info)) + return D_INVALID_SIZE; + + err = device_read_alloc(ior, (vm_size_t)ior->io_count); + if (err != KERN_SUCCESS) + return (err); + + memcpy ((uint8_t *)ior->io_data, &mb_info, ior->io_count); + + ior->io_residual = 0; + return (D_SUCCESS); +} |