Update set/inc/modify offset API
This commit is contained in:
@@ -872,7 +872,7 @@ instance CHERICap #(CapMem, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
function setAddr = error("feature not implemented for this cap type");
|
||||
function maskAddr = error("feature not implemented for this cap type");
|
||||
function getOffset = error("feature not implemented for this cap type");
|
||||
function setOffset = error("feature not implemented for this cap type");
|
||||
function modifyOffset = error("feature not implemented for this cap type");
|
||||
function getBase = error("feature not implemented for this cap type");
|
||||
function getTop = error("feature not implemented for this cap type");
|
||||
function getLength = error("feature not implemented for this cap type");
|
||||
@@ -902,7 +902,7 @@ instance CHERICap #(CapReg, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
function setAddr = error("feature not implemented for this cap type");
|
||||
function maskAddr = error("feature not implemented for this cap type");
|
||||
function getOffset = error("feature not implemented for this cap type");
|
||||
function setOffset = error("feature not implemented for this cap type");
|
||||
function modifyOffset = error("feature not implemented for this cap type");
|
||||
function getBase = error("feature not implemented for this cap type");
|
||||
function getTop = error("feature not implemented for this cap type");
|
||||
function getLength = error("feature not implemented for this cap type");
|
||||
@@ -1013,8 +1013,8 @@ instance CHERICap #(CapPipe, OTypeW, FlagsW, CapAddressW, CapW, TSub#(MW, 3));
|
||||
|
||||
function getOffset (x) = getOffsetFat(x.capFat, x.tempFields);
|
||||
|
||||
function Exact#(CapPipe) setOffset (CapPipe cap, Bit#(CapAddressW) offset, Bool increment);
|
||||
let result = incOffset(cap.capFat, pack(cap.capFat.address) + zeroExtend(offset), zeroExtend(offset), cap.tempFields, !increment);
|
||||
function Exact#(CapPipe) modifyOffset (CapPipe cap, Bit#(CapAddressW) offset, Bool doInc);
|
||||
let result = incOffset(cap.capFat, pack(cap.capFat.address) + zeroExtend(offset), zeroExtend(offset), cap.tempFields, !doInc);
|
||||
cap.capFat = result.d;
|
||||
cap.tempFields = getTempFields(cap.capFat);
|
||||
return Exact {exact: result.v, value: cap};
|
||||
|
||||
@@ -130,8 +130,14 @@ typeclass CHERICap#(type t, numeric type ot, numeric type flg, numeric type n, n
|
||||
|
||||
// Get the offset of the capability
|
||||
function Bit#(n) getOffset (t cap) = getAddr(cap) - getBase(cap);
|
||||
// Modify the offset of the capability. Result invalid if not exact
|
||||
function Exact#(t) modifyOffset (t cap, Bit#(n) offset, Bool doInc);
|
||||
// Set the offset of the capability. Result invalid if not exact
|
||||
function Exact#(t) setOffset (t cap, Bit#(n) offset, Bool increment);
|
||||
function Exact#(t) setOffset (t cap, Bit#(n) offset) =
|
||||
modifyOffset(cap, offset, False);
|
||||
// Set the offset of the capability. Result invalid if not exact
|
||||
function Exact#(t) incOffset (t cap, Bit#(n) inc) =
|
||||
modifyOffset(cap, inc, True);
|
||||
|
||||
// Get the base
|
||||
function Bit#(n) getBase (t cap);
|
||||
|
||||
Reference in New Issue
Block a user