Rev 854 | Rev 861 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 854 | Rev 859 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | static void __fastcall buddy_system_free(zone_t *z, link_t *block); |
28 | static void __fastcall buddy_system_free(zone_t *z, link_t *block); |
29 | static void zone_mark_unavailable(zone_t *zone, index_t frame_idx); |
29 | static void zone_mark_unavailable(zone_t *zone, index_t frame_idx); |
30 | 30 | ||
Line 31... | Line 31... | ||
31 | static addr_t __fastcall zone_alloc(zone_t *zone, u32_t order); |
31 | static addr_t __fastcall zone_alloc(zone_t *zone, u32_t order); |
- | 32 | void __fastcall zone_free(zone_t *zone, pfn_t frame_idx); |
|
Line 32... | Line 33... | ||
32 | 33 | ||
Line 33... | Line 34... | ||
33 | size_t buddy_conf_size(int max_order); |
34 | size_t buddy_conf_size(int max_order); |
Line 34... | Line -... | ||
34 | - | ||
35 | static inline void frame_initialize(frame_t *frame); |
- | |
36 | 35 | ||
Line 37... | Line 36... | ||
37 | static inline u32_t fnzb(u32_t arg); |
36 | static inline void frame_initialize(frame_t *frame); |
38 | 37 | ||
Line 209... | Line 208... | ||
209 | frame->refcount = 1; |
208 | frame->refcount = 1; |
210 | frame->buddy_order = 0; |
209 | frame->buddy_order = 0; |
211 | } |
210 | } |
212 | 211 | ||
Line 213... | Line -... | ||
213 | static inline count_t fnzb(u32_t arg) |
- | |
214 | { |
- | |
215 | int n; |
- | |
216 | asm volatile ("xor %0, %0 \n\t" |
- | |
217 | "bsr %0, %1" |
- | |
218 | :"=r" (n) |
- | |
219 | :"r"(arg) |
- | |
220 | ); |
- | |
221 | return n; |
- | |
222 | } |
- | |
Line 223... | Line 212... | ||
223 | 212 | ||
224 | static link_t *buddy_find_block(zone_t *zone, link_t *child, |
213 | static link_t *buddy_find_block(zone_t *zone, link_t *child, |
225 | u32_t order) |
214 | u32_t order) |
226 | { |
215 | { |
Line 500... | Line 489... | ||
500 | frame = (frame_t*)tmp; |
489 | frame = (frame_t*)tmp; |
501 | 490 | ||
Line 502... | Line 491... | ||
502 | /* get frame address */ |
491 | /* get frame address */ |
503 | v = make_frame_index(zone, frame); |
492 | v = make_frame_index(zone, frame); |
- | 493 | ||
504 | return v; |
494 | return v; |
505 | } |
495 | } |
Line 506... | Line 496... | ||
506 | 496 | ||
Line 516... | Line 506... | ||
516 | zone_get_frame(&z_core, pfn-z_core.base)->parent = data; |
506 | zone_get_frame(&z_core, pfn-z_core.base)->parent = data; |
517 | spinlock_unlock(&z_core.lock); |
507 | spinlock_unlock(&z_core.lock); |
518 | } |
508 | } |
519 | 509 | ||
Line -... | Line 510... | ||
- | 510 | void* __fastcall frame_get_parent(pfn_t pfn) |
|
- | 511 | { |
|
- | 512 | // zone_t *zone = find_zone_and_lock(pfn, &hint); |
|
- | 513 | void *res; |
|
- | 514 | ||
- | 515 | spinlock_lock(&z_core.lock); |
|
- | 516 | res = zone_get_frame(&z_core, pfn)->parent; |
|
- | 517 | spinlock_unlock(&z_core.lock); |
|
- | 518 | ||
- | 519 | return res; |
|
- | 520 | } |
|
Line 520... | Line 521... | ||
520 | 521 | ||
521 | static inline int to_order(count_t arg) |
522 | static inline int to_order(count_t arg) |
522 | { |
523 | { |
523 | int n; |
524 | int n; |
Line 546... | Line 547... | ||
546 | 547 | ||
Line 547... | Line 548... | ||
547 | return (v << FRAME_WIDTH); |
548 | return (v << FRAME_WIDTH); |
548 | } |
549 | } |
Line 549... | Line 550... | ||
549 | 550 | ||
550 | addr_t core_alloc(u32_t order) //__cdecl __dllexport |
551 | addr_t __fastcall core_alloc(u32_t order) //export |
551 | { |
552 | { |
552 | eflags_t efl; |
553 | eflags_t efl; |
Line 553... | Line 554... | ||
553 | pfn_t v; |
554 | pfn_t v; |
Line 560... | Line 561... | ||
560 | 561 | ||
Line 561... | Line 562... | ||
561 | return (v << FRAME_WIDTH); |
562 | return (v << FRAME_WIDTH); |
562 | }; |
563 | }; |
Line -... | Line 564... | ||
- | 564 | ||
- | 565 | void __fastcall core_free(addr_t frame) //export |
|
- | 566 | { |
|
- | 567 | eflags_t efl; |
|
- | 568 | ||
- | 569 | efl = safe_cli(); |
|
- | 570 | spinlock_lock(&z_core.lock); |
|
- | 571 | zone_free(&z_core, frame>>12); |
|
- | 572 | spinlock_unlock(&z_core.lock); |
|
- | 573 | safe_sti(efl); |
|
- | 574 | } |
|
563 | 575 | ||
564 | addr_t alloc_page() //obsolete |
576 | addr_t alloc_page() //obsolete |
565 | { |
577 | { |
566 | eflags_t efl; |
578 | eflags_t efl; |
567 | u32_t edx; |
579 | u32_t edx; |
Line 617... | Line 629... | ||
617 | zone->busy_count -= (1 << order); |
629 | zone->busy_count -= (1 << order); |
618 | } |
630 | } |
619 | } |
631 | } |
620 | 632 | ||
Line 621... | Line 633... | ||
621 | void core_free(addr_t frame) //export |
633 | void frame_free(addr_t frame) //export |
622 | { |
634 | { |
623 | eflags_t efl; |
635 | eflags_t efl; |
- | 636 | zone_t *zone; |
|
Line 624... | Line 637... | ||
624 | 637 | ||
625 | efl = safe_cli(); |
638 | efl = safe_cli(); |
626 | spinlock_lock(&z_core.lock); |
639 | spinlock_lock(&z_core.lock); |
627 | zone_free(&z_core, frame>>12); |
640 | zone_free(&z_core, frame>>12); |
628 | spinlock_unlock(&z_core.lock); |
641 | spinlock_unlock(&z_core.lock); |
629 | safe_sti(efl); |
642 | safe_sti(efl); |
Line 630... | Line 643... | ||
630 | } |
643 | } |
631 | 644 | ||
632 | void frame_free(addr_t frame) //export |
- | |
633 | { |
- | |
634 | eflags_t efl; |
- | |
635 | zone_t *zone; |
- | |
636 | - | ||
637 | efl = safe_cli(); |
645 | count_t get_free_mem() |
638 | spinlock_lock(&z_core.lock); |
- | |
639 | zone_free(&z_core, frame>>12); |
- | |
640 | spinlock_unlock(&z_core.lock); |
646 | { |