MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ioctl

Method ioctl

source/kernel/devs/devinput.cpp:213–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213U32 DevInput::ioctl(KThread* thread, U32 request) {
214 CPU* cpu = thread->cpu;
215 U32 cmd = request & 0xFFFF;
216 KMemory* memory = thread->memory;
217
218 switch (cmd) {
219 case 0x4501: { // EVIOCGVERSION
220 U32 len = (request & 0x1fff0000) >> 16;
221 U32 buffer = IOCTL_ARG1;
222 if (len<4)
223 kpanic_fmt("Bad length for EVIOCGVERSION: %d", len);
224 memory->writed(buffer, this->version);
225 return 4;
226 }
227 case 0x4502: { // EVIOCGID
228// struct input_id {
229// __u16 bustype;
230// __u16 vendor;
231// __u16 product;
232// __u16 version;
233// };
234 U32 len = (request & 0x1fff0000) >> 16;
235 U32 buffer = IOCTL_ARG1;
236 if (len!=8)
237 kpanic_fmt("Bad length for EVIOCGID: %d",len);
238 memory->writew(buffer, this->bustype);
239 memory->writew(buffer + 2, this->vendor);
240 memory->writew(buffer + 4, this->product);
241 memory->writew(buffer + 6, this->version);
242 return 0;
243 }
244 case 0x4506: { // EVIOCGNAME
245 U32 len = (request & 0x1fff0000) >> 16;
246 U32 buffer = IOCTL_ARG1;
247 U32 todo = std::min((U32)name.length(), len);
248 memory->memcpy(buffer, this->name.c_str(), todo);
249 return todo;
250 }
251 case 0x4507: { // EVIOCGPHYS
252 U32 len = (request & 0x1fff0000) >> 16;
253 U32 buffer = IOCTL_ARG1;
254 U32 todo = std::min((U32)name.length(), len);
255 memory->memcpy(buffer, this->name.c_str(), todo);
256 return todo;
257 }
258 case 0x4508: { // EVIOCGUNIQ
259 U32 len = (request & 0x1fff0000) >> 16;
260 U32 buffer = IOCTL_ARG1;
261 U32 todo = std::min((U32)name.length(), len);
262 memory->memcpy(buffer, this->name.c_str(), todo);
263 return todo;
264 }
265 case 0x4509: { // EVIOCGPROP
266 U32 len = (request & 0x1fff0000) >> 16;
267 U32 buffer = IOCTL_ARG1;
268 if (len<4)
269 kpanic_fmt("Bad length for EVIOCGBIT: %d", len);
270 memory->writed(buffer, this->prop);

Callers

nothing calls this directly

Calls 14

kpanic_fmtFunction · 0.85
minFunction · 0.85
writeBitFunction · 0.85
kpanicFunction · 0.85
writeAbsFunction · 0.85
memcpyMethod · 0.80
memsetMethod · 0.80
writedMethod · 0.45
writewMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45
writebMethod · 0.45

Tested by

no test coverage detected