mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-09-25 12:53:19 +02:00
haze: prefer more specific data types
This commit is contained in:
parent
d0364c31cc
commit
6811e57870
@ -42,6 +42,6 @@ namespace haze {
|
|||||||
|
|
||||||
using Result = ::ams::Result;
|
using Result = ::ams::Result;
|
||||||
|
|
||||||
static constexpr size_t UsbBulkPacketBufferSize = 1_MB;
|
static constexpr u32 UsbBulkPacketBufferSize = 1_MB;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
namespace haze {
|
namespace haze {
|
||||||
|
|
||||||
constexpr inline size_t PtpUsbBulkHighSpeedMaxPacketLength = 0x200;
|
constexpr inline u32 PtpUsbBulkHighSpeedMaxPacketLength = 0x200;
|
||||||
constexpr inline size_t PtpUsbBulkHeaderLength = 2 * sizeof(u32) + 2 * sizeof(u16);
|
constexpr inline u32 PtpUsbBulkHeaderLength = 2 * sizeof(u32) + 2 * sizeof(u16);
|
||||||
constexpr inline size_t PtpStringMaxLength = 255;
|
constexpr inline u32 PtpStringMaxLength = 255;
|
||||||
|
|
||||||
enum PtpUsbBulkContainerType : u16 {
|
enum PtpUsbBulkContainerType : u16 {
|
||||||
PtpUsbBulkContainerType_Undefined = 0,
|
PtpUsbBulkContainerType_Undefined = 0,
|
||||||
|
@ -24,8 +24,8 @@ namespace haze {
|
|||||||
class PtpDataBuilder final {
|
class PtpDataBuilder final {
|
||||||
private:
|
private:
|
||||||
AsyncUsbServer *m_server;
|
AsyncUsbServer *m_server;
|
||||||
size_t m_transmitted_size;
|
u32 m_transmitted_size;
|
||||||
size_t m_offset;
|
u32 m_offset;
|
||||||
u8 *m_data;
|
u8 *m_data;
|
||||||
bool m_disabled;
|
bool m_disabled;
|
||||||
private:
|
private:
|
||||||
@ -110,7 +110,7 @@ namespace haze {
|
|||||||
HAZE_ASSERT(m_offset == 0 && m_transmitted_size == 0);
|
HAZE_ASSERT(m_offset == 0 && m_transmitted_size == 0);
|
||||||
|
|
||||||
/* Declare how many bytes the data will require to write. */
|
/* Declare how many bytes the data will require to write. */
|
||||||
size_t data_size = 0;
|
u32 data_size = 0;
|
||||||
{
|
{
|
||||||
/* Temporarily disable writing to calculate the size.*/
|
/* Temporarily disable writing to calculate the size.*/
|
||||||
m_disabled = true;
|
m_disabled = true;
|
||||||
|
@ -56,7 +56,7 @@ namespace haze {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ReadBuffer(u8 *buffer, size_t count, size_t *out_read_count) {
|
Result ReadBuffer(u8 *buffer, u32 count, u32 *out_read_count) {
|
||||||
*out_read_count = 0;
|
*out_read_count = 0;
|
||||||
|
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
@ -80,7 +80,7 @@ namespace haze {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Result Read(T *out_t) {
|
Result Read(T *out_t) {
|
||||||
size_t read_count;
|
u32 read_count;
|
||||||
u8 bytes[sizeof(T)];
|
u8 bytes[sizeof(T)];
|
||||||
|
|
||||||
R_TRY(this->ReadBuffer(bytes, sizeof(T), std::addressof(read_count)));
|
R_TRY(this->ReadBuffer(bytes, sizeof(T), std::addressof(read_count)));
|
||||||
|
@ -41,7 +41,7 @@ namespace haze {
|
|||||||
|
|
||||||
bool GetConfigured() const;
|
bool GetConfigured() const;
|
||||||
Event *GetCompletionEvent(UsbSessionEndpoint ep) const;
|
Event *GetCompletionEvent(UsbSessionEndpoint ep) const;
|
||||||
Result TransferAsync(UsbSessionEndpoint ep, void *buffer, size_t size, u32 *out_urb_id);
|
Result TransferAsync(UsbSessionEndpoint ep, void *buffer, u32 size, u32 *out_urb_id);
|
||||||
Result GetTransferResult(UsbSessionEndpoint ep, u32 urb_id, u32 *out_transferred_size);
|
Result GetTransferResult(UsbSessionEndpoint ep, u32 urb_id, u32 *out_transferred_size);
|
||||||
Result SetZeroLengthTermination(bool enable);
|
Result SetZeroLengthTermination(bool enable);
|
||||||
};
|
};
|
||||||
|
@ -25,19 +25,18 @@ namespace haze {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PtpObjectHeap::Initialize() {
|
void PtpObjectHeap::Initialize() {
|
||||||
size_t mem_used = 0;
|
|
||||||
|
|
||||||
/* If we're already initialized, skip re-initialization. */
|
/* If we're already initialized, skip re-initialization. */
|
||||||
if (m_heap_block_size != 0) {
|
if (m_heap_block_size != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Estimate how much memory we can reserve. */
|
/* Estimate how much memory we can reserve. */
|
||||||
|
size_t mem_used = 0;
|
||||||
HAZE_R_ABORT_UNLESS(svcGetInfo(std::addressof(mem_used), InfoType_UsedMemorySize, svc::CurrentProcess, 0));
|
HAZE_R_ABORT_UNLESS(svcGetInfo(std::addressof(mem_used), InfoType_UsedMemorySize, svc::CurrentProcess, 0));
|
||||||
HAZE_ASSERT(mem_used > LibnxReservedMemorySize);
|
HAZE_ASSERT(mem_used > LibnxReservedMemorySize);
|
||||||
mem_used -= LibnxReservedMemorySize;
|
mem_used -= LibnxReservedMemorySize;
|
||||||
|
|
||||||
/* Take the rest for ourselves. */
|
/* Calculate size of blocks. */
|
||||||
m_heap_block_size = mem_used / NumHeapBlocks;
|
m_heap_block_size = mem_used / NumHeapBlocks;
|
||||||
HAZE_ASSERT(m_heap_block_size > 0);
|
HAZE_ASSERT(m_heap_block_size > 0);
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ namespace haze {
|
|||||||
s64 offset = 0;
|
s64 offset = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
/* Get the next batch. */
|
/* Get the next batch. */
|
||||||
size_t bytes_read;
|
u64 bytes_read;
|
||||||
R_TRY(m_fs.ReadFile(std::addressof(file), offset, g_fs_buffer, FsBufferSize, FsReadOption_None, std::addressof(bytes_read)));
|
R_TRY(m_fs.ReadFile(std::addressof(file), offset, g_fs_buffer, FsBufferSize, FsReadOption_None, std::addressof(bytes_read)));
|
||||||
|
|
||||||
offset += bytes_read;
|
offset += bytes_read;
|
||||||
@ -726,7 +726,7 @@ namespace haze {
|
|||||||
/* Begin writing to the filesystem. */
|
/* Begin writing to the filesystem. */
|
||||||
while (true) {
|
while (true) {
|
||||||
/* Read as many bytes as we can. */
|
/* Read as many bytes as we can. */
|
||||||
size_t bytes_received;
|
u32 bytes_received;
|
||||||
const Result read_res = dp.ReadBuffer(g_fs_buffer, FsBufferSize, std::addressof(bytes_received));
|
const Result read_res = dp.ReadBuffer(g_fs_buffer, FsBufferSize, std::addressof(bytes_received));
|
||||||
|
|
||||||
/* Write to the file. */
|
/* Write to the file. */
|
||||||
|
@ -233,7 +233,7 @@ namespace haze {
|
|||||||
return std::addressof(m_endpoints[ep]->CompletionEvent);
|
return std::addressof(m_endpoints[ep]->CompletionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result UsbSession::TransferAsync(UsbSessionEndpoint ep, void *buffer, size_t size, u32 *out_urb_id) {
|
Result UsbSession::TransferAsync(UsbSessionEndpoint ep, void *buffer, u32 size, u32 *out_urb_id) {
|
||||||
R_RETURN(usbDsEndpoint_PostBufferAsync(m_endpoints[ep], buffer, size, out_urb_id));
|
R_RETURN(usbDsEndpoint_PostBufferAsync(m_endpoints[ep], buffer, size, out_urb_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user