refactor: namespace restructure of entire codebase
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Reorganize all source files into a hierarchical namespace structure with dot-separated unit names matching directory paths. Major changes: - src/prog/ -> src/app/ (app.*.pas) - src/fault/ -> src/arch/x86/fault/ (arch.x86.fault.*.pas) - src/isr/ -> src/arch/x86/isr/ (arch.x86.isr.*.pas) - src/include/ -> src/core/ (core.*.pas) + src/arch/x86/ - src/driver/ subtree reorganized with driver.* namespace prefixes - src/driver/storage/con/ -> src/driver/storage/ctl/ (Windows reserved name fix) - src/driver/storage/ split into con(ctl)/fs/vol/ subdirectories - src/driver/net/ flattened from l1-l5 layers to driver.net.*.pas - kernel.pas -> asuro.pas, faults.pas -> arch.x86.faults.pas - stdio.pas/syslog.pas -> io/io.stdio.pas, io/io.syslog.pas - processmanager.pas -> proc/proc.mgr.pas - lmemorymanager.pas -> memory/memory.heap.pas - Build scripts moved to toolchain/ - Added compat/ shims for lmemorymanager and types - Added doc/namespace.md tracking the refactor 197 files changed, 6292 insertions(+), 5526 deletions(-)
This commit is contained in:
1 parent
e922f086c2
commit
6fa008ed79
197 files changed
+6291
-5525
No files matched your search
@@ -0,0 +1,106 @@
|
||||
// Copyright 2021 Aaron Hance
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
{
|
||||
Driver->Storage->IORequest - I/O request allocation and lifecycle helpers.
|
||||
|
||||
Provides heap allocation/free for TIORequest records used by the
|
||||
submit_io / complete_io path in driver.storage.mgr.pas.
|
||||
|
||||
@author(Aaron Hance <[email protected]>)
|
||||
}
|
||||
unit driver.storage.iorequest;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
memory.heap,
|
||||
driver.storage.types;
|
||||
|
||||
{ Allocate a new TIORequest on the heap and initialise its core fields.
|
||||
Caller, State, Error and ByteCount are zeroed (caller fills as needed). }
|
||||
function ioreq_alloc(reqType : TIORequestType;
|
||||
device : PStorage_Device;
|
||||
lba : uint32;
|
||||
sectors : uint32;
|
||||
buf : pointer) : PIORequest;
|
||||
|
||||
{ Free a heap-allocated TIORequest. Safe to call with nil. }
|
||||
procedure ioreq_free(req : PIORequest);
|
||||
|
||||
{ Copy an existing TIORequest into a new heap allocation (deep copy of the
|
||||
record, NOT the buffer it points to). Used by dispatch_next to create an
|
||||
ISR-safe copy from the CFIFO value-element. }
|
||||
function ioreq_copy(src : PIORequest) : PIORequest;
|
||||
|
||||
implementation
|
||||
|
||||
function ioreq_alloc(reqType : TIORequestType;
|
||||
device : PStorage_Device;
|
||||
lba : uint32;
|
||||
sectors : uint32;
|
||||
buf : pointer) : PIORequest;
|
||||
var
|
||||
req : PIORequest;
|
||||
begin
|
||||
req := PIORequest(kalloc(SizeOf(TIORequest)));
|
||||
if req = nil then begin
|
||||
ioreq_alloc := nil;
|
||||
exit;
|
||||
end;
|
||||
req^.RequestType := reqType;
|
||||
req^.State := iosPending;
|
||||
req^.Device := device;
|
||||
req^.LBA := lba;
|
||||
req^.SectorCount := sectors;
|
||||
req^.Buffer := buf;
|
||||
req^.ByteCount := 0;
|
||||
req^.Error := eNone;
|
||||
req^.Caller := nil;
|
||||
req^.UserData := nil;
|
||||
req^.Callback := nil;
|
||||
req^.CallbackData := nil;
|
||||
ioreq_alloc := req;
|
||||
end;
|
||||
|
||||
procedure ioreq_free(req : PIORequest);
|
||||
begin
|
||||
if req <> nil then
|
||||
kfree(void(req));
|
||||
end;
|
||||
|
||||
function ioreq_copy(src : PIORequest) : PIORequest;
|
||||
var
|
||||
dst : PIORequest;
|
||||
begin
|
||||
dst := PIORequest(kalloc(SizeOf(TIORequest)));
|
||||
if dst = nil then begin
|
||||
ioreq_copy := nil;
|
||||
exit;
|
||||
end;
|
||||
dst^.RequestType := src^.RequestType;
|
||||
dst^.State := src^.State;
|
||||
dst^.Device := src^.Device;
|
||||
dst^.LBA := src^.LBA;
|
||||
dst^.SectorCount := src^.SectorCount;
|
||||
dst^.Buffer := src^.Buffer;
|
||||
dst^.ByteCount := src^.ByteCount;
|
||||
dst^.Error := src^.Error;
|
||||
dst^.Caller := src^.Caller;
|
||||
dst^.UserData := src^.UserData;
|
||||
dst^.Callback := src^.Callback;
|
||||
dst^.CallbackData := src^.CallbackData;
|
||||
ioreq_copy := dst;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in new issue
Block a user