Skip to content

Commit

Permalink
Merge pull request #10 from no92/kbl
Browse files Browse the repository at this point in the history
Kaby Lake modesetting support
  • Loading branch information
Dennisbonke authored May 6, 2024
2 parents 310ee00 + 69c6d36 commit 2264a2d
Show file tree
Hide file tree
Showing 99 changed files with 7,226 additions and 1,767 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.cross-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[binaries]
c = ['gcc-13']
cpp = ['g++-13']

[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,29 @@ on: [push, pull_request]
jobs:
build-lil:
name: Build lil
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Install prerequisites
run: |
set -x
sudo apt-get update
sudo apt-get install meson
sudo apt-get install gcc-13 ninja-build
pip3 install meson
- name: Checkout lil
uses: actions/checkout@v2
- name: Prepare build
run: |
set -x
mkdir -p build/
meson setup --buildtype=debugoptimized build/
mkdir -p build build-util
meson setup --buildtype=debugoptimized --cross-file=.github/workflows/ci.cross-file build/
meson setup --buildtype=debugoptimized --native-file=.github/workflows/ci.cross-file -Dbuild_utils=true build-util/
- name: Build lil
run: |
set -x
ninja
working-directory: build/
- name: Build lil-utils
run: |
set -x
ninja
working-directory: build-util/
22 changes: 22 additions & 0 deletions include/lil/fourcc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define fourcc_code(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))

#define FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */
#define FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */

#define FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */
#define FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */
#define FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */
#define FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */

#ifdef __cplusplus
}
#endif

63 changes: 45 additions & 18 deletions include/lil/imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,39 @@
#include <stdint.h>
#include <stddef.h>

#include "intel.h"

#ifdef __cplusplus
extern "C" {
#endif

enum LilLogType {
ERROR,
WARNING,
INFO,
VERBOSE,
DEBUG,
};

void *memcpy(void *restrict dest, const void *restrict src, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memset(void *s, int c, size_t n);
int strcmp(const char *s1, const char *s2);
#ifndef __STDC_HOSTED__

__attribute__((nonnull(1, 2))) void *memcpy(void *dest, const void *src, size_t n);
__attribute__((nonnull(1, 2))) int memcmp(const void *s1, const void *s2, size_t n);
__attribute__((nonnull(1))) void *memset(void *s, int c, size_t n);
__attribute__((nonnull(1, 2))) int strcmp(const char *s1, const char *s2);

#else

#include <string.h>

__attribute__((weak)) void lil_pci_writeb(void* device, uint16_t offset, uint8_t val);
__attribute__((weak)) uint8_t lil_pci_readb(void* device, uint16_t offset);
__attribute__((weak)) void lil_pci_writew(void* device, uint16_t offset, uint16_t val);
__attribute__((weak)) uint16_t lil_pci_readw(void* device, uint16_t offset);
__attribute__((weak)) void lil_pci_writed(void* device, uint16_t offset, uint32_t val);
__attribute__((weak)) uint32_t lil_pci_readd(void* device, uint16_t offset);
#endif

__attribute__((nonnull(1))) void lil_pci_writeb(void* device, uint16_t offset, uint8_t val);
__attribute__((nonnull(1))) uint8_t lil_pci_readb(void* device, uint16_t offset);
__attribute__((nonnull(1))) void lil_pci_writew(void* device, uint16_t offset, uint16_t val);
__attribute__((nonnull(1))) uint16_t lil_pci_readw(void* device, uint16_t offset);
__attribute__((nonnull(1))) void lil_pci_writed(void* device, uint16_t offset, uint32_t val);
__attribute__((nonnull(1))) uint32_t lil_pci_readd(void* device, uint16_t offset);

__attribute__((weak)) void lil_outb(uint16_t port, uint8_t value);
__attribute__((weak)) void lil_outw(uint16_t port, uint16_t value);
Expand All @@ -29,11 +44,23 @@ __attribute__((weak)) uint8_t lil_inb(uint16_t port);
__attribute__((weak)) uint16_t lil_inw(uint16_t port);
__attribute__((weak)) uint32_t lil_ind(uint16_t port);

__attribute__((weak)) void lil_sleep(uint64_t ms);
__attribute__((weak)) void lil_usleep(uint64_t us);
__attribute__((weak)) void* lil_malloc(size_t s);
__attribute__((weak)) void lil_free(void* p);
__attribute__((weak)) void* lil_map(size_t loc, size_t len);
__attribute__((weak)) void lil_unmap(void *loc, size_t len);
__attribute__((weak)) void lil_log(enum LilLogType type, const char *fmt, ...);
__attribute__((weak, noreturn)) void lil_panic(const char* msg);
void lil_sleep(uint64_t ms);
void lil_usleep(uint64_t us);
__attribute__((malloc, returns_nonnull)) void* lil_malloc(size_t s);
__attribute__((nonnull(1))) void lil_free(void* p);
__attribute__((nonnull(1, 3, 4))) void lil_get_bar(void *device, int bar, uintptr_t *obase, uintptr_t *len);
__attribute__((weak, returns_nonnull)) void* lil_map(size_t loc, size_t len);
__attribute__((weak, nonnull(1))) void lil_unmap(void *loc, size_t len);
__attribute__((format(printf, 2, 3), nonnull(2))) void lil_log(enum LilLogType type, const char *fmt, ...);
__attribute__((noreturn, nonnull(1))) void lil_panic(const char* msg);

#define lil_assert(x) if(!(x)) { \
lil_log(ERROR, "assertion '%s' failed (%s:%u)\n", #x, __FILE__, __LINE__); \
lil_panic("assertion failed"); \
}

__attribute__((weak)) const struct vbt_header *lil_vbt_locate(struct LilGpu *gpu);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 2264a2d

Please sign in to comment.