summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/driver/util.h
blob: 898875ae2a0089b96d6d25617c31bac2004c60d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once
#include <kernel/types.h>
#include <shared/mem.h>
#include <shared/ring.h>
#include <stdbool.h>
#include <stddef.h>

// TODO put req_readcopy in a global header
int req_readcopy(VfsReq *req, const void *buf, size_t len);

/* compare request path. path MUST be a static string */
#define reqpathcmp(req, path) _reqpathcmp(req, ""path"", sizeof(path) - 1)
#define _reqpathcmp(req, path, plen) \
	(req->input.kern && \
	 req->input.len == plen && \
	 memcmp(req->input.buf_kern, path, plen) == 0)

size_t ring_to_virt(ring_t *r, Proc *proc, void __user *ubuf, size_t max);