summaryrefslogtreecommitdiff
path: root/include/kernel
diff options
context:
space:
mode:
authorSergi Granell2017-11-29 23:38:29 +0100
committerdevnoname1202017-11-29 23:38:29 +0100
commita512c73dd92549475ccc90cd7a5bf3482142733a (patch)
treec2083e3307b6effddfb910d7960c60fcce346b4b /include/kernel
parentAdd kscePervasiveUartSetBaudrate NID (diff)
downloadvds-libraries-a512c73dd92549475ccc90cd7a5bf3482142733a.tar.gz
Add psp2kern/{lowio/pervasive.h, power.h, syscon.h, uart.h}, minor nits (#255)
* Add psp2kern/{lowio/pervasive.h, power.h, syscon.h, uart.h}, minor nits * Fix psp2kern/power.h kernelgroup * Remove stray kscePervasiveUartSetBaudrate from psp2kern/uart.h * Add missing docs * Documentation improvements
Diffstat (limited to '')
-rw-r--r--include/kernel/bt.h3
-rw-r--r--include/kernel/ctrl.h8
-rw-r--r--include/kernel/lowio/gpio.h6
-rw-r--r--include/kernel/lowio/i2c.h6
-rw-r--r--include/kernel/lowio/pervasive.h44
-rw-r--r--include/kernel/power.h224
-rw-r--r--include/kernel/syscon.h227
-rw-r--r--include/kernel/uart.h20
8 files changed, 527 insertions, 11 deletions
diff --git a/include/kernel/bt.h b/include/kernel/bt.h
index be85864..32dc38c 100644
--- a/include/kernel/bt.h
+++ b/include/kernel/bt.h
@@ -337,4 +337,5 @@ int sceBtUnregisterCallback(SceUID cb);
#ifdef __cplusplus
}
#endif
-#endif
+
+#endif /* _PSP2_KERNEL_BT_H_ */
diff --git a/include/kernel/ctrl.h b/include/kernel/ctrl.h
index aa9f367..5d5dcf9 100644
--- a/include/kernel/ctrl.h
+++ b/include/kernel/ctrl.h
@@ -1,5 +1,5 @@
-#ifndef _PSP2_KERNEL_CTRL_H_
-#define _PSP2_KERNEL_CTRL_H_
+#ifndef _PSP2_KERN_CTRL_H_
+#define _PSP2_KERN_CTRL_H_
#include <psp2kern/types.h>
@@ -14,7 +14,7 @@ typedef enum SceCtrlErrorCode {
} SceCtrlErrorCode;
/** Enumeration for the digital controller buttons.
- * @note - L1/R1/L3/R3 only can bind using ::sceCtrlReadBufferPositiveExt2
+ * @note - L1/R1/L3/R3 only can bind using ::sceCtrlReadBufferPositiveExt2
*/
typedef enum SceCtrlButtons {
SCE_CTRL_SELECT = 0x00000001, //!< Select button.
@@ -295,4 +295,4 @@ int sceCtrlRegisterVirtualControllerDriver(SceCtrlVirtualControllerDriver *drive
}
#endif
-#endif /* _PSP2CTRL_H_ */
+#endif /* _PSP2_KERN_CTRL_H_ */
diff --git a/include/kernel/lowio/gpio.h b/include/kernel/lowio/gpio.h
index 944acbd..49322d4 100644
--- a/include/kernel/lowio/gpio.h
+++ b/include/kernel/lowio/gpio.h
@@ -1,5 +1,5 @@
-#ifndef _PSP2_LOWIO_GPIO_H_
-#define _PSP2_LOWIO_GPIO_H_
+#ifndef _PSP2_KERN_LOWIO_GPIO_H_
+#define _PSP2_KERN_LOWIO_GPIO_H_
#include <psp2kern/types.h>
@@ -38,5 +38,5 @@ int sceGpioQueryIntr(int bus, int port);
}
#endif
-#endif /* _PSP2_LOWIO_GPIO_H_ */
+#endif /* _PSP2_KERN_LOWIO_GPIO_H_ */
diff --git a/include/kernel/lowio/i2c.h b/include/kernel/lowio/i2c.h
index 5a49f77..961f1df 100644
--- a/include/kernel/lowio/i2c.h
+++ b/include/kernel/lowio/i2c.h
@@ -1,5 +1,5 @@
-#ifndef _PSP2_LOWIO_I2C_H_
-#define _PSP2_LOWIO_I2C_H_
+#ifndef _PSP2_KERN_LOWIO_I2C_H_
+#define _PSP2_KERN_LOWIO_I2C_H_
#include <psp2kern/types.h>
@@ -38,5 +38,5 @@ int sceI2cSetDebugHandlers(int bus, SceI2cDebugHandlers *debug_handlers);
}
#endif
-#endif /* _PSP2_LOWIO_I2C_H_ */
+#endif /* _PSP2_KERN_LOWIO_I2C_H_ */
diff --git a/include/kernel/lowio/pervasive.h b/include/kernel/lowio/pervasive.h
new file mode 100644
index 0000000..24a4ac4
--- /dev/null
+++ b/include/kernel/lowio/pervasive.h
@@ -0,0 +1,44 @@
+#ifndef _PSP2_KERN_LOWIO_PERVASIVE_H_
+#define _PSP2_KERN_LOWIO_PERVASIVE_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+"C" {
+#endif
+
+int scePervasiveUartClockDisable(int port);
+int scePervasiveUartResetEnable(int port);
+int scePervasiveUartResetDisable(int port);
+int scePervasiveUartClockEnable(int port);
+int scePervasiveUartSetBaudrate(int port, unsigned int baudrate);
+
+int scePervasiveGpioResetEnable(void);
+int scePervasiveGpioResetDisable(void);
+int scePervasiveGpioClockEnable(void);
+int scePervasiveGpioClockDisable(void);
+
+int scePervasiveSpiResetEnable(int port);
+int scePervasiveSpiResetDisable(int port);
+int scePervasiveSpiClockDisable(int port);
+int scePervasiveSpiClockEnable(int port);
+
+int scePervasiveDsiResetEnable(int port, unsigned int mask);
+int scePervasiveDsiResetDisable(int port, unsigned int mask);
+int scePervasiveDsiClockEnable(int port, unsigned int mask);
+int scePervasiveDsiClockDisable(int port, unsigned int mask);
+
+int scePervasiveMsifResetEnable(void);
+int scePervasiveMsifResetDisable(void);
+int scePervasiveMsifClockEnable(void);
+int scePervasiveMsifClockDisable(void);
+int scePervasiveMsifSetClock(unsigned int clock);
+
+int scePervasiveRemovableMemoryGetCardInsertState(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERN_LOWIO_PERVASIVE_H_ */
+
diff --git a/include/kernel/power.h b/include/kernel/power.h
new file mode 100644
index 0000000..ed797be
--- /dev/null
+++ b/include/kernel/power.h
@@ -0,0 +1,224 @@
+#ifndef _PSP2_KERN_POWER_H_
+#define _PSP2_KERN_POWER_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum ScePowerCallbackType {
+ /** indicates the unit is suspending, seems to occur due to inactivity */
+ SCE_POWER_CB_SUSPENDING = 0x00010000,
+ /** indicates the unit is resuming from suspend mode */
+ SCE_POWER_CB_RESUMING = 0x00020000,
+ /** indicates the unit has finish resuming from suspend mode */
+ SCE_POWER_CB_RESUME_COMPLETE = 0x00040000
+} ScePowerCallbackType;
+
+/* Callbacks */
+
+/** Callback function prototype */
+typedef void (*ScePowerCallback)(int notifyId, int notifyCount, int powerInfo);
+
+/* Prototypes */
+
+/**
+ * Registers a ScePower Callback
+ *
+ * @param cbid - The UID of the specified callback
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerRegisterCallback(SceUID cbid);
+
+/**
+ * Unregister a callback
+ *
+ * @param cbid - The UID of the specified callback
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerUnregisterCallback(SceUID cbid);
+
+/**
+ * Returns battery charging status
+ *
+ * @return SCE_TRUE if under charge, SCE_FALSE otherwise
+ */
+SceBool scePowerIsBatteryCharging(void);
+
+/**
+ * Returns battery life percentage
+ *
+ * @return Battery life percentage
+ */
+int scePowerGetBatteryLifePercent(void);
+
+/**
+ * Check if a suspend is required
+ *
+ * @return SCE_TRUE if suspend is required, SCE_FALSE otherwise
+ */
+SceBool scePowerIsSuspendRequired(void);
+
+/**
+ * Check if AC is plugged in
+ *
+ * @return SCE_TRUE if plugged in, SCE_FALSE otherwise
+ */
+SceBool scePowerIsPowerOnline(void);
+
+/**
+ * Returns battery life time
+ *
+ * @return Battery life time in seconds
+ */
+int scePowerGetBatteryLifeTime(void);
+
+/**
+ * Returns battery remaining capacity
+ *
+ * @return battery remaining capacity in mAh (milliampere hour)
+ */
+int scePowerGetBatteryRemainCapacity(void);
+
+/**
+ * Returns battery state
+ *
+ * @return SCE_TRUE if battery is low, SCE_FALSE otherwise
+ */
+SceBool scePowerIsLowBattery(void);
+
+/**
+ * Returns battery full capacity
+ *
+ * @return battery full capacity in mAh (milliampere hour)
+ */
+int scePowerGetBatteryFullCapacity(void);
+
+/**
+ * Returns battery temperature
+ *
+ * @return temperature in degrees celcius * 100
+ */
+int scePowerGetBatteryTemp(void);
+
+/**
+ * Returns battery voltage
+ *
+ * @return battery voltage in mV (millivolts)
+ */
+int scePowerGetBatteryVolt(void);
+
+/**
+ * Returns battery state of health
+ *
+ * @return battery state of health percent
+ */
+int scePowerGetBatterySOH(void);
+
+/**
+ * Returns battery cycle count
+ *
+ * @return battery cycle count
+ */
+int scePowerGetBatteryCycleCount(void);
+
+/**
+ * Returns CPU clock frequency
+ *
+ * @return CPU clock frequency in Mhz
+ */
+int scePowerGetArmClockFrequency(void);
+
+/**
+ * Returns BUS clock frequency
+ *
+ * @return BUS clock frequency in Mhz
+ */
+int scePowerGetBusClockFrequency(void);
+
+/**
+ * Returns GPU clock frequency
+ *
+ * @return GPU clock frequency in Mhz
+ */
+int scePowerGetGpuClockFrequency(void);
+
+/**
+ * Returns GPU crossbar clock frequency
+ *
+ * @return GPU crossbar clock frequency in Mhz
+ */
+int scePowerGetGpuXbarClockFrequency(void);
+
+/**
+ * Requests PS Vita to do a cold reset
+ *
+ * @return always 0
+ */
+int scePowerRequestColdReset(void);
+
+/**
+ * Requests PS Vita to go into standby
+ *
+ * @return always 0
+ */
+int scePowerRequestStandby(void);
+
+/**
+ * Requests PS Vita to suspend
+ *
+ * @return always 0
+ */
+int scePowerRequestSuspend(void);
+
+/**
+ * Request display off
+ *
+ * @return always 0
+ */
+int scePowerRequestDisplayOff(void);
+
+/**
+ * Sets CPU clock frequency
+ *
+ * @param freq - Frequency to set in Mhz
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerSetArmClockFrequency(int freq);
+
+/**
+ * Sets BUS clock frequency
+ *
+ * @param freq - Frequency to set in Mhz
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerSetBusClockFrequency(int freq);
+
+/**
+ * Sets GPU clock frequency
+ *
+ * @param freq - Frequency to set in Mhz
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerSetGpuClockFrequency(int freq);
+
+/**
+ * Sets GPU crossbar clock frequency
+ *
+ * @param freq - Frequency to set in Mhz
+ *
+ * @return 0 on success, < 0 on error
+ */
+int scePowerSetGpuXbarClockFrequency(int freq);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERN_POWER_H_ */
diff --git a/include/kernel/syscon.h b/include/kernel/syscon.h
new file mode 100644
index 0000000..225f798
--- /dev/null
+++ b/include/kernel/syscon.h
@@ -0,0 +1,227 @@
+#ifndef _PSP2_KERN_SYSCON_H_
+#define _PSP2_KERN_SYSCON_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SCE_SYSCON_PACKET_TX_CMD_LO 0
+#define SCE_SYSCON_PACKET_TX_CMD_HI 1
+#define SCE_SYSCON_PACKET_TX_LENGTH 2
+#define SCE_SYSCON_PACKET_TX_DATA(i) (3 + (i))
+
+#define SCE_SYSCON_PACKET_RX_STATUS_LO 0
+#define SCE_SYSCON_PACKET_RX_STATUS_HI 1
+#define SCE_SYSCON_PACKET_RX_LENGTH 2
+#define SCE_SYSCON_PACKET_RX_RESULT 3
+#define SCE_SYSCON_PACKET_RX_DATA(i) (4 + (i))
+
+typedef enum SceSysconCmd {
+ SCE_SYSCON_CMD_RESET_DEVICE = 0x0C
+} SceSysconCmd;
+
+typedef enum SceSysconResetType {
+ SCE_SYSCON_RESET_TYPE_POWEROFF = 0x00,
+ SCE_SYSCON_RESET_TYPE_SUSPEND = 0x01,
+ SCE_SYSCON_RESET_TYPE_COLD_RESET = 0x02,
+ SCE_SYSCON_RESET_TYPE_SOFT_RESET = 0x11
+} SceSysconResetType;
+
+typedef struct SceSysconPacket {
+ struct SceSysconPacket *next;
+ unsigned int status;
+ SceUID semaId;
+ unsigned int unk;
+ unsigned char tx[32];
+ unsigned char rx[32];
+ unsigned int unk1[4];
+ int (*callback)(struct SceSysconPacket *packet, void *argp);
+ void *argp;
+ unsigned int time;
+ unsigned int unk2[5];
+} SceSysconPacket; /* size 0x80 */
+
+/** A set of debug handlers for syscon, that you can set in sceSysconSetDebugHandlers(). */
+typedef struct SceSysconDebugHandlers {
+ /** Structure size (probably, unused). */
+ int size;
+ /** Callback ran right before running a packet, with a pointer to it passed as the first argument. */
+ void (*start)(SceSysconPacket *packet);
+ /** Callback ran right after finishing running a packet, with a pointer to it passed as the first argument. */
+ void (*end)(SceSysconPacket *packet);
+} SceSysconDebugHandlers;
+
+typedef int (*SceSysconCmdExecAsyncCallback)(SceSysconPacket *packet, void *argp);
+
+typedef void (*SceSysconCallback)(int enable, void *argp);
+
+/**
+ * Waits until the syscon is initialized.
+ *
+ * @return 0 on success.
+ */
+int sceSysconWaitInitialized(void);
+
+/**
+ * Execute synchronously a syscon packet.
+ *
+ * @param packet The packet to execute. Its tx member needs to be initialized.
+ * @param flags The packet flags. Check SceSysconPacketFlags.
+ *
+ * @return 0 on success.
+ */
+int sceSysconCmdExec(SceSysconPacket *packet, unsigned int flags);
+
+/**
+ * Execute asynchronously a syscon packet.
+ *
+ * @param packet The packet to execute. Its tx member needs to be initialized.
+ * @param flags The packet flags. Check SceSysconPacketFlags.
+ * @param callback The packet callback. Check the callback member of SceSysconPacket.
+ * @param argp The second argument that will be passed to the callback when executed.
+ *
+ * @return 0 on success.
+ */
+int sceSysconCmdExecAsync(SceSysconPacket *packet, unsigned int flags, SceSysconCmdExecAsyncCallback cb, void *argp);
+
+/**
+ * Wait for the currently queued syscon packets to be executed, or check if any are in the queue.
+ *
+ * @param packet The packet you want to check or wait for, or NULL if you want to check or wait for all the currently running packets.
+ * @param noWait Set to 1 if you just want to check the packet status, or 0 if you want the function to return only when the packet queue is empty.
+ *
+ * @return 1 if packets are still running (and noWait was set to 1), 0 on success, < 0 otherwise.
+ */
+int sceSysconCmdSync(SceSysconPacket *packet, int noWait);
+
+/**
+ * Reset the device.
+ *
+ * @param type The reset type value, one of SceSysconResetType.
+ * @param mode The resetting mode (?).
+ *
+ * @return 0 on success.
+ */
+int sceSysconResetDevice(int type, int mode);
+
+int sceSysconReadCommand(unsigned short cmd, void *buffer, unsigned int size);
+int sceSysconSendCommand(unsigned short cmd, const void *buffer, unsigned int size);
+
+/**
+ * Set the debug handlers.
+ *
+ * @return 0.
+ */
+int sceSysconSetDebugHandlers(const SceSysconDebugHandlers *handlers);
+
+/**
+ * Turn a LED on or off.
+ *
+ * @param led The LED id.
+ * @param enable Set this value to 1 if you want the LED to turn on, or 0 if you want it to turn off.
+ *
+ * @return 0 on success.
+ */
+int sceSysconCtrlLED(int led, int enable);
+
+/**
+ * Set the memory stick power.
+ *
+ * @param power The new power value.
+ *
+ * @return 0 on success.
+ */
+int sceSysconCtrlMsPower(int power);
+
+/**
+ * Set the SD power.
+ *
+ * @param power The new power value.
+ *
+ * @return 0 on success.
+ */
+int sceSysconCtrlSdPower(int power);
+
+/**
+ * Set the ADV7533 HDMI CEC power.
+ *
+ * @param power The new power value.
+ *
+ * @return 0 on success.
+ */
+int sceSysconCtrlHdmiCecPower(int power);
+
+int sceSysconCtrlManualChargeMode(int);
+
+int sceSysconEnableHibernateIO(int);
+
+int sceSysconIduModeClear(void);
+int sceSysconIduModeSet(void);
+int sceSysconIsDownLoaderMode(void);
+
+int sceSysconLogStart(void);
+int sceSysconLogStartWaiting(void);
+int sceSysconLogReadData(unsigned short, void *buff, unsigned int size);
+
+int sceSysconShowModeClear(void);
+int sceSysconShowModeSet(void);
+
+/**
+ * Get the baryon version.
+ *
+ * @return The baryon version.
+ */
+int sceSysconGetBaryonVersion(void);
+
+/**
+ * Get the baryon timestamp.
+ *
+ * @return The baryon timestamp.
+ */
+unsigned long long sceSysconGetBaryonTimestamp();
+
+int sceSysconGetBatteryCalibData(int *, int *, int *, int *);
+int sceSysconGetHardwareInfo(void);
+int sceSysconGetHardwareInfo2(int *, int *, int *);
+int sceSysconGetLogInfo(int *);
+int sceSysconGetManualChargeMode(int *);
+int sceSysconGetManufacturesStatus(int *);
+int sceSysconGetTemperatureLog(int *);
+int sceSysconGetUsbDetStatus(int *);
+
+int sceSysconClearTemperatureLog(int);
+
+int sceSysconBeginConfigstorageTransaction(void);
+int sceSysconCommitConfigstorageTransaction(void);
+int sceSysconEndConfigstorageTransaction(void);
+int sceSysconLoadConfigstorageScript(unsigned short, const void *buff, unsigned int size);
+int sceSysconVerifyConfigstorageScript(unsigned short, const void *buff, unsigned int size);
+
+/**
+ * Set the low battery callback, that will be ran when the battery is low.
+ *
+ * @param callback The callback function.
+ * @param argp The second argument that will be passed to the callback.
+ *
+ * @return 0.
+ */
+int sceSysconSetLowBatteryCallback(SceSysconCallback callback, void *argp);
+
+/**
+ * Set the thermal alert callback, that will be ran when the temperature reaches a critical point.
+ *
+ * @param callback The callback function.
+ * @param argp The second argument that will be passed to the callback.
+ *
+ * @return 0.
+ */
+int sceSysconSetThermalAlertCallback(SceSysconCallback callback, void *argp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERN_SYSCON_H_ */
+
diff --git a/include/kernel/uart.h b/include/kernel/uart.h
new file mode 100644
index 0000000..97eebfd
--- /dev/null
+++ b/include/kernel/uart.h
@@ -0,0 +1,20 @@
+#ifndef _PSP2_KERN_UART_H_
+#define _PSP2_KERN_UART_H_
+
+#include <psp2kern/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int sceUartInit(int port);
+int sceUartReadAvailable(int port);
+int sceUartRead(int port);
+int sceUartWrite(int port, char data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PSP2_KERN_UART_H_ */
+