Voxia OS v0.0.1
Hobby Project Operating System Targeting x86-64
Loading...
Searching...
No Matches
block.h
Go to the documentation of this file.
1// Copyright (c) 2025 Mohammad Arfan
2
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21#ifndef __BLOCK__BLOCK_H__
22#define __BLOCK__BLOCK_H__
23
24#include <type.h>
25#ifdef __cplusplus
26extern "C" {
27#endif
28typedef enum {
29 FMODE_R = 1UL << 0,
30 FMODE_W = 1UL << 1,
31 FMODE_E = 1UL << 2
32} fmode_t;
33
35
36typedef struct {
38 int (*close)(void);
39 uint8_t* (*read)(uint64_t offset, size_t count);
40 int (*write)(void* block, uint64_t offset, size_t count, uint8_t* data);
41} __attribute__((aligned(64))) block_device_operations_t;
42
43void registerBlockDevice(const char* name, block_device_operations_t* ops,
44 void* identifier);
45#ifdef __cplusplus
46}
47#endif
48
49#endif // __BLOCK__BLOCK_H__
fmode_t
Definition block.h:28
@ FMODE_R
Definition block.h:29
@ FMODE_W
Definition block.h:30
@ FMODE_E
Definition block.h:31
void registerBlockDevice(const char *name, block_device_operations_t *ops, void *identifier)
open_response_code
Definition block.h:34
@ OPEN_FAILED
Definition block.h:34
@ OPEN_SUCCESS
Definition block.h:34
int count
Definition cache.h:2
kstring name
Definition dentry.h:5
void * ops
Definition dev.h:2
typedef __attribute__
Definition msi.c:47
uint16_t identifier
Definition icmp.h:4
int(* close)(void)
Definition block.h:38
uint8_t data[512]
Definition interrupt.h:60
open_response_code(* open)(fmode_t mode)
Definition block.h:37
char mode[8]
Definition tar.h:40
int(* write)(void *block, uint64_t offset, size_t count, uint8_t *data)
Definition block.h:40
unsigned long uint64_t
Definition type.h:25
unsigned char uint8_t
Definition type.h:7
uint32_t offset
Definition virtio.h:6