miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Toggle main menu visibility
Loading...
Searching...
No Matches
block_device.h
Go to the documentation of this file.
1
// MIT License
2
//
3
// Copyright (c) 2026 Christian Spoo
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef _MINIOS_DRIVERS_BLOCK_DEVICE_H_
24
#define _MINIOS_DRIVERS_BLOCK_DEVICE_H_
25
26
#include <
miniOS/types.h
>
27
28
/* Maximum number of tracked block devices (1 disk + up to 15 partitions). */
29
#define BLKDEV_MAX 16
30
31
#define BLKDEV_MAJOR_SATA 8
/* SCSI/ATA disk major, matching Linux convention */
32
33
typedef
struct
{
34
char
name
[16];
/* "sda", "sda1", "sda2", ... */
35
uint8_t
major
;
36
uint8_t
minor
;
37
uint64_t
lba_start
;
/* first LBA (0 for whole-disk entry) */
38
uint64_t
lba_end
;
/* last LBA inclusive (0 for whole-disk entry) */
39
bool
is_partition
;
40
}
block_device_t
;
41
46
void
blkdev_init
(
void
);
47
59
int
blkdev_register
(
const
char
*name,
uint8_t
major,
uint8_t
minor,
60
uint64_t
lba_start,
uint64_t
lba_end,
bool
is_partition);
61
68
const
block_device_t
*
blkdev_find
(
uint8_t
major,
uint8_t
minor);
69
75
const
block_device_t
*
blkdev_get
(
int
index);
76
80
int
blkdev_count
(
void
);
81
82
#endif
/* _MINIOS_DRIVERS_BLOCK_DEVICE_H_ */
blkdev_register
int blkdev_register(const char *name, uint8_t major, uint8_t minor, uint64_t lba_start, uint64_t lba_end, bool is_partition)
Definition
block_device.c:35
blkdev_find
const block_device_t * blkdev_find(uint8_t major, uint8_t minor)
Definition
block_device.c:52
blkdev_count
int blkdev_count(void)
Definition
block_device.c:66
blkdev_init
void blkdev_init(void)
Definition
block_device.c:30
blkdev_get
const block_device_t * blkdev_get(int index)
Definition
block_device.c:60
block_device_t
Definition
block_device.h:33
block_device_t::name
char name[16]
Definition
block_device.h:34
block_device_t::major
uint8_t major
Definition
block_device.h:35
block_device_t::lba_start
uint64_t lba_start
Definition
block_device.h:37
block_device_t::minor
uint8_t minor
Definition
block_device.h:36
block_device_t::is_partition
bool is_partition
Definition
block_device.h:39
block_device_t::lba_end
uint64_t lba_end
Definition
block_device.h:38
types.h
uint64_t
unsigned long int uint64_t
Definition
types.h:37
uint8_t
unsigned char uint8_t
Definition
types.h:28
include
miniOS
drivers
block_device.h
Generated by
1.18.0