arch/m68k/mm/motorola.c

Source file repositories/reference/linux-study-clean/arch/m68k/mm/motorola.c

File Facts

System
Linux kernel
Corpus path
arch/m68k/mm/motorola.c
Extension
.c
Size
12988 bytes
Lines
513
Domain
Architecture Layer
Bucket
arch/m68k
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (type) {
		case TABLE_PTE:
			/*
			 * m68k doesn't have SPLIT_PTE_PTLOCKS for not having
			 * SMP.
			 */
			pagetable_pte_ctor(mm, ptdesc);
			break;
		case TABLE_PMD:
			pagetable_pmd_ctor(mm, ptdesc);
			break;
		case TABLE_PGD:
			pagetable_pgd_ctor(ptdesc);
			break;
		}

		mmu_page_ctor(pt_addr);

		new = PD_PTABLE(pt_addr);
		PD_MARKBITS(new) = ptable_mask(type) - 1;
		list_add_tail(new, dp);

		return (pmd_t *)pt_addr;
	}

	for (tmp = 1, off = 0; (mask & tmp) == 0; tmp <<= 1, off += ptable_size(type))
		;
	PD_MARKBITS(dp) = mask & ~tmp;
	if (!PD_MARKBITS(dp)) {
		/* move to end of list */
		list_move_tail(dp, &ptable_list[type]);
	}
	return ptdesc_address(PD_PTDESC(dp)) + off;
}

int free_pointer_table(void *table, int type)
{
	ptable_desc *dp;
	unsigned long ptable = (unsigned long)table;
	unsigned long pt_addr = ptable & PAGE_MASK;
	unsigned int mask = 1U << ((ptable - pt_addr)/ptable_size(type));

	dp = PD_PTABLE(pt_addr);
	if (PD_MARKBITS (dp) & mask)
		panic ("table already free!");

	PD_MARKBITS (dp) |= mask;

	if (PD_MARKBITS(dp) == ptable_mask(type)) {
		/* all tables in ptdesc are free, free ptdesc */
		list_del(dp);
		mmu_page_dtor((void *)pt_addr);
		pagetable_dtor_free(virt_to_ptdesc((void *)pt_addr));
		return 1;
	} else if (ptable_list[type].next != dp) {
		/*
		 * move this descriptor to the front of the list, since
		 * it has one or more free tables.
		 */
		list_move(dp, &ptable_list[type]);
	}
	return 0;
}

/* size of memory already mapped in head.S */
extern __initdata unsigned long m68k_init_mapped_size;

extern unsigned long availmem;

static pte_t *last_pte_table __initdata = NULL;

static pte_t * __init kernel_page_table(void)
{
	pte_t *pte_table = last_pte_table;

	if (PAGE_ALIGNED(last_pte_table)) {
		pte_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
		if (!pte_table) {
			panic("%s: Failed to allocate %lu bytes align=%lx\n",
					__func__, PAGE_SIZE, PAGE_SIZE);
		}

		clear_page(pte_table);
		mmu_page_ctor(pte_table);

		last_pte_table = pte_table;
	}

	last_pte_table += PTRS_PER_PTE;

Annotation

Implementation Notes