1037 Commits

Author SHA1 Message Date
Murai Takashi
8cd3603b99 compat/freebsd_network: Fix Use of zero-allocated memory
If device is not found, 'list' is allocated to size 0.
So, modify function to return 0 as FreeBSD's subr_bus.c
when 'count' is 0.
Pointed out by Clang Static Analyzer.

Change-Id: Ice24ae939bfcdb6e1276a86dba40d0b689030fbb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3753
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-03-02 14:19:54 +00:00
X512
779ab335dd use .IsSet() instead if .Get() != NULL
Change-Id: Ia2b7a719fd398e78cc3b11d4f7b02cb81179f65f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3488
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2021-02-02 15:17:54 +00:00
Murai Takashi
44e4aca7cc compat/freebsd_network: Fix dead store
Fix value stored to 'newPowerManagementStatus' is never read.
Pointed out by Clang Static Analyzer.

It seems FreeBSD's pci_set_powerstate_method() writes 'status'
(newPowerManagementStatus in Haiku) with PCI_WRITE_CONFIG
(pci_write_config in Haiku).

Change-Id: I9b11f746ed8e772a3f839e1bd5a6b432c9e8ff6b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3513
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-12-15 21:55:43 +00:00
Jérôme Duval
b943b993c7 freebsd_network: Use user_memcpy() for ETHER_ADDMULTI/ETHER_REMMULTI
Change-Id: Id0a7e50f9ae38bff42faf1d6c4a62f702347bda3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3446
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-12-02 07:40:16 +00:00
Murai Takashi
56e857a499 libs/util: Fix -Wformat=
Change-Id: I2ef917da71d4e436c274dfeb13386936e1c9d2d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3362
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2020-11-02 07:20:28 +00:00
Murai Takashi
5d80f760f5 libs/gnu: Fix -Wformat=
Change-Id: I29db5d08cf575cf1aaada131270c4b3ccc65720e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3311
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-10-13 15:19:14 +00:00
Augustin Cavalier
e6076c6d2e freebsd_network: Define _KERNEL for C++ files too.
This also allows the removal of a function that is also in the cpufunc.h header.
2020-10-11 20:36:41 -04:00
CodeforEvolution
5c32512076 GNU Compatibility: Implement qsort_r
This is a version of the qsort function allowing you to pass a "cookie" to the function.

Change-Id: I60c645213b9c9590e38b112634fcac1d7969b6d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2449
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-18 06:25:20 +00:00
Adrien Destugues
b4b9e2089f libicon: reorder gradient stops when loading from BMessage
Some files have gradients stops stored in an incorrect order.

Fixes #14210
2020-08-02 17:42:44 +02:00
Michael Lotz
b0a3a5c9bc freebsd_network: Handle 64 bit memory BARs.
This adds the upper 32 bits for address and size.

Change-Id: I2f776c7b8b72ecefca9f3b93d9c42912666a41e2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3026
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-07-11 23:31:06 +00:00
Michael Lotz
8827bb6d89 freebsd_network: Apply empty size and type check to IO ports.
Factor out the conversion to BAR index and hand the pci_info to both
memory and IO port allocation functions. Then apply the same checks
in the IO port case as are done for memory.

This aligns with what is done on FreeBSD.

Change-Id: Ib4bd28fd861959a467ba676de22efb1f97e5a27c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3025
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-07-11 23:31:06 +00:00
Augustin Cavalier
c70ec71d0c freebsd_network: Move ticks/seconds conversions to sys/time.h and
rename.

They now match the names they have in FreeBSD.
No functional change intended.
2020-07-05 21:16:32 -04:00
Augustin Cavalier
a68e59dd1d freebsd_network: Fix destruction of ref-counted ext_bufs.
The check as to whether or not the buf should be freed was wrong,
leading to incorrect frees.

Fixes double-free KDLs under the idualwifi driver that occur
on boot extremely frequently.

Change-Id: Ia411a6f5c31dd30764705cd87840797f862b4020
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2862
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-06-02 03:13:59 +00:00
Adrien Destugues
2a3b385efb Icon-O-Matic: replace SVG parser with nanosvg
The parser was based on an old example from agg. NanoSVG is originally
based on the same code, but has lots of bugfixes. So it makes sense
to use it.

Nanosvg revision 25241c5a8f8451d41ab1b02ab2d865b01600d949

Fixes #5955, #8586, #13021.

Change-Id: I38ff9aa4e1d403c41979ebe42f7b45d4500a870c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2661
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-22 14:08:17 +00:00
Adrien Destugues
2dc597d50d Optimize ffs() implementation
- Use gcc builtin
- Define as a static inline function in the .h so no function call overhead is needed
- Keep the function in libroot for backwards compatibility
- Remove a duplicate implementation in the freebsd compatibility layer

gcc2 does not document the builtin, but it is in fact already available
there as well.

Fixes #3281.

Change-Id: I94f8a2548637aa70e85febbfab06f07c1a427005
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2605
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-08 14:01:53 +00:00
Augustin Cavalier
5332b1ce28 freebsd_network: Remove bogus KASSERT.
As pointed out by halamix, root_size is set to > 0 during
radix_bitmap creation, and never changed after that. So
this is a bogus check.

Fixes #14941.
2020-04-23 01:05:33 -04:00
Adrien Destugues
e4225c3b0e Remove struct size hacks in net80211
wpa_supplicant needs to be rebuilt
against it and then this needs to be tested.

Added some FIXMEs to keep track of places I'm not sure if we need to
change anything.

Fixes #14805

Change-Id: I6379dc32b772289960afbfb362365a542a986983
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2225
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-04-12 21:09:30 +00:00
navinbarnwal
c770613157 libprint: Small code formatting fix
Change-Id: I40735e8994a8a4804401ce2694bb0f305216bbf4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2453
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-04-06 07:02:00 +00:00
waddlesplash
8e12c92fee freebsd_network: Implement mtx_destroy for spinlocks.
Somehow, I missed this when implementing MTX_SPIN in the first place,
and it went largely unnoticed because MTX_SPIN is rarely used and
apparently even more rarely destroyed.

Should fix #15749.
2020-03-24 21:06:37 -04:00
Leorize
4657aba9da freebsd_network/malloc: include kernel/heap.h
This header was not included when Haiku is built with KDEBUG_LEVEL=0,
causing build failures.

Change-Id: I690064f7c1a9818056a394e2655811775c4cc554
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2360
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-03-15 23:31:27 +00:00
François Revol
0960949012 m68k: build fix
Change-Id: I3e2b106d5b14a84523e74024616a5c168f011e1a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2216
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-02-06 00:07:15 +00:00
Murai Takashi
450f71e21e agg: trans_double_path::reset(): reset m_kindex2
Fix PVS V519
Pointed out in PVS-Studio blog
https://medium.com/pvs-studio/best-copy-paste-algorithms-for-c-and-c-haiku-os-cookbook-8e15876d2547

Change-Id: Ie6b9ae42f246bf201e30d19968a502268e80fe6d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2116
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-01-22 00:29:36 +00:00
Augustin Cavalier
a1e74397a1 build: Rework gcc2 test_app_server build logic a bit. 2020-01-05 17:17:41 -05:00
Adrien Destugues
003169fbb3 libprint: remove arbitrary limitation of allocation size
libprint had a very conservative size limitation (4MB) for the bitmap it
allocates. This leads to splitting a page to print in several "bands"
(about 5 in my testing). However, these may still be too large for the
printer driver to handle, which means the driver may be further slicing
things up, or other drivers may need the full page anyway and recompose
it in some way.

Instead of an hardcoded limit, now try to allocate a bitmap for the
whole page, and if that doesn't work, progressively increase the number
of bands until we manage to allocate a bitmap. Stop when we have split
the page in 256 bands, as it seems rather pointless to be that far. Call
debugger when this happens, as there doesn't seem to be a way to do
better error handling here (the code used to raise std::bad_alloc if
BBitmap allocation failed, or just return an invalid bitmap and view).

Change-Id: Iba690f68c748d20828709244a23e82a08185390e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1922
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-01-01 10:19:19 +00:00
Ynoga
09b40d1634 ppc: Minor tweaks to get the arch compile again (WIP)
- Factor in types changes (introduction of intptr_t)
- Align JamFiles syntax with in progress architectures (arm/sparc)
- Xorriso doesn't support much of the mkisofs options (anymore ?)
- (After a correct bootstrap) one should be able to build @minimum-raw and haiku-boot-cd again
Change-Id: I4f779ad8f2210389fa9b7f7c0a98c3652a64c257
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1983
Reviewed-by: François Revol <revol@free.fr>
2019-12-04 18:34:31 +00:00
Augustin Cavalier
caef66c2cd freebsd_network: Return to allocating the segments in dmamap_load.
It seems some drivers do not create dmamaps for all their bustags,
so we can't allocate the segments there. And of course, some also
do not go through dmamem_alloc, so the only option then is to revert
to where FreeBSD allocates them, inside dmamap_load.
2019-12-03 17:52:23 -05:00
waddlesplash
7100b1e1f5 freebsd_network: Move segment array allocation in bus_dma to dmamap_create().
It seems that some drivers (e.g. broadcom43xx) create a parent DMA tag
with nsegments set to BUS_SPACE_UNRESTRICTED, i.e. MAX_INT, which of
course fails allocation, expecting to never allocate memory for this
tag, only for child tags. So in order to handle this, we have to
delay allocating the segment array until we are certain that the nsegments
value is the "real deal".

Doing it in dmamap_load would be fine, but as there is more than one
entry point to that, we would have to allocate this in multiple places.
dmamap_create() must be called and there is only one way through it,
so put the allocation there.

Fixes #15500 (i.e. both the KDL and the underlying problem that
led to it; it only crashed because the wrong pointer was passed
to kernel_free, whoops.)
2019-12-02 20:37:52 -05:00
Augustin Cavalier
a3dc96a3a2 freebsd_network: Use ifmedia_baudrate to compute the link speed.
This is much more accurate than testing only 2 IFM_* types.
2019-11-23 16:28:40 -05:00
Augustin Cavalier
26b95c15f2 freebsd_network: Completely overhaul bus_dma implementation.
The old implementation was based on an ancient copy of the FreeBSD
busdma code for x86, and did not make a bunch of assumptions that
we make basically everywhere else (for instance, that we can request
arbitrarily-aligned contiguous physical memory from the VM.)

As a consequence, it had a significant amount of code devoted to
bounce pages, which are just a waste of resources on x86, and
for that matter, probably any other architecture Haiku will ever
be ported to. (Even if we do need to run on some system where
only a small portion of system memory can be accessed by devices,
likely we would reserve that memory for just this occasion anyway.)

I was initially under the impression that the bounce-pages code
never turned on, but apparently due to the "alignment" check
(and also the "Maxmem" check, which was to defined to 32KB...?!)
it does indeed activate on a variety of systems, and maybe
(in the case of drivers that do not call sync() properly) even
is the cause of some of our ported driver breakage.

The new implementation is pretty much optimized for Haiku,
and shares almost no code or structure with the old one (save
for a few functions that really only have one proper implementation.)

Tested with ipro1000 and rtl81xx. Regressions are more than possible,
so please don't hesitate to file bugs if your network driver now
fails to come up (or you get KDLs.)
2019-11-22 22:19:43 -05:00
Augustin Cavalier
56cb682b80 freebsd_network: Moderate reorganization.
* Rename device.c to device_hooks.c, as this is what it really contains.
 * Rename compat.c to device.c, as it implements the generic "device"
   related functions, both for compat layer internals and FreeBSD
   public ones.
 * Move malloc and related operations out of the now-device.c,
   and place them in a new "malloc.cpp", which also incorporates
   compat_cpp.cpp.

No functional change intended.
2019-11-22 22:19:43 -05:00
Augustin Cavalier
c903bc728b freebsd_iflib: Fix usage of kobj_lookup_method.
Should solve #15441. We should probably enable -Werror=incompatible-ptr
globally to avoid this in the future...
2019-10-23 21:11:42 -04:00
Kyle Ambroff-Kao
d8779e44ee Drop requirement for specifying firmware map size
The HAIKU_FIRMWARE_NAME_MAP macro takes a size parameter to define the
firmware map array type, and then a multi-dimensional array literal is
assigned to the array defined by that macro.

This is error-prone. The idualwifi7260 driver, before this patch, had
the size incorrectly set to 6 when the number of entries was 7, which
sliced the last entry off of the map, making it unavailable to the
driver. After fixing this size, the driver properly loads the
iwm-8265-22.ucode firmware on my computer.

This patch changes that macro to take a const char[][2] literal as its
only parameter, making it less likely for this sort of bug to be
re-introduced.

Fixes #15413.

Change-Id: I78a75e692a8637af0f13d1eb16180ce8d95d0852
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1917
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-10-16 00:23:55 +00:00
waddlesplash
fb8915c671 freebsd_iflib: Also NULL-check ctx. 2019-10-10 20:32:57 -04:00
Augustin Cavalier
8af29cccf5 freebsd_iflib: Add NULL check to irq_free.
Should fix #15402.
2019-10-09 20:57:00 -04:00
Augustin Cavalier
6ad99cdddf freebsd_iflib: Synchronize with FreeBSD trunk.
Up through Sep. 20th (yesterday.) Includes some pretty substantial
fixes around MSI interrupts, among other things.
2019-09-21 18:38:35 -04:00
Simon South
a041f1b49c GLUT: Fix message handling in GlutWindow
Call the superclass implementation of MessageReceived() to process messages not
handled by GlutWindow itself.

This restores mouse and keyboard functionality in OpenGL apps, including
Celestia, affected by commit 75e5739772.

Change-Id: Ic3af56ab2f78e8b2b8be576d2edc30bb7357f359
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1862
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-09-13 22:57:04 +00:00
Jaroslaw Pelczar
412e096a06 trans_double_path: Fix member initialization order
Silence GCC -Wreorder warning

Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: I14a9e314805f5a39faf6d8a9beb6e6bc24a71eec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1820
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-09-02 17:14:29 +00:00
Jaroslaw Pelczar
1761cb8e6f arm64: Add more headers for code compilation
This makes ARM64 target compile more files. This patch is one of
series of patches to support new architecture, as fixes in many
places are required just to compile the code.

Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: Ia060612733cd3a0fcb781fec449da164ed635b8e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1807
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-09-01 03:02:49 +00:00
Adrien Destugues
4950607607 Add a features.h to auto enable _DEFAULT_SOURCE
Unless __STRICT_ANSI__ is defined (as it is when running the compiler in
--std=c89 or --std=c99, but not when running it without any specific
args), we can enable these by default and behave like most other
systems. I don't know why no one has done this yet despite suggesting it
multiple times and people prefer to #define _BSD_SOURCE manually
everywhere.

Remove all places in our Jamfiles and sources where it had been defined.
_DEFAULT_SOURCE is now enabled by default for all sources of Haiku, since we
let the compiler use GNU extensions (no strict C standard specified on
command line)

Use _DEFAULT_SOURCE as the define name to match current versions of
glibc. Enable it if _BSD_SOURCE is #defined in compiler flags, for
backward compatibility.

Change-Id: I6db04da5f6db437723cdfba3478f5094a69d7727
Reviewed-on: https://review.haiku-os.org/c/1633
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2019-07-29 20:26:46 +00:00
Adrien Destugues
91ec679f17 PVS V1010: access before start of buffer after fgets
Change-Id: I8cfa1e8a3c8dd8c2837e51756ac3eeaea1e756f0
Reviewed-on: https://review.haiku-os.org/c/1639
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-21 20:05:08 +00:00
Adrien Destugues
fbe53d9249 PVS V1031: missing includes for memcpy/memset
Change-Id: I106027c0b8a367be1e58598f124e3a6d6541ee32
Reviewed-on: https://review.haiku-os.org/c/1622
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-17 22:17:22 +00:00
Bruno Albuquerque
8c76ab00c4 freebsd_network: Enable memory mapped io and ioport access.
Cofirmed to fix #15016, #15052.
Potentially fixes #14576, #14546, #14298, #14265, #13840.

Change-Id: I27b0bb6692c23aedbdddc70aff9349c713703dd4
Reviewed-on: https://review.haiku-os.org/c/1497
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-05-31 17:02:48 +00:00
Augustin Cavalier
3ca2e85bfd Interface: Add casts to memcpy/memset invocations on BPoint & BRect.
Their copy constructors are exactly what GCC would generate,
but we can't remove them because doing so would make them
trivially copyable, and so they would be passed in registers
on x86_64, an ABI breakage.

So instead we have to add explicit casts to void* here.
2019-05-24 16:10:13 -04:00
Augustin Cavalier
1705656eac Add (void*) casts to memcpy/memset invocations to appease GCC 8.
A lot of these classes are not *technically* "trivially copyable"
for one reason or another, but in all of these cases it seems
OK to me to use memcpy/memset on them. Adding a cast to void*
tells GCC that "I know what I'm doing here" and shuts up the
warning.
2019-05-24 14:21:37 -04:00
Augustin Cavalier
d906fe3cc7 freebsd_network: Allocate a new root device for every attach.
This also means that when attach fails, we destroy the root device.
This should fix stale root devices getting left around when attach
fails.

Probably helps with or even outright fixes #15016.
2019-05-20 11:51:44 -04:00
Augustin Cavalier
c5f96e5b4a net80211: Merge a memory leak fix from FreeBSD. 2019-05-16 15:11:01 -04:00
Jérôme Duval
89f1fd6512 Bump gutenprint version.
needs gutenprint8 packages to be uploaded.

Change-Id: I1204ff8b1bb85cc0eb615082b205280daabbc290
Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2019-05-14 19:11:41 -04:00
Augustin Cavalier
32cbf55317 freebsd_network: Fix logic inversion introduced in the last change.
Thanks to Stephan for noticing!
2019-05-14 12:03:00 -04:00
Bruno Albuquerque
9888752db1 freebsd_network: Style fixes pointed out by Korli.
- Did not see his comments before pushing my previous change.
- clear owning flag when passed value is NULL.

Change-Id: I493973aff2b107785c3734847c85a52f0f9da360
Reviewed-on: https://review.haiku-os.org/c/1443
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-05-13 18:58:04 +00:00
Bruno Albuquerque
7f6254d1e9 Prevent a double softc free.
- Keep track if the softc was allocated externally or not.
- Only try to deallocate it if it was allocated internally.

Do not try to free the softc if we were not the ones allocating it.

- Avoid a double free on consecutive calls to device_set_softc.

Change-Id: Ibb38e54e9dfd2a80dbb53920970bead626da8ba1
Reviewed-on: https://review.haiku-os.org/c/1441
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-05-08 15:31:31 +00:00