arch/powerpc/platforms/powermac/pfunc_core.c

Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powermac/pfunc_core.c

File Facts

System
Linux kernel
Corpus path
arch/powerpc/platforms/powermac/pfunc_core.c
Extension
.c
Size
25575 bytes
Lines
1023
Domain
Architecture Layer
Bucket
arch/powerpc
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

struct pmf_cmd {
	const void		*cmdptr;
	const void		*cmdend;
	struct pmf_function	*func;
	void			*instdata;
	struct pmf_args		*args;
	int			error;
};

#if 0
/* Debug output */
static void print_blob(const char *title, const void *blob, int bytes)
{
	printk("%s", title);
	while(bytes--) {
		printk("%02x ", *((u8 *)blob));
		blob += 1;
	}
	printk("\n");
}
#endif

/*
 * Parser helpers
 */

static u32 pmf_next32(struct pmf_cmd *cmd)
{
	u32 value;
	if ((cmd->cmdend - cmd->cmdptr) < 4) {
		cmd->error = 1;
		return 0;
	}
	value = *((u32 *)cmd->cmdptr);
	cmd->cmdptr += 4;
	return value;
}

static const void* pmf_next_blob(struct pmf_cmd *cmd, int count)
{
	const void *value;
	if ((cmd->cmdend - cmd->cmdptr) < count) {
		cmd->error = 1;
		return NULL;
	}
	value = cmd->cmdptr;
	cmd->cmdptr += count;
	return value;
}

/*
 * Individual command parsers
 */

#define PMF_PARSE_CALL(name, cmd, handlers, p...) \
	do { \
		if (cmd->error) \
			return -ENXIO; \
		if (handlers == NULL) \
			return 0; \
		if (handlers->name)				      \
			return handlers->name(cmd->func, cmd->instdata, \
					      cmd->args, p);	      \
		return -1; \
	} while(0) \


static int pmf_parser_write_gpio(struct pmf_cmd *cmd, struct pmf_handlers *h)
{
	u8 value = (u8)pmf_next32(cmd);
	u8 mask = (u8)pmf_next32(cmd);

	LOG_PARSE("pmf: write_gpio(value: %02x, mask: %02x)\n", value, mask);

	PMF_PARSE_CALL(write_gpio, cmd, h, value, mask);
}

static int pmf_parser_read_gpio(struct pmf_cmd *cmd, struct pmf_handlers *h)
{
	u8 mask = (u8)pmf_next32(cmd);
	int rshift = (int)pmf_next32(cmd);
	u8 xor = (u8)pmf_next32(cmd);

	LOG_PARSE("pmf: read_gpio(mask: %02x, rshift: %d, xor: %02x)\n",
		  mask, rshift, xor);

	PMF_PARSE_CALL(read_gpio, cmd, h, mask, rshift, xor);
}

static int pmf_parser_write_reg32(struct pmf_cmd *cmd, struct pmf_handlers *h)

Annotation

Implementation Notes