unsafe.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 1,063 行 · 第 1/2 页
JAVA
1,063 行
/**
* Sets an int at a given memory address
*
* @param memPtr
* @param value
*/
protected static native void setInt(Address memPtr, int value);
/**
* Sets an int at a given memory address While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
*/
protected static native void setInts(Address memPtr, int value, int count);
/**
* Perform a bitwise AND of the int at the given address and the given value. While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void andInt(Address memPtr, int value, int count);
/**
* Perform a bitwise OR of the int at the given address and the given value. While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void orInt(Address memPtr, int value, int count);
/**
* Perform a bitwise XOR of the int at the given address and the given value While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void xorInt(Address memPtr, int value, int count);
/**
* Sets a 24-bit int at a given memory address While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
*/
protected static native void setInts24(Address memPtr, int value, int count);
/**
* Perform a bitwise AND of the 24-bit int at the given address and the given value. While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void andInt24(Address memPtr, int value, int count);
/**
* Perform a bitwise OR of the 24-bit int at the given address and the given value. While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void orInt24(Address memPtr, int value, int count);
/**
* Perform a bitwise XOR of the 24-bit int at the given address and the given value While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void xorInt24(Address memPtr, int value, int count);
/**
* Sets an int at a given memory address
*
* @param object
* @param offset
* @param value
*/
protected static native void setInt(Object object, int offset, int value);
/**
* Sets a long at a given memory address
*
* @param memPtr
* @param value
*/
protected static native void setLong(Address memPtr, long value);
/**
* Sets a long at a given memory address While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
*/
protected static native void setLongs(Address memPtr, long value, int count);
/**
* Perform a bitwise AND of the long at the given address and the given value. While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void andLong(Address memPtr, long value, int count);
/**
* Perform a bitwise OR of the long at the given address and the given value. While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void orLong(Address memPtr, long value, int count);
/**
* Perform a bitwise XOR of the long at the given address and the given value While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
* The number of times to repeat this operation
*/
protected static native void xorLong(Address memPtr, long value, int count);
/**
* Sets a long at a given memory address
*
* @param object
* @param offset
* @param value
*/
protected static native void setLong(Object object, int offset, long value);
/**
* Sets a float at a given memory address
*
* @param memPtr
* @param value
*/
protected static native void setFloat(Address memPtr, float value);
/**
* Sets a float at a given memory address While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
*/
protected static native void setFloats(Address memPtr, float value, int count);
/**
* Sets a float at a given memory address
*
* @param object
* @param offset
* @param value
*/
protected static native void setFloat(Object object, int offset, float value);
/**
* Sets a double at a given memory address
*
* @param memPtr
* @param value
*/
protected static native void setDouble(Address memPtr, double value);
/**
* Sets a double at a given memory address While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
*/
protected static native void setDoubles(Address memPtr, double value, int count);
/**
* Sets a double at a given memory address
*
* @param object
* @param offset
* @param value
*/
protected static native void setDouble(Object object, int offset, double value);
/**
* Sets a Object at a given memory address
*
* @param memPtr
* @param value
*/
protected static native void setObject(Address memPtr, Object value);
/**
* Sets a Object at a given memory address While count is greater then 1, the address is incremented and the process repeats.
*
* @param memPtr
* @param value
* @param count
*/
protected static native void setObjects(Address memPtr, Object value, int count);
/**
* Sets a Object at a given memory address
*
* @param object
* @param offset
* @param value
*/
protected static native void setObject(Object object, int offset, Object value);
/**
* Fill the memory at the given memory address with size times 0 bytes.
*
* memPtr must be VmObject.SLOT_SIZE aligned
*
* size % VmObject.SLOT_SIZE must be 0
*
* @param memPtr
* @param size
*/
protected static native void clear(Address memPtr, int size);
/**
* Copy size bytes of memory from srcMemPtr to destMemPtr. The memory areas must not overlap.
*
* @param srcMemPtr
* @param destMemPtr
* @param size
*/
protected static native void copy(Address srcMemPtr, Address destMemPtr, int size);
/**
* Push an integer onto the execution stack
*
* @param value
*/
protected static native void pushInt(int value);
/**
* Push a long onto the execution stack
*
* @param value
*/
protected static native void pushLong(long value);
/**
* Push an Object onto the execution stack
*
* @param value
*/
protected static native void pushObject(Object value);
/**
* Invoke the given method without any parameters
*
* @param method
*/
protected static native void invokeVoid(VmMethod method);
/**
* Invoke the given method without any parameters
*
* @param method
* @return int
*/
protected static native int invokeInt(VmMethod method);
/**
* Invoke the given method without any parameters
*
* @param method
* @return long
*/
protected static native long invokeLong(VmMethod method);
/**
* Invoke the given method without any parameters
*
* @param method
* @return Object
*/
protected static native Object invokeObject(VmMethod method);
/**
* Gets the current stackframe
*
* @return The address of the stackframe of the current thread
*/
protected static native Address getCurrentFrame();
/**
* Halt the processor until the next interrupt arrives.
*/
protected static native void idle();
/**
* Cause the system to stop TODO Protect me again
*/
protected static void die(String msg) {
debug("Real panic: ");
if (msg != null) {
debug(msg);
}
die();
}
/**
* Cause the system to stop TODO Protect me again
*/
private static native void die();
/**
* Print the given string on the screen.
*/
public static native void debug(String str);
/**
* Print the given value on the screen.
*/
public static native void debug(char value);
/**
* Print the given value on the screen.
*/
public static native void debug(int value);
/**
* Print the given value on the screen.
*/
public static native void debug(long value);
/**
* Initialize the new Thread.
*
* @param curThread
* @param newStack
* @param stackSize
*/
protected static native void initThread(VmThread curThread, Object newStack, int stackSize);
/**
* Atomic compare and swap. Compares the int value addressed by the given address with the given old value. If they are equal, the value at the given address is replace by the new value and true
* is returned, otherwise nothing is changed and false is returned.
*
* @param address
* @param oldValue
* @param newValue
* @return boolean true if the value at address is changed, false otherwise.
*/
protected static native boolean atomicCompareAndSwap(Address address, int oldValue, int newValue);
/**
* Atomic AND. *((int*)address) &= value.
*
* @param address
* @param value
* @return boolean
*/
protected static native boolean atomicAnd(Address address, int value);
/**
* Atomic OR. *((int*)address) |= value.
*
* @param address
* @param value
* @return boolean
*/
protected static native boolean atomicOr(Address address, int value);
/**
* Atomic SUB. *((int*)address) -= value.
*
* @param address
* @param value
* @return boolean
*/
protected static native boolean atomicSub(Address address, int value);
protected static native int inPortByte(int portNr);
protected static native int inPortWord(int portNr);
protected static native int inPortDword(int portNr);
protected static native void outPortByte(int portNr, int value);
protected static native void outPortWord(int portNr, int value);
protected static native void outPortDword(int portNr, int value);
public static native float intBitsToFloat(int value);
public static native int floatToRawIntBits(float value);
public static native double longBitsToDouble(long value);
public static native long doubleToRawLongBits(double value);
protected static native int compare(Address a1, Address a2) throws PragmaUninterruptible;
protected static native Address add(Address addr, int incValue) throws PragmaUninterruptible;
protected static native Address add(Address a1, Address a2) throws PragmaUninterruptible;
protected static native Address intToAddress(int addr32) throws PragmaUninterruptible;
protected static native Address longToAddress(long addr64) throws PragmaUninterruptible;
protected static native int addressToInt(Address addr) throws PragmaUninterruptible;
protected static native long addressToLong(Address addr) throws PragmaUninterruptible;
/**
* Gets the minimum valid address in the addressspace of the current architecture.
*
* @return Address
*/
protected static native Address getMinAddress();
/**
* Gets the maximum valid address in the addressspace of the current architecture.
*
* @return Address
*/
protected static native Address getMaxAddress();
/**
* Gets the (inclusive) start address of the available memory.
*
* @return Address
*/
protected static native Address getMemoryStart();
/**
* Gets the (exclusive) end address of the available memory.
*
* @return Address
*/
protected static native Address getMemoryEnd();
/**
* Gets the (inclusive) start address of the kernel.
*
* @return Address
*/
protected static native Address getKernelStart();
/**
* Gets the (exclusive) end address of the kernel.
*
* @return Address
*/
protected static native Address getKernelEnd();
/**
* Gets the (inclusive) start address of the initial jarfile.
*
* @return Address
*/
protected static native Address getInitJarStart();
/**
* Gets the (exclusive) end address of the initial jarfile.
*
* @return Address
*/
protected static native Address getInitJarEnd();
/**
* Gets the (inclusive) start address of the boot heap.
*
* @return Address
*/
protected static native Address getBootHeapStart();
/**
* Gets the (exclusive) end address of the boot heap.
*
* @return Address
*/
protected static native Address getBootHeapEnd();
public static native long getTimeStampCounter();
/**
* Gets information of the JNode kernel command line.
*
* @param destination
* If non-null, the commandline is copied into this array.
* @return The maximum length of the command line
*/
protected static native int getCmdLine(byte[] destination);
/**
* Gets the processor that currently runs the active thread.
*
* @return The current processor.
* @throws PragmaUninterruptible
*/
public static native VmProcessor getCurrentProcessor() throws PragmaUninterruptible;
/**
* Trigger a yieldpoint
*/
static native void yieldPoint();
/**
* Gets the address of the system dependent jump table used for native method indirection.
*
* @return The address of the system dependent jump table.
*/
public static native Address getJumpTable();
/**
* Read CPU identification data.
*
* If id is null, this method will return the length of the id array that is required to fit all data. If id is not null and long enough, it is filled with all identification data.
*
* @param id
* @return The required length of id.
*/
static native int getCPUID(int[] id);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?