Error adding new functions
Posted: Sun Dec 01, 2019 4:27 am
Hi everyone, in my newly started OS project I have a problem: following the wiki Meaty Skeleton I can't add new features like this:
inline.h file
file outb.c
If I try to use outb in the kernel, I get a undefined reference to 'outb' even if I add the outb.o file in the Makefile to the FREEOBJS list. Does anyone have any solution?
inline.h file
Code: Select all
#include <stdio.h>
#include <stdint.h>
#include <sys / cdefs.h>
#ifndef INLINE_H
#define INLINE_H 1
#ifdef __cplusplus
extern "C" {
#endif
static inline void outb (uint16_t port, uint8_t val):
static inline uint8_t inb (uint16_t port);
#ifdef __cplusplus
}
#endif
#endif
Code: Select all
#include <stdio.h>
#include <stdint.h>
#include <inline.h>
static inline void outb (uint16_t port, uint8_t val)
{
asm volatile ("outb% 0,% 1":: "a" (val), "Nd" (port));
/ * There's an outb% al, $ imm8 encoding, for compile-time constant port numbers that fit in 8b. (N constraint).
* Wider immediate constants would be truncated at assemble-time (e.g. "i" constraint).
* The outb% al,% dx encoding is the only option for all other cases.
*% 1 expands to% dx because port is a uint16_t. % w1 could be used if we had the port number a wider C type * /
}