MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysEndpointDequeue

Function SysEndpointDequeue

Kernel/src/arch/x86_64/syscalls.cpp:2428–2457  ·  view source on GitHub ↗

//////////////////////// \brief SysEndpointDequeue (endpoint, id, size, data) Accept a pending connection on an interface and return a new MessageEndpoint \param endpoint (handle_id_t) Handle ID of specified endpoint \param id (uint64_t*) Returned message ID \param size (uint32_t*) Returned message Size \param data (uint8_t*) Message data buffer \return 0 on empty, 1 on success, negative error

Source from the content-addressed store, hash-verified

2426/// \return 0 on empty, 1 on success, negative error code on failure
2427/////////////////////////////
2428long SysEndpointDequeue(regs64_t* r){
2429 process_t* currentProcess = Scheduler::GetCurrentProcess();
2430
2431 Handle* endpHandle;
2432 if(Scheduler::FindHandle(currentProcess, SC_ARG0(r), &endpHandle)){
2433 Log::Warning("SysEndpointDequeue: Invalid handle ID %d", SC_ARG0(r));
2434 return -EINVAL;
2435 }
2436
2437 if(!endpHandle->ko->IsType(MessageEndpoint::TypeID())){
2438 Log::Warning("SysEndpointDequeue: Invalid handle type (ID %d)", SC_ARG0(r));
2439 return -EINVAL;
2440 }
2441
2442 if(!Memory::CheckUsermodePointer(SC_ARG1(r), sizeof(uint64_t), currentProcess->addressSpace)){
2443 return -EFAULT;
2444 }
2445
2446 if(!Memory::CheckUsermodePointer(SC_ARG2(r), sizeof(uint16_t), currentProcess->addressSpace)){
2447 return -EFAULT;
2448 }
2449
2450 MessageEndpoint* endpoint = reinterpret_cast<MessageEndpoint*>(endpHandle->ko.get());
2451
2452 if(!Memory::CheckUsermodePointer(SC_ARG3(r), endpoint->GetMaxMessageSize(), currentProcess->addressSpace)){
2453 return -EFAULT;
2454 }
2455
2456 return endpoint->Read(reinterpret_cast<uint64_t*>(SC_ARG1(r)), reinterpret_cast<uint16_t*>(SC_ARG2(r)), reinterpret_cast<uint64_t*>(SC_ARG3(r)));
2457}
2458
2459/////////////////////////////
2460/// \brief SysEndpointCall (endpoint, id, data, rID, rData, size, timeout)

Callers

nothing calls this directly

Calls 8

GetCurrentProcessFunction · 0.85
FindHandleFunction · 0.85
WarningFunction · 0.85
CheckUsermodePointerFunction · 0.85
IsTypeMethod · 0.80
GetMaxMessageSizeMethod · 0.80
getMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected