mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
Kernel: Refactor storage stack with u64 as mmap offset
This commit is contained in:
parent
0d8c9024ee
commit
6698fd84ff
15 changed files with 21 additions and 21 deletions
|
@ -173,7 +173,7 @@ UNMAP_AFTER_INIT u32 BXVGADevice::find_framebuffer_address()
|
||||||
return framebuffer_address;
|
return framebuffer_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, const Range& range, size_t offset, int prot, bool shared)
|
KResultOr<Region*> BXVGADevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(video);
|
REQUIRE_PROMISE(video);
|
||||||
if (!shared)
|
if (!shared)
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
BXVGADevice();
|
BXVGADevice();
|
||||||
|
|
||||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
||||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared) override;
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
||||||
|
|
||||||
// ^Device
|
// ^Device
|
||||||
virtual mode_t required_mode() const override { return 0660; }
|
virtual mode_t required_mode() const override { return 0660; }
|
||||||
|
|
|
@ -51,7 +51,7 @@ UNMAP_AFTER_INIT MBVGADevice::MBVGADevice(PhysicalAddress addr, size_t pitch, si
|
||||||
s_the = this;
|
s_the = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> MBVGADevice::mmap(Process& process, FileDescription&, const Range& range, size_t offset, int prot, bool shared)
|
KResultOr<Region*> MBVGADevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(video);
|
REQUIRE_PROMISE(video);
|
||||||
if (!shared)
|
if (!shared)
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
MBVGADevice(PhysicalAddress addr, size_t pitch, size_t width, size_t height);
|
MBVGADevice(PhysicalAddress addr, size_t pitch, size_t width, size_t height);
|
||||||
|
|
||||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
||||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared) override;
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
||||||
|
|
||||||
// ^Device
|
// ^Device
|
||||||
virtual mode_t required_mode() const override { return 0660; }
|
virtual mode_t required_mode() const override { return 0660; }
|
||||||
|
|
|
@ -52,7 +52,7 @@ void MemoryDevice::did_seek(FileDescription&, off_t)
|
||||||
TODO();
|
TODO();
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> MemoryDevice::mmap(Process& process, FileDescription&, const Range& range, size_t offset, int prot, bool shared)
|
KResultOr<Region*> MemoryDevice::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
|
||||||
{
|
{
|
||||||
auto viewed_address = PhysicalAddress(offset);
|
auto viewed_address = PhysicalAddress(offset);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
MemoryDevice();
|
MemoryDevice();
|
||||||
~MemoryDevice();
|
~MemoryDevice();
|
||||||
|
|
||||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared) override;
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
||||||
|
|
||||||
// ^Device
|
// ^Device
|
||||||
virtual mode_t required_mode() const override { return 0660; }
|
virtual mode_t required_mode() const override { return 0660; }
|
||||||
|
|
|
@ -39,7 +39,7 @@ AnonymousFile::~AnonymousFile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, const Range& range, size_t offset, int prot, bool shared)
|
KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, const Range& range, u64 offset, int prot, bool shared)
|
||||||
{
|
{
|
||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
virtual ~AnonymousFile() override;
|
virtual ~AnonymousFile() override;
|
||||||
|
|
||||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared) override;
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual const char* class_name() const override { return "AnonymousFile"; }
|
virtual const char* class_name() const override { return "AnonymousFile"; }
|
||||||
|
|
|
@ -59,7 +59,7 @@ int File::ioctl(FileDescription&, unsigned, FlatPtr)
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> File::mmap(Process&, FileDescription&, const Range&, size_t, int, bool)
|
KResultOr<Region*> File::mmap(Process&, FileDescription&, const Range&, u64, int, bool)
|
||||||
{
|
{
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) = 0;
|
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) = 0;
|
||||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0;
|
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0;
|
||||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg);
|
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg);
|
||||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared);
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared);
|
||||||
virtual KResult stat(::stat&) const { return EBADF; }
|
virtual KResult stat(::stat&) const { return EBADF; }
|
||||||
|
|
||||||
virtual String absolute_path(const FileDescription&) const = 0;
|
virtual String absolute_path(const FileDescription&) const = 0;
|
||||||
|
|
|
@ -327,7 +327,7 @@ InodeMetadata FileDescription::metadata() const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> FileDescription::mmap(Process& process, const Range& range, size_t offset, int prot, bool shared)
|
KResultOr<Region*> FileDescription::mmap(Process& process, const Range& range, u64 offset, int prot, bool shared)
|
||||||
{
|
{
|
||||||
LOCKER(m_lock);
|
LOCKER(m_lock);
|
||||||
return m_file->mmap(process, *this, range, offset, prot, shared);
|
return m_file->mmap(process, *this, range, offset, prot, shared);
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
Custody* custody() { return m_custody.ptr(); }
|
Custody* custody() { return m_custody.ptr(); }
|
||||||
const Custody* custody() const { return m_custody.ptr(); }
|
const Custody* custody() const { return m_custody.ptr(); }
|
||||||
|
|
||||||
KResultOr<Region*> mmap(Process&, const Range&, size_t offset, int prot, bool shared);
|
KResultOr<Region*> mmap(Process&, const Range&, u64 offset, int prot, bool shared);
|
||||||
|
|
||||||
bool is_blocking() const { return m_is_blocking; }
|
bool is_blocking() const { return m_is_blocking; }
|
||||||
void set_blocking(bool b) { m_is_blocking = b; }
|
void set_blocking(bool b) { m_is_blocking = b; }
|
||||||
|
|
|
@ -107,7 +107,7 @@ int InodeFile::ioctl(FileDescription& description, unsigned request, FlatPtr arg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& description, const Range& range, size_t offset, int prot, bool shared)
|
KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& description, const Range& range, u64 offset, int prot, bool shared)
|
||||||
{
|
{
|
||||||
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
|
// FIXME: If PROT_EXEC, check that the underlying file system isn't mounted noexec.
|
||||||
RefPtr<InodeVMObject> vmobject;
|
RefPtr<InodeVMObject> vmobject;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
||||||
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
|
||||||
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override;
|
||||||
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, size_t offset, int prot, bool shared) override;
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
|
||||||
|
|
||||||
virtual String absolute_path(const FileDescription&) const override;
|
virtual String absolute_path(const FileDescription&) const override;
|
||||||
|
|
||||||
|
|
|
@ -148,12 +148,12 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
|
|
||||||
FlatPtr addr = params.addr;
|
FlatPtr addr = params.addr;
|
||||||
size_t size = params.size;
|
auto size = params.size;
|
||||||
size_t alignment = params.alignment;
|
auto alignment = params.alignment;
|
||||||
int prot = params.prot;
|
auto prot = params.prot;
|
||||||
int flags = params.flags;
|
auto flags = params.flags;
|
||||||
int fd = params.fd;
|
auto fd = params.fd;
|
||||||
int offset = params.offset;
|
auto offset = params.offset;
|
||||||
|
|
||||||
if (prot & PROT_EXEC) {
|
if (prot & PROT_EXEC) {
|
||||||
REQUIRE_PROMISE(prot_exec);
|
REQUIRE_PROMISE(prot_exec);
|
||||||
|
@ -255,7 +255,7 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u
|
||||||
return EACCES;
|
return EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto region_or_error = description->mmap(*this, range.value(), static_cast<size_t>(offset), prot, map_shared);
|
auto region_or_error = description->mmap(*this, range.value(), static_cast<u64>(offset), prot, map_shared);
|
||||||
if (region_or_error.is_error())
|
if (region_or_error.is_error())
|
||||||
return region_or_error.error().error();
|
return region_or_error.error().error();
|
||||||
region = region_or_error.value();
|
region = region_or_error.value();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue