Debian Codegraph @

i386/i386at/mbinfo.c

raw
1 /*
2 * Copyright (c) 2024 Free Software Foundation, Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <string.h>
19 #include <i386at/mbinfo.h>
20 #include <mach/vm_param.h>
21 #include <vm/pmap.h>
22 #include <device/ds_routines.h>
23
24 static struct multiboot_raw_info mb_info;
25
26 void
27 mbinfo_register_boot_data(const struct multiboot_raw_info *mbi)
28 {
29 mb_info = *mbi;
30 }
31
32 io_return_t
33 mbinforead(dev_t dev, io_req_t ior)
34 {
35 int err;
36
37 /* Check if IO_COUNT is valid */
38 if (ior->io_count > sizeof(struct multiboot_raw_info))
39 return D_INVALID_SIZE;
40
41 err = device_read_alloc(ior, (vm_size_t)ior->io_count);
42 if (err != KERN_SUCCESS)
43 return (err);
44
45 memcpy ((uint8_t *)ior->io_data, &mb_info, ior->io_count);
46
47 ior->io_residual = 0;
48 return (D_SUCCESS);
49 }