Index: ioemu/Makefile.target =================================================================== --- ioemu.orig/Makefile.target 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/Makefile.target 2006-08-06 02:14:09.794902973 +0100 @@ -302,7 +302,7 @@ endif # must use static linking to avoid leaving stuff in virtual address space -VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o +VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o ifdef CONFIG_WIN32 VL_OBJS+=tap-win32.o Index: ioemu/configure =================================================================== --- ioemu.orig/configure 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/configure 2006-08-06 02:14:09.795902861 +0100 @@ -75,8 +75,8 @@ bigendian="no" mingw32="no" EXESUF="" -gdbstub="yes" -slirp="yes" +gdbstub="no" +slirp="no" adlib="no" oss="no" dsound="no" @@ -749,6 +749,8 @@ if expr $target : '.*-softmmu' > /dev/null ; then target_softmmu="yes" fi +#for support 256M guest +target_softmmu="yes" target_user_only="no" if expr $target : '.*-user' > /dev/null ; then target_user_only="yes" Index: ioemu/cpu-all.h =================================================================== --- ioemu.orig/cpu-all.h 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/cpu-all.h 2006-08-06 02:14:09.796902750 +0100 @@ -690,7 +690,9 @@ void page_set_flags(target_ulong start, target_ulong end, int flags); void page_unprotect_range(target_ulong data, target_ulong data_size); +#ifdef CONFIG_DM #define SINGLE_CPU_DEFINES +#endif #ifdef SINGLE_CPU_DEFINES #if defined(TARGET_I386) @@ -745,6 +747,12 @@ #endif +#else /* SINGLE_CPU_DEFINES */ + +#define CPUState CPUX86State +#define cpu_init cpu_x86_init +int main_loop(void); + #endif /* SINGLE_CPU_DEFINES */ void cpu_dump_state(CPUState *env, FILE *f, Index: ioemu/disas.h =================================================================== --- ioemu.orig/disas.h 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/disas.h 2006-08-06 02:14:09.796902750 +0100 @@ -1,6 +1,7 @@ #ifndef _QEMU_DISAS_H #define _QEMU_DISAS_H +#ifndef CONFIG_DM /* Disassemble this for me please... (debugging). */ void disas(FILE *out, void *code, unsigned long size); void target_disas(FILE *out, target_ulong code, target_ulong size, int flags); @@ -17,5 +18,6 @@ const char *disas_strtab; struct syminfo *next; } *syminfos; +#endif /* !CONFIG_DM */ #endif /* _QEMU_DISAS_H */ Index: ioemu/exec-all.h =================================================================== --- ioemu.orig/exec-all.h 2006-08-06 02:14:04.798459982 +0100 +++ ioemu/exec-all.h 2006-08-06 02:14:09.796902750 +0100 @@ -509,7 +509,7 @@ extern int tb_invalidated_flag; -#if !defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) && !defined(CONFIG_DM) void tlb_fill(target_ulong addr, int is_write, int is_user, void *retaddr); @@ -536,7 +536,7 @@ #endif -#if defined(CONFIG_USER_ONLY) +#if defined(CONFIG_USER_ONLY) || defined(CONFIG_DM) static inline target_ulong get_phys_addr_code(CPUState *env, target_ulong addr) { return addr; Index: ioemu/hw/pc.c =================================================================== --- ioemu.orig/hw/pc.c 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/hw/pc.c 2006-08-06 02:14:09.797902638 +0100 @@ -73,6 +73,7 @@ } } +#ifndef CONFIG_DM /* IRQ handling */ int cpu_get_pic_interrupt(CPUState *env) { @@ -89,6 +90,7 @@ intno = pic_read_irq(isa_pic); return intno; } +#endif /* CONFIG_DM */ static void pic_irq_request(void *opaque, int level) { @@ -400,6 +402,7 @@ /*************************************************/ +#ifndef CONFIG_DM static void putb(uint8_t **pp, int val) { uint8_t *q; @@ -546,6 +549,7 @@ float_pointer_struct[10] = -mpf_checksum(float_pointer_struct, q - float_pointer_struct); } +#endif /* !CONFIG_DM */ static const int ide_iobase[2] = { 0x1f0, 0x170 }; @@ -626,12 +630,14 @@ /* init CPUs */ for(i = 0; i < smp_cpus; i++) { env = cpu_init(); +#ifndef CONFIG_DM if (i != 0) env->hflags |= HF_HALTED_MASK; if (smp_cpus > 1) { /* XXX: enable it in all cases */ env->cpuid_features |= CPUID_APIC; } +#endif /* !CONFIG_DM */ register_savevm("cpu", i, 3, cpu_save, cpu_load, env); qemu_register_reset(main_cpu_reset, env); if (pci_enabled) { @@ -690,6 +696,7 @@ bochs_bios_init(); +#ifndef CONFIG_DM if (linux_boot) { uint8_t bootsect[512]; uint8_t old_bootsect[512]; @@ -745,6 +752,7 @@ /* loader type */ stw_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x210, 0x01); } +#endif /* !CONFIG_DM */ if (pci_enabled) { pci_bus = i440fx_init(); @@ -783,9 +791,11 @@ isa_pic = pic_init(pic_irq_request, first_cpu); pit = pit_init(0x40, 0); pcspk_init(pit); +#ifndef CONFIG_DM if (pci_enabled) { pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic); } +#endif /* !CONFIG_DM */ for(i = 0; i < MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { Index: ioemu/hw/vga_int.h =================================================================== --- ioemu.orig/hw/vga_int.h 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/hw/vga_int.h 2006-08-06 02:14:09.797902638 +0100 @@ -28,7 +28,7 @@ #define ST01_DISP_ENABLE 0x01 /* bochs VBE support */ -#define CONFIG_BOCHS_VBE +//#define CONFIG_BOCHS_VBE #define VBE_DISPI_MAX_XRES 1600 #define VBE_DISPI_MAX_YRES 1200 Index: ioemu/monitor.c =================================================================== --- ioemu.orig/monitor.c 2006-08-06 02:14:04.798459982 +0100 +++ ioemu/monitor.c 2006-08-06 02:14:49.574468309 +0100 @@ -68,6 +68,12 @@ void term_flush(void) { +#ifdef CONFIG_DM + if (term_outbuf_index > 0 && !monitor_hd) { + fwrite(term_outbuf, term_outbuf_index, 1, stderr); + term_outbuf_index = 0; + } +#endif if (term_outbuf_index > 0) { qemu_chr_write(monitor_hd, term_outbuf, term_outbuf_index); term_outbuf_index = 0; @@ -106,6 +112,7 @@ va_end(ap); } +#ifndef CONFIG_DM static int monitor_fprintf(FILE *stream, const char *fmt, ...) { va_list ap; @@ -114,6 +121,7 @@ va_end(ap); return 0; } +#endif /* !CONFIG_DM */ static int compare_cmd(const char *name, const char *list) { @@ -227,6 +235,7 @@ return mon_cpu; } +#ifndef CONFIG_DM static void do_info_registers(void) { CPUState *env; @@ -280,6 +289,7 @@ { dump_exec_info(NULL, monitor_fprintf); } +#endif /* !CONFIG_DM */ static void do_info_history (void) { @@ -377,6 +387,7 @@ cpu_set_log(mask); } +#ifndef CONFIG_DM static void do_savevm(const char *filename) { if (qemu_savevm(filename) < 0) @@ -623,6 +634,7 @@ #endif term_printf("\n"); } +#endif /* !CONFIG_DM */ static void do_sum(uint32_t start, uint32_t size) { @@ -841,6 +853,7 @@ kbd_mouse_event(0, 0, 0, mouse_button_state); } +#ifndef CONFIG_DM static void do_ioport_read(int count, int format, int size, int addr, int has_index, int index) { uint32_t val; @@ -1031,6 +1044,7 @@ term_printf("kqemu support: not compiled\n"); #endif } +#endif /* !CONFIG_DM */ #ifdef CONFIG_PROFILER @@ -1152,6 +1166,7 @@ "filename", "save screen into PPM image 'filename'" }, { "log", "s", do_log, "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, +#ifndef CONFIG_DM { "savevm", "F", do_savevm, "filename", "save the whole virtual machine state to 'filename'" }, { "loadvm", "F", do_loadvm, @@ -1172,21 +1187,26 @@ "/fmt expr", "print expression value (use $reg for CPU register access)", }, { "i", "/ii.", do_ioport_read, "/fmt addr", "I/O port read" }, +#endif/* !CONFIG_DM */ { "sendkey", "s", do_send_key, "keys", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1')" }, +#ifndef CONFIG_DM { "system_reset", "", do_system_reset, "", "reset the system" }, { "system_powerdown", "", do_system_powerdown, "", "send system power down event" }, +#endif /* !CONFIG_DM */ { "sum", "ii", do_sum, "addr size", "compute the checksum of a memory region" }, { "usb_add", "s", do_usb_add, "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, { "usb_del", "s", do_usb_del, "device", "remove USB device 'bus.addr'" }, +#ifndef CONFIG_DM { "cpu", "i", do_cpu_set, "index", "set the default CPU" }, +#endif /* !CONFIG_DM */ { "mouse_move", "sss?", do_mouse_move, "dx dy [dz]", "send mouse move events" }, { "mouse_button", "i", do_mouse_button, @@ -1208,10 +1228,12 @@ "", "show the network state" }, { "block", "", do_info_block, "", "show the block devices" }, +#ifndef CONFIG_DM { "registers", "", do_info_registers, "", "show the cpu registers" }, { "cpus", "", do_info_cpus, "", "show infos for each CPU" }, +#endif /* !CONFIG_DM */ { "history", "", do_info_history, "", "show the command line history", }, { "irq", "", irq_info, @@ -1220,6 +1242,7 @@ "", "show i8259 (PIC) state", }, { "pci", "", pci_info, "", "show PCI info", }, +#ifndef CONFIG_DM #if defined(TARGET_I386) { "tlb", "", tlb_info, "", "show virtual to physical memory mappings", }, @@ -1230,6 +1253,7 @@ "", "show dynamic compiler info", }, { "kqemu", "", do_info_kqemu, "", "show kqemu information", }, +#endif /* !CONFIG_DM */ { "usb", "", usb_info, "", "show guest USB devices", }, { "usbhost", "", usb_host_info, @@ -1243,6 +1267,7 @@ /*******************************************************************/ +#ifndef CONFIG_DM static const char *pch; static jmp_buf expr_env; @@ -1786,6 +1811,7 @@ *pp = pch; return 0; } +#endif /* !CONFIG_DM */ static int get_str(char *buf, int buf_size, const char **pp) { @@ -1852,8 +1878,10 @@ return 0; } +#ifndef CONFIG_DM static int default_fmt_format = 'x'; static int default_fmt_size = 4; +#endif /* !CONFIG_DM */ #define MAX_ARGS 16 @@ -1861,7 +1889,10 @@ { const char *p, *pstart, *typestr; char *q; - int c, nb_args, len, i, has_arg; + int c, nb_args, len, i; +#ifndef CONFIG_DM + int has_arg; +#endif /* !CONFIG_DM */ term_cmd_t *cmd; char cmdname[256]; char buf[1024]; @@ -1953,6 +1984,7 @@ args[nb_args++] = str; } break; +#ifndef CONFIG_DM case '/': { int count, format, size; @@ -2085,6 +2117,7 @@ } } break; +#endif /* !CONFIG_DM */ case '-': { int has_option; @@ -2111,6 +2144,11 @@ args[nb_args++] = (void *)has_option; } break; +#ifdef CONFIG_DM + /* TODO: add more commands we need here to support hvm device model */ + case '/': + case 'i': +#endif /* CONFIG_DM */ default: bad_type: term_printf("%s: unknown type '%c'\n", cmdname, c); @@ -2161,6 +2199,7 @@ return; } +#ifndef CONFIG_DM static void cmd_completion(const char *name, const char *list) { const char *p, *pstart; @@ -2354,6 +2393,11 @@ for(i = 0; i < nb_args; i++) qemu_free(args[i]); } +#else +void readline_find_completion(const char *cmdline) +{ +} +#endif /* !CONFIG_DM */ static int term_can_read(void *opaque) { Index: ioemu/vl.c =================================================================== --- ioemu.orig/vl.c 2006-08-06 02:14:04.797460093 +0100 +++ ioemu/vl.c 2006-08-06 02:14:09.802902081 +0100 @@ -422,12 +422,15 @@ void hw_error(const char *fmt, ...) { va_list ap; +#ifndef CONFIG_DM CPUState *env; +#endif /* !CONFIG_DM */ va_start(ap, fmt); fprintf(stderr, "qemu: hardware error: "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); +#ifndef CONFIG_DM for(env = first_cpu; env != NULL; env = env->next_cpu) { fprintf(stderr, "CPU #%d:\n", env->cpu_index); #ifdef TARGET_I386 @@ -436,6 +439,7 @@ cpu_dump_state(env, stderr, fprintf, 0); #endif } +#endif /* !CONFIG_DM */ va_end(ap); abort(); } @@ -4336,6 +4340,7 @@ return ret; } +#ifndef CONFIG_DM /***********************************************************/ /* cpu save/restore */ @@ -4770,6 +4775,25 @@ } return 0; } +#else /* CONFIG_DM */ +void cpu_save(QEMUFile *f, void *opaque) +{ +} + +int cpu_load(QEMUFile *f, void *opaque, int version_id) +{ + return 0; +} + +static void ram_save(QEMUFile *f, void *opaque) +{ +} + +static int ram_load(QEMUFile *f, void *opaque, int version_id) +{ + return 0; +} +#endif /* CONFIG_DM */ /***********************************************************/ /* machine registration */ @@ -6054,6 +6078,7 @@ socket_init(); #endif +#ifndef CONFIG_DM /* init network clients */ if (nb_net_clients == 0) { /* if no clients, we use a default config */ @@ -6063,6 +6088,7 @@ "user"); nb_net_clients = 2; } +#endif /* !CONFIG_DM */ for(i = 0;i < nb_net_clients; i++) { if (net_client_init(net_clients[i]) < 0) 1' href='#n311'>311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791
/*
ChibiOS - Copyright (C) 2006-2014 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file ch.cpp
* @brief C++ wrapper code.
*
* @addtogroup cpp_library
* @{
*/
#include "ch.hpp"
namespace chibios_rt {
/*------------------------------------------------------------------------*
* chibios_rt::System *
*------------------------------------------------------------------------*/
void System::init(void) {
chSysInit();
}
void System::lock(void) {
chSysLock();
}
void System::unlock(void) {
chSysUnlock();
}
void System::lockFromIsr(void) {
chSysLockFromISR();
}
void System::unlockFromIsr(void) {
chSysUnlockFromISR();
}
systime_t System::getTime(void) {
return chVTGetSystemTimeX();
}
bool System::isTimeWithin(systime_t start, systime_t end) {
return chVTIsSystemTimeWithinX(start, end);
}
/*------------------------------------------------------------------------*
* chibios_rt::Core *
*------------------------------------------------------------------------*/
void *Core::alloc(size_t size) {
return chCoreAlloc(size);
}
void *Core::allocI(size_t size) {
return chCoreAllocI(size);
}
size_t Core::getStatus(void) {
return chCoreStatus();
}
/*------------------------------------------------------------------------*
* chibios_rt::Timer *
*------------------------------------------------------------------------*/
void Timer::setI(systime_t time, vtfunc_t vtfunc, void *par) {
chVTSetI(&timer_ref, time, vtfunc, par);
}
void Timer::resetI() {
if (chVTIsArmedI(&timer_ref))
chVTDoResetI(&timer_ref);
}
bool Timer::isArmedI(void) {
return chVTIsArmedI(&timer_ref);
}
/*------------------------------------------------------------------------*
* chibios_rt::ThreadReference *
*------------------------------------------------------------------------*/
void ThreadReference::stop(void) {
chSysHalt("invoked unimplemented method stop()");
}
msg_t ThreadReference::suspend(void) {
msg_t msg;
chSysLock();
chDbgAssert(thread_ref != NULL,
"already referenced");
thread_ref = chThdGetSelfX();
chSchGoSleepS(CH_STATE_SUSPENDED);
msg = thread_ref->p_u.rdymsg;
chSysUnlock();
return msg;
}
msg_t ThreadReference::suspendS(void) {
chDbgAssert(thread_ref == NULL,
"already referenced");
thread_ref = chThdGetSelfX();
chSchGoSleepS(CH_STATE_SUSPENDED);
return thread_ref->p_u.rdymsg;
}
void ThreadReference::resume(msg_t msg) {
chSysLock();
chDbgAssert(thread_ref != NULL,
"not referenced");
if (thread_ref) {
thread_t *tp = thread_ref;
thread_ref = NULL;
chSchWakeupS(tp, msg);
}
chSysUnlock();
}
void ThreadReference::resumeI(msg_t msg) {
chDbgAssert(thread_ref != NULL,
"not referenced");
if (thread_ref) {
thread_t *tp = thread_ref;
thread_ref = NULL;
tp->p_msg = msg;
chSchReadyI(tp);
}
}
void ThreadReference::requestTerminate(void) {
chDbgAssert(thread_ref != NULL,
"not referenced");
chThdTerminate(thread_ref);
}
#if CH_CFG_USE_WAITEXIT
msg_t ThreadReference::wait(void) {
chDbgAssert(thread_ref != NULL,
"not referenced");
msg_t msg = chThdWait(thread_ref);
thread_ref = NULL;
return msg;
}
#endif /* CH_CFG_USE_WAITEXIT */
#if CH_CFG_USE_MESSAGES
msg_t ThreadReference::sendMessage(msg_t msg) {
chDbgAssert(thread_ref != NULL,
"not referenced");
return chMsgSend(thread_ref, msg);
}
bool ThreadReference::isPendingMessage(void) {
chDbgAssert(thread_ref != NULL,
"not referenced");
return chMsgIsPendingI(thread_ref);
}
msg_t ThreadReference::getMessage(void) {
chDbgAssert(thread_ref != NULL,
"not referenced");
return chMsgGet(thread_ref);
}
void ThreadReference::releaseMessage(msg_t msg) {
chDbgAssert(thread_ref != NULL,
"not referenced");
chMsgRelease(thread_ref, msg);
}
#endif /* CH_CFG_USE_MESSAGES */
#if CH_CFG_USE_EVENTS
void ThreadReference::signalEvents(eventmask_t mask) {
chDbgAssert(thread_ref != NULL,
"not referenced");
chEvtSignal(thread_ref, mask);
}
void ThreadReference::signalEventsI(eventmask_t mask) {
chDbgAssert(thread_ref != NULL,
"not referenced");
chEvtSignalI(thread_ref, mask);
}
#endif /* CH_CFG_USE_EVENTS */
#if CH_CFG_USE_DYNAMIC
#endif /* CH_CFG_USE_DYNAMIC */
/*------------------------------------------------------------------------*
* chibios_rt::BaseThread *
*------------------------------------------------------------------------*/
BaseThread::BaseThread() : ThreadReference(NULL) {
}
msg_t BaseThread::main(void) {
return 0;
}
ThreadReference BaseThread::start(tprio_t prio) {
(void)prio;
return *this;
};
msg_t _thd_start(void *arg) {
return ((BaseThread *)arg)->main();
}
void BaseThread::setName(const char *tname) {
chRegSetThreadName(tname);
}
tprio_t BaseThread::setPriority(tprio_t newprio) {
return chThdSetPriority(newprio);
}
void BaseThread::exit(msg_t msg) {
chThdExit(msg);
}
void BaseThread::exitS(msg_t msg) {
chThdExitS(msg);
}
bool BaseThread::shouldTerminate(void) {
return chThdShouldTerminateX();
}
void BaseThread::sleep(systime_t interval){
chThdSleep(interval);
}
void BaseThread::sleepUntil(systime_t time) {
chThdSleepUntil(time);
}
void BaseThread::yield(void) {
chThdYield();
}
#if CH_CFG_USE_MESSAGES
ThreadReference BaseThread::waitMessage(void) {
ThreadReference tr(chMsgWait());
return tr;
}
#endif /* CH_CFG_USE_MESSAGES */
#if CH_CFG_USE_EVENTS
eventmask_t BaseThread::getAndClearEvents(eventmask_t mask) {
return chEvtGetAndClearEvents(mask);
}
eventmask_t BaseThread::addEvents(eventmask_t mask) {
return chEvtAddEvents(mask);
}
eventmask_t BaseThread::waitOneEvent(eventmask_t ewmask) {
return chEvtWaitOne(ewmask);
}
eventmask_t BaseThread::waitAnyEvent(eventmask_t ewmask) {
return chEvtWaitAny(ewmask);
}
eventmask_t BaseThread::waitAllEvents(eventmask_t ewmask) {
return chEvtWaitAll(ewmask);
}
#if CH_CFG_USE_EVENTS_TIMEOUT
eventmask_t BaseThread::waitOneEventTimeout(eventmask_t ewmask,
systime_t time) {
return chEvtWaitOneTimeout(ewmask, time);
}
eventmask_t BaseThread::waitAnyEventTimeout(eventmask_t ewmask,
systime_t time) {
return chEvtWaitAnyTimeout(ewmask, time);
}
eventmask_t BaseThread::waitAllEventsTimeout(eventmask_t ewmask,
systime_t time) {
return chEvtWaitAllTimeout(ewmask, time);
}
#endif /* CH_CFG_USE_EVENTS_TIMEOUT */
void BaseThread::dispatchEvents(const evhandler_t handlers[],
eventmask_t mask) {
chEvtDispatch(handlers, mask);
}
#endif /* CH_CFG_USE_EVENTS */
#if CH_CFG_USE_MUTEXES
void BaseThread::unlockMutex(Mutex *mp) {
chMtxUnlock(&mp->mutex);
}
void BaseThread::unlockMutexS(Mutex *mp) {
chMtxUnlockS(&mp->mutex);
}
void BaseThread::unlockAllMutexes(void) {
chMtxUnlockAll();
}
#endif /* CH_CFG_USE_MUTEXES */
#if CH_CFG_USE_SEMAPHORES
/*------------------------------------------------------------------------*
* chibios_rt::CounterSemaphore *
*------------------------------------------------------------------------*/
CounterSemaphore::CounterSemaphore(cnt_t n) {
chSemObjectInit(&sem, n);
}
void CounterSemaphore::reset(cnt_t n) {
chSemReset(&sem, n);
}
void CounterSemaphore::resetI(cnt_t n) {
chSemResetI(&sem, n);
}
msg_t CounterSemaphore::wait(void) {
return chSemWait(&sem);
}
msg_t CounterSemaphore::waitS(void) {
return chSemWaitS(&sem);
}
msg_t CounterSemaphore::wait(systime_t time) {
return chSemWaitTimeout(&sem, time);
}
msg_t CounterSemaphore::waitS(systime_t time) {
return chSemWaitTimeoutS(&sem, time);
}
void CounterSemaphore::signal(void) {
chSemSignal(&sem);
}
void CounterSemaphore::signalI(void) {
chSemSignalI(&sem);
}
void CounterSemaphore::addCounterI(cnt_t n) {
chSemAddCounterI(&sem, n);
}
cnt_t CounterSemaphore::getCounterI(void) {
return chSemGetCounterI(&sem);
}
msg_t CounterSemaphore::signalWait(CounterSemaphore *ssem,
CounterSemaphore *wsem) {
return chSemSignalWait(&ssem->sem, &wsem->sem);
}
/*------------------------------------------------------------------------*
* chibios_rt::BinarySemaphore *
*------------------------------------------------------------------------*/
BinarySemaphore::BinarySemaphore(bool taken) {
chBSemObjectInit(&bsem, taken);
}
msg_t BinarySemaphore::wait(void) {
return chBSemWait(&bsem);
}
msg_t BinarySemaphore::waitS(void) {
return chBSemWaitS(&bsem);
}
msg_t BinarySemaphore::wait(systime_t time) {
return chBSemWaitTimeout(&bsem, time);
}
msg_t BinarySemaphore::waitS(systime_t time) {
return chBSemWaitTimeoutS(&bsem, time);
}
void BinarySemaphore::reset(bool taken) {
chBSemReset(&bsem, taken);
}
void BinarySemaphore::resetI(bool taken) {
chBSemResetI(&bsem, taken);
}
void BinarySemaphore::signal(void) {
chBSemSignal(&bsem);
}
void BinarySemaphore::signalI(void) {
chBSemSignalI(&bsem);
}
bool BinarySemaphore::getStateI(void) {
return (bool)chBSemGetStateI(&bsem);
}
#endif /* CH_CFG_USE_SEMAPHORES */
#if CH_CFG_USE_MUTEXES
/*------------------------------------------------------------------------*
* chibios_rt::Mutex *
*------------------------------------------------------------------------*/
Mutex::Mutex(void) {
chMtxObjectInit(&mutex);
}
bool Mutex::tryLock(void) {
return chMtxTryLock(&mutex);
}
bool Mutex::tryLockS(void) {
return chMtxTryLockS(&mutex);
}
void Mutex::lock(void) {
chMtxLock(&mutex);
}
void Mutex::lockS(void) {
chMtxLockS(&mutex);
}
void Mutex::unlock(void) {
chMtxUnlock(&mutex);
}
void Mutex::unlockS(void) {
chMtxLockS(&mutex);
}
#if CH_CFG_USE_CONDVARS
/*------------------------------------------------------------------------*
* chibios_rt::CondVar *
*------------------------------------------------------------------------*/
CondVar::CondVar(void) {
chCondObjectInit(&condvar);
}
void CondVar::signal(void) {
chCondSignal(&condvar);
}
void CondVar::signalI(void) {
chCondSignalI(&condvar);
}
void CondVar::broadcast(void) {
chCondBroadcast(&condvar);
}
void CondVar::broadcastI(void) {
chCondBroadcastI(&condvar);
}
msg_t CondVar::wait(void) {
return chCondWait(&condvar);
}
msg_t CondVar::waitS(void) {
return chCondWaitS(&condvar);
}
#if CH_CFG_USE_CONDVARS_TIMEOUT
msg_t CondVar::wait(systime_t time) {
return chCondWaitTimeout(&condvar, time);
}
#endif /* CH_CFG_USE_CONDVARS_TIMEOUT */
#endif /* CH_CFG_USE_CONDVARS */
#endif /* CH_CFG_USE_MUTEXES */
#if CH_CFG_USE_EVENTS
/*------------------------------------------------------------------------*
* chibios_rt::EvtListener *
*------------------------------------------------------------------------*/
eventflags_t EvtListener::getAndClearFlags(void) {
return chEvtGetAndClearFlags(&ev_listener);
}
eventflags_t EvtListener::getAndClearFlagsI(void) {
return chEvtGetAndClearFlagsI(&ev_listener);
}
/*------------------------------------------------------------------------*
* chibios_rt::EvtSource *
*------------------------------------------------------------------------*/
EvtSource::EvtSource(void) {
chEvtObjectInit(&ev_source);
}
void EvtSource::registerOne(chibios_rt::EvtListener *elp,
eventid_t eid) {
chEvtRegister(&ev_source, &elp->ev_listener, eid);
}
void EvtSource::registerMask(chibios_rt::EvtListener *elp,
eventmask_t emask) {
chEvtRegisterMask(&ev_source, &elp->ev_listener, emask);
}
void EvtSource::unregister(chibios_rt::EvtListener *elp) {
chEvtUnregister(&ev_source, &elp->ev_listener);
}
void EvtSource::broadcastFlags(eventflags_t flags) {
chEvtBroadcastFlags(&ev_source, flags);
}
void EvtSource::broadcastFlagsI(eventflags_t flags) {
chEvtBroadcastFlagsI(&ev_source, flags);
}
#endif /* CH_CFG_USE_EVENTS */
#if CH_CFG_USE_QUEUES
/*------------------------------------------------------------------------*
* chibios_rt::InQueue *
*------------------------------------------------------------------------*/
InQueue::InQueue(uint8_t *bp, size_t size, qnotify_t infy, void *link) {
chIQObjectInit(&iq, bp, size, infy, link);
}
size_t InQueue::getFullI(void) {
return chIQGetFullI(&iq);
}
size_t InQueue::getEmptyI(void) {
return chIQGetEmptyI(&iq);
}
bool InQueue::isEmptyI(void) {
return (bool)chIQIsEmptyI(&iq);
}
bool InQueue::isFullI(void) {
return (bool)chIQIsFullI(&iq);
}
void InQueue::resetI(void) {
chIQResetI(&iq);
}
msg_t InQueue::putI(uint8_t b) {
return chIQPutI(&iq, b);
}
msg_t InQueue::get() {
return chIQGet(&iq);
}
msg_t InQueue::get(systime_t time) {
return chIQGetTimeout(&iq, time);
}
size_t InQueue::read(uint8_t *bp, size_t n, systime_t time) {
return chIQReadTimeout(&iq, bp, n, time);
}
/*------------------------------------------------------------------------*
* chibios_rt::OutQueue *
*------------------------------------------------------------------------*/
OutQueue::OutQueue(uint8_t *bp, size_t size, qnotify_t onfy, void *link) {
chOQObjectInit(&oq, bp, size, onfy, link);
}
size_t OutQueue::getFullI(void) {
return chOQGetFullI(&oq);
}
size_t OutQueue::getEmptyI(void) {
return chOQGetEmptyI(&oq);
}
bool OutQueue::isEmptyI(void) {
return (bool)chOQIsEmptyI(&oq);
}
bool OutQueue::isFullI(void) {
return (bool)chOQIsFullI(&oq);
}
void OutQueue::resetI(void) {
chOQResetI(&oq);
}
msg_t OutQueue::put(uint8_t b) {
return chOQPut(&oq, b);
}
msg_t OutQueue::put(uint8_t b, systime_t time) {
return chOQPutTimeout(&oq, b, time);
}
msg_t OutQueue::getI(void) {
return chOQGetI(&oq);
}
size_t OutQueue::write(const uint8_t *bp, size_t n, systime_t time) {
return chOQWriteTimeout(&oq, bp, n, time);
}
#endif /* CH_CFG_USE_QUEUES */
#if CH_CFG_USE_MEMPOOLS
/*------------------------------------------------------------------------*
* chibios_rt::MemoryPool *
*------------------------------------------------------------------------*/
MemoryPool::MemoryPool(size_t size, memgetfunc_t provider) {
chPoolObjectInit(&pool, size, provider);
}
MemoryPool::MemoryPool(size_t size, memgetfunc_t provider, void* p, size_t n) {
chPoolObjectInit(&pool, size, provider);
chPoolLoadArray(&pool, p, n);
}
void MemoryPool::loadArray(void *p, size_t n) {
chPoolLoadArray(&pool, p, n);
}
void *MemoryPool::allocI(void) {
return chPoolAllocI(&pool);
}
void *MemoryPool::alloc(void) {
return chPoolAlloc(&pool);
}
void MemoryPool::free(void *objp) {
chPoolFree(&pool, objp);
}
void MemoryPool::freeI(void *objp) {
chPoolFreeI(&pool, objp);
}
#endif /* CH_CFG_USE_MEMPOOLS */
}
/** @} */